Improve testReusePeerRecovery test
This commit is contained in:
parent
29f4274213
commit
8df7f2af0d
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;
|
||||||
import org.elasticsearch.action.admin.indices.status.ShardStatus;
|
import org.elasticsearch.action.admin.indices.status.ShardStatus;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.gateway.Gateway;
|
import org.elasticsearch.gateway.Gateway;
|
||||||
import org.elasticsearch.index.query.FilterBuilders;
|
import org.elasticsearch.index.query.FilterBuilders;
|
||||||
|
@ -359,7 +360,7 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests {
|
||||||
|
|
||||||
logger.info("--> shutting down the nodes");
|
logger.info("--> shutting down the nodes");
|
||||||
client("node1").admin().cluster().prepareNodesShutdown().setDelay("10ms").setExit(false).execute().actionGet();
|
client("node1").admin().cluster().prepareNodesShutdown().setDelay("10ms").setExit(false).execute().actionGet();
|
||||||
Thread.sleep(2000);
|
assertThat(waitForNodesToShutdown(TimeValue.timeValueSeconds(30), 4), equalTo(true));
|
||||||
logger.info("--> start the nodes back up");
|
logger.info("--> start the nodes back up");
|
||||||
startNode("node1", settings);
|
startNode("node1", settings);
|
||||||
startNode("node2", settings);
|
startNode("node2", settings);
|
||||||
|
@ -374,7 +375,7 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests {
|
||||||
|
|
||||||
logger.info("--> shutting down the nodes");
|
logger.info("--> shutting down the nodes");
|
||||||
client("node1").admin().cluster().prepareNodesShutdown().setDelay("10ms").setExit(false).execute().actionGet();
|
client("node1").admin().cluster().prepareNodesShutdown().setDelay("10ms").setExit(false).execute().actionGet();
|
||||||
Thread.sleep(2000);
|
assertThat(waitForNodesToShutdown(TimeValue.timeValueSeconds(30), 4), equalTo(true));
|
||||||
|
|
||||||
logger.info("--> start the nodes back up");
|
logger.info("--> start the nodes back up");
|
||||||
startNode("node1", settings);
|
startNode("node1", settings);
|
||||||
|
@ -428,4 +429,17 @@ public class SimpleRecoveryLocalGatewayTests extends AbstractNodesTests {
|
||||||
assertThat(client("node2").admin().indices().prepareExists("test").execute().actionGet().exists(), equalTo(true));
|
assertThat(client("node2").admin().indices().prepareExists("test").execute().actionGet().exists(), equalTo(true));
|
||||||
assertThat(client("node2").prepareCount("test").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(1l));
|
assertThat(client("node2").prepareCount("test").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().count(), equalTo(1l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean waitForNodesToShutdown(TimeValue timeout, int numberOfNodes) throws InterruptedException {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
WAIT_FOR_CLOSING:
|
||||||
|
while ((System.currentTimeMillis() - start) < timeout.millis()) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
for (int i = 1; i < numberOfNodes + 1; i++) {
|
||||||
|
if (!node("node" + i).isClosed()) continue WAIT_FOR_CLOSING;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue