// since surefire and eclipse don't otherwise guarantee the order, we are
  // starting this one alphabetically before create2nodes..
  @Test(enabled = true, dependsOnMethods = "testImagesCache")
  public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
    String tag = this.tag + "run";
    try {
      client.destroyNodesMatching(NodePredicates.withTag(tag));
    } catch (Exception e) {

    }

    TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
    try {
      Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
      Credentials good = nodes.iterator().next().getCredentials();
      assert good.account != null;
      assert good.key != null;

      Image image = Iterables.get(nodes, 0).getImage();
      try {
        Map<? extends NodeMetadata, ExecResponse> responses =
            runScriptWithCreds(tag, image.getOsFamily(), new Credentials(good.account, "romeo"));
        assert false : "shouldn't pass with a bad password\n" + responses;
      } catch (RunScriptOnNodesException e) {
        assert Throwables.getRootCause(e).getMessage().contains("Auth fail") : e;
      }

      runScriptWithCreds(tag, image.getOsFamily(), good);

      checkNodes(nodes, tag);

    } finally {
      client.destroyNodesMatching(NodePredicates.withTag(tag));
    }
  }
  // since surefire and eclipse don't otherwise guarantee the order, we are
  // starting this one alphabetically before create2nodes..
  @Test(
      enabled = true,
      dependsOnMethods = {"testCompareSizes"})
  public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
    String tag = this.tag + "run";
    try {
      client.destroyNodesMatching(withTag(tag));
    } catch (Exception e) {

    }

    TemplateOptions options = client.templateOptions().blockOnPort(22, 120);
    try {
      Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
      Credentials good = nodes.iterator().next().getCredentials();
      assert good.identity != null : nodes;
      assert good.credential != null : nodes;

      OperatingSystem os = get(nodes, 0).getOperatingSystem();
      try {
        Map<? extends NodeMetadata, ExecResponse> responses =
            runScriptWithCreds(tag, os, new Credentials(good.identity, "romeo"));
        assert false : "shouldn't pass with a bad password\n" + responses;
      } catch (RunScriptOnNodesException e) {
        assert getRootCause(e).getMessage().contains("Auth fail") : e;
      }

      runScriptWithCreds(tag, os, good);

      checkNodes(nodes, tag);

    } finally {
      client.destroyNodesMatching(withTag(tag));
    }
  }
  public void testOptionToNotBlock() throws Exception {
    String tag = this.tag + "block";
    try {
      client.destroyNodesMatching(withTag(tag));
    } catch (Exception e) {

    }
    // no inbound ports
    TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts();
    try {
      long time = System.currentTimeMillis();
      Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
      NodeMetadata node = getOnlyElement(nodes);
      assert node.getState() != NodeState.RUNNING;
      long duration = System.currentTimeMillis() - time;
      assert duration < 30 * 1000 : "duration longer than 30 seconds!:  " + duration / 1000;
    } finally {
      client.destroyNodesMatching(withTag(tag));
    }
  }
  @Test(enabled = true, dependsOnMethods = "testGet")
  public void testOptionToNotBlock() throws Exception {
    String tag = this.tag + "block";
    try {
      client.destroyNodesMatching(NodePredicates.withTag(tag));
    } catch (Exception e) {

    }
    // no inbound ports
    TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts();
    try {
      long time = System.currentTimeMillis();
      Set<? extends NodeMetadata> nodes = client.runNodesWithTag(tag, 1, options);
      NodeMetadata node = Iterables.getOnlyElement(nodes);
      assertEquals(node.getState(), NodeState.PENDING);

      long duration = System.currentTimeMillis() - time;
      assert duration < 30 * 1000 : "duration longer than 30 seconds!:  " + duration / 1000;
    } finally {
      client.destroyNodesMatching(NodePredicates.withTag(tag));
    }
  }