@Test(timeout = 60000)
public void testNoLocalDynamicConfigAndBackupFiles()
throws InterruptedException, IOException {
int serverCount = 3;
String config = generateNewQuorumConfig(serverCount);
QuorumPeerTestBase.MainThread mt[] = new QuorumPeerTestBase.MainThread[serverCount];
String[] staticFileContent = new String[serverCount];
for (int i = 0; i < serverCount; i++) {
mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts.get(i),
config, false);
mt[i].start();
}
for (int i = 0; i < serverCount; i++) {
Assert.assertTrue("waiting for server " + i + " being up",
ClientBase.waitForServerUp("127.0.0.1:" + clientPorts.get(i),
CONNECTION_TIMEOUT));
Assert.assertNull("static file backup (zoo.cfg.bak) shouldn't exist!",
mt[i].getFileByName(ZOO_CFG_BAK_FILE));
Assert.assertNull("dynamic configuration file (zoo.cfg.dynamic.*) shouldn't exist!",
mt[i].getFileByName(mt[i].getQuorumPeer().getNextDynamicConfigFilename()));
staticFileContent[i] = Files.readAllLines(mt[i].confFile.toPath(), StandardCharsets.UTF_8).toString();
Assert.assertTrue("static config file should contain server entry " + serverAddress.get(i),
staticFileContent[i].contains(serverAddress.get(i)));
}
for (int i = 0; i < serverCount; i++) {
mt[i].shutdown();
}
}