public void testZkMasterReconnectDuringDeployment() throws Exception {
deployTestIndices(1, getNodeCount());
_miniCluster.getMaster().shutdown();
ZkClient zkClient = new ZkClient(_miniCluster.getZkConfiguration().getZKServers());
InteractionProtocol protocol = new InteractionProtocol(zkClient, _miniCluster.getZkConfiguration());
Master master = new Master(protocol, false);
master.start();
TestUtil.waitUntilBecomeMaster(master);
final IDeployClient deployClient = new DeployClient(_protocol);
WatchedEvent event = new WatchedEvent(new WatcherEvent(EventType.None.getIntValue(), KeeperState.Expired
.getIntValue(), null));
for (int i = 0; i < 25; i++) {
final String indexName = "index" + i;
IIndexDeployFuture deployFuture = deployClient.addIndex(indexName, INDEX_FILE.getAbsolutePath(), 1);
zkClient.getEventLock().lock();
zkClient.process(event);
zkClient.getEventLock().unlock();
IndexState indexState = deployFuture.joinDeployment();
assertEquals("" + deployClient.getIndexMetaData(indexName).getDeployError(), IndexState.DEPLOYED, indexState);
if (indexState == IndexState.ERROR) {
IndexDeployError deployError = protocol.getIndexMD(indexName).getDeployError();
Set<Shard> shards = protocol.getIndexMD(indexName).getShards();
for (Shard shard : shards) {
List<Exception> shardErrors = deployError.getShardErrors(shard.getName());
for (Exception exception : shardErrors) {
exception.printStackTrace();
}