Package org.jclouds.scriptbuilder.domain

Examples of org.jclouds.scriptbuilder.domain.Statement


    controller.destroyCluster(clusterSpec);
  }

  @Test
  public void testVersion() throws Exception {
    Statement checkVersion = Statements.exec("ls /etc/alternatives/hadoop-lib");
    Map<? extends NodeMetadata, ExecResponse> responses =
       controller.runScriptOnNodesMatching(clusterSpec, ALL, checkVersion);

    printResponses(checkVersion, responses);
    assertResponsesContain(responses, checkVersion, "cdh3u2");
View Full Code Here


    if (family.equals(OsFamily.UNIX)) {
      // store the json file in tmp
      String fileName = "/tmp/" + this.fileName + ".json";

      Statement storeJSonFile = Statements.createOrOverwriteFile(fileName,
          Collections.singleton(toJSON()));

      Statement runRecipe = null;

      runRecipe = Statements.exec("sudo -i chef-solo -j " + fileName
          + (url != null ? " -r " + url : ""));

      return Statements.newStatementList(storeJSonFile, runRecipe).render(
View Full Code Here

   // fail faster than normal
   Timeouts timeouts = injector.getInstance(Timeouts.class);

   @Test(expectedExceptions = IllegalStateException.class)
   public void testWithoutInitThrowsIllegalStateException() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("testpassword!").build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

      testMe.call();
   }

   public void testDefault() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING)
            .credentials(LoginCredentials.builder().user("tester").password("testpassword!").build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

      verify(sshClient);
   }

   public void testWithSudoPassword() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("testpassword!").authenticateSudo(true).build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

   /**
    * in a couple versions of ubuntu on aws-ec2, status returneds no pid (ex. empty stdout w/exit code 1) transiently. sadly, we need to doublecheck status before assuming it has failed.
    *
    */
   public void testDoublecheckStatusInCaseTransientlyWrong() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("testpassword!").authenticateSudo(true).build()).build();

      SshClient sshClient = createMock(SshClient.class);

View Full Code Here

     
      verify(sshClient);
   }
  
   public void testNotRoot() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("testpassword!").authenticateSudo(true).build()).build();

      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

      verify(sshClient);
   }
  
   public void testBadReturnCode() {
      Statement command = exec("doFoo");
      NodeMetadata node = new NodeMetadataBuilder().ids("badreturncode").status(Status.RUNNING).credentials(
            LoginCredentials.builder().user("tester").password("testpassword!").authenticateSudo(true).build()).build();
     
      SshClient sshClient = createMock(SshClient.class);
View Full Code Here

@Test(groups = "unit")
public class CredentialsFromAdminAccessTest {

   public void testWhenNotAdminAccess() {

      Statement statement = Statements.exec("echo hello");
      assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statement), null);

      Statement statementList = Statements.newStatementList(statement);
      assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statementList), null);

   }
View Full Code Here

            .defineDataBag(databagBar).build();

      solo.createDatabagsIfNecessary(statements);
      ImmutableList<Statement> statementList = statements.build();

      Statement expectedFoo = createOrOverwriteFile("/tmp/databags/foo/itemFoo.json",
            ImmutableSet.of("{\"foo\":\"bar\"}"));
      Statement expectedBar = createOrOverwriteFile("/tmp/databags/bar/itemBar.json",
            ImmutableSet.of("{\"bar\":\"foo\"}"));
      Statement expectedExtra = createOrOverwriteFile("/tmp/databags/bar/extra.json", ImmutableSet.of("{\"extra\":[]}"));

      assertEquals(statementList.size(), 6);
      assertEquals(statementList.get(0), exec("{md} /tmp/databags"));
      assertEquals(statementList.get(1), exec("{md} /tmp/databags/" + databagFoo.getName()));
      assertEquals(statementList.get(2).render(OsFamily.UNIX), expectedFoo.render(OsFamily.UNIX));
      assertEquals(statementList.get(3), exec("{md} /tmp/databags/" + databagBar.getName()));
      assertEquals(statementList.get(4).render(OsFamily.UNIX), expectedBar.render(OsFamily.UNIX));
      assertEquals(statementList.get(5).render(OsFamily.UNIX), expectedExtra.render(OsFamily.UNIX));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.scriptbuilder.domain.Statement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.