protected List<String> setupDefaultMaster(final int offset, String... args) throws Exception {
    // TODO (dano): Move this bootstrapping to something reusable
    final CuratorFramework curator = zk.curatorWithSuperAuth();
    curator.newNamespaceAwareEnsurePath(Paths.configHosts()).ensure(curator.getZookeeperClient());
    curator.newNamespaceAwareEnsurePath(Paths.configJobs()).ensure(curator.getZookeeperClient());
    curator.newNamespaceAwareEnsurePath(Paths.configJobRefs()).ensure(curator.getZookeeperClient());
    curator.newNamespaceAwareEnsurePath(Paths.statusHosts()).ensure(curator.getZookeeperClient());
    curator.newNamespaceAwareEnsurePath(Paths.statusMasters()).ensure(curator.getZookeeperClient());
    curator.newNamespaceAwareEnsurePath(Paths.historyJobs()).ensure(curator.getZookeeperClient());
    curator
        .newNamespaceAwareEnsurePath(Paths.configId(zkClusterId))
        .ensure(curator.getZookeeperClient());

    final List<String> argsList =
        Lists.newArrayList(
            "-vvvv",
            "--no-log-setup",
            "--http",
            "http://0.0.0.0:" + (masterPort() + offset),
            "--admin",
            "http://0.0.0.0:" + (masterAdminPort() + offset),
            "--domain",
            "",
            "--zk",
            zk.connectString(),
            "--zk-enable-acls",
            "--zk-acl-agent-user",
            AGENT_USER,
            "--zk-acl-agent-digest",
            AGENT_DIGEST,
            "--zk-acl-master-user",
            MASTER_USER,
            "--zk-acl-master-password",
            MASTER_PASSWORD);

    final String name;
    if (asList(args).contains("--name")) {
      name = args[asList(args).indexOf("--name") + 1];
    } else {
      name = TEST_MASTER + offset;
      argsList.addAll(asList("--name", TEST_MASTER));
    }

    final String stateDir = masterStateDirs.resolve(name).toString();
    argsList.addAll(asList("--state-dir", stateDir));

    argsList.addAll(asList(args));

    return argsList;
  }
  @Test
  public void test() throws Exception {
    final DefaultZooKeeperClient client = new DefaultZooKeeperClient(zk.curatorWithSuperAuth());
    client.ensurePath("/foo/bar");
    final ZooKeeperHealthChecker hc =
        new ZooKeeperHealthChecker(client, "/foo", riemannClient.facade(), MILLISECONDS, 1);
    hc.start();

    // Start in our garden of eden where everything travaileth together in harmony....
    awaitHealthy(hc, 1, MINUTES);

    // Alas!  Behold!  Our zookeeper hath been slain with the sword of the wrath of the random!
    zk.stop();
    awaitState("critical", 1, MINUTES);

    // And lo, our zookeeper hath been resurrected and our foe vanquished!
    zk.start();
    awaitState("ok", 1, MINUTES);
    awaitHealthy(hc, 1, MINUTES);

    // And they lived happily ever after
  }
  @After
  public void baseTeardown() throws Exception {
    for (final HeliosClient client : clients) {
      client.close();
    }
    clients.clear();

    for (Service service : services) {
      try {
        service.stopAsync();
      } catch (Exception e) {
        log.error("Uncaught exception", e);
      }
    }
    for (Service service : services) {
      try {
        service.awaitTerminated();
      } catch (Exception e) {
        log.error("Service failed", e);
      }
    }
    services.clear();

    // Clean up docker
    try (final DockerClient dockerClient = getNewDockerClient()) {
      final List<Container> containers = dockerClient.listContainers();
      for (final Container container : containers) {
        for (final String name : container.names()) {
          if (name.contains(testTag)) {
            try {
              dockerClient.killContainer(container.id());
            } catch (DockerException e) {
              e.printStackTrace();
            }
            break;
          }
        }
      }
    } catch (Exception e) {
      log.error("Docker client exception", e);
    }

    if (zk != null) {
      zk.close();
    }

    listThreads();
  }
  @Before
  public void baseSetup() throws Exception {
    System.setProperty("user.name", TEST_USER);
    masterPort = temporaryPorts.localPort("helios master");
    masterAdminPort = temporaryPorts.localPort("helios master admin");

    masterEndpoint = "http://localhost:" + masterPort();
    masterAdminEndpoint = "http://localhost:" + masterAdminPort();

    zk = zooKeeperTestManager();
    listThreads();
    zk.ensure("/config");
    zk.ensure("/status");
    agentStateDirs = temporaryFolder.newFolder("helios-agents").toPath();
    masterStateDirs = temporaryFolder.newFolder("helios-masters").toPath();

    // TODO (mbrown): not 100% sure what a minimal client is but it sounds good
    httpClient = HttpClients.createMinimal();
  }
 protected AgentMain startDefaultAgent(final String host, final String... args) throws Exception {
   final String stateDir = agentStateDirs.resolve(host).toString();
   final List<String> argsList =
       Lists.newArrayList(
           "-vvvv",
           "--no-log-setup",
           "--no-http",
           "--name",
           host,
           "--docker=" + DOCKER_HOST,
           "--zk",
           zk.connectString(),
           "--zk-session-timeout",
           "100",
           "--zk-connection-timeout",
           "100",
           "--zk-enable-acls",
           "--zk-acl-master-user",
           MASTER_USER,
           "--zk-acl-master-digest",
           MASTER_DIGEST,
           "--zk-acl-agent-user",
           AGENT_USER,
           "--zk-acl-agent-password",
           AGENT_PASSWORD,
           "--state-dir",
           stateDir,
           "--domain",
           "",
           "--port-range="
               + dockerPortRange.lowerEndpoint()
               + ":"
               + dockerPortRange.upperEndpoint());
   argsList.addAll(asList(args));
   return startAgent(argsList.toArray(new String[argsList.size()]));
 }
 @After
 public void tearDown() throws Exception {
   if (zk != null) {
     zk.stop();
   }
 }