@Test(timeout = 50000)
public void testMasterChangeWhileDeploingIndex() throws Exception {
Master master = new Master(_zk.getInteractionProtocol(), false);
Node node = Mocks.mockNode();// leave safe mode
NodeQueue nodeQueue = _protocol.publishNode(node, new NodeMetaData("node1"));
master.start();
TestUtil.waitUntilLeaveSafeMode(master);
// phase I - until watchdog is running and its node turn
IndexDeployOperation deployOperation = new IndexDeployOperation("index1", TestResources.INDEX1.getAbsolutePath(), 1);
_protocol.addMasterOperation(deployOperation);
while (!master.getContext().getMasterQueue().isEmpty()) {
// wait until deploy is in watch phase
Thread.sleep(100);
}
// phase II - master change while node is deploying
master.shutdown();
Master secMaster = new Master(_zk.getInteractionProtocol(), false);
secMaster.start();
// phase III - finish node operations/ mater operation should be finished
while (!nodeQueue.isEmpty()) {
nodeQueue.remove();
}
TestUtil.waitUntilIndexDeployed(_protocol, deployOperation.getIndexName());
assertNotNull(_protocol.getIndexMD(deployOperation.getIndexName()));
secMaster.shutdown();