UpgradeMain upgrade = new UpgradeMain(upgradeDir, upgradeDir);
upgrade.runUpgrade();
ZooKeeperServer zks = new ZooKeeperServer(upgradeDir, upgradeDir, 3000);
SyncRequestProcessor.setSnapCount(1000);
final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
f.startup(zks);
LOG.info("starting up the zookeeper server .. waiting");
Assert.assertTrue("waiting for server being up",
ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
Stat stat = zk.exists("/", false);
List<String> children = zk.getChildren("/", false);
Collections.sort(children);
for (int i = 0; i < 10; i++) {
Assert.assertTrue("data tree sanity check",
("test-" + i).equals(children.get(i)));
}
//try creating one node
zk.create("/upgrade", "upgrade".getBytes(), Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
// check if its there
if (zk.exists("/upgrade", false) == null) {
Assert.assertTrue(false);
}
zk.close();
// bring down the server
f.shutdown();
Assert.assertTrue("waiting for server down",
ClientBase.waitForServerDown(HOSTPORT,
ClientBase.CONNECTION_TIMEOUT));
}