spin a bit to wait for condition in test, so slow machines will still run it correctly
This commit is contained in:
parent
fe8b3725bb
commit
361d6bf89a
|
@ -30,6 +30,7 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
|
||||||
import org.elasticsearch.common.logging.ESLogger;
|
import org.elasticsearch.common.logging.ESLogger;
|
||||||
import org.elasticsearch.common.logging.Loggers;
|
import org.elasticsearch.common.logging.Loggers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.env.NodeEnvironment;
|
import org.elasticsearch.env.NodeEnvironment;
|
||||||
import org.elasticsearch.gateway.Gateway;
|
import org.elasticsearch.gateway.Gateway;
|
||||||
|
@ -369,8 +370,13 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests {
|
||||||
health = client("node1").admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
health = client("node1").admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
||||||
assertThat(health.isTimedOut(), equalTo(false));
|
assertThat(health.isTimedOut(), equalTo(false));
|
||||||
|
|
||||||
// we need to wait for the allocate dangled to kick in
|
// spin a bit waiting for the index to exists
|
||||||
Thread.sleep(500);
|
long time = System.currentTimeMillis();
|
||||||
|
while ((System.currentTimeMillis() - time) < TimeValue.timeValueSeconds(10).millis()) {
|
||||||
|
if (client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("--> verify that the dangling index exists");
|
logger.info("--> verify that the dangling index exists");
|
||||||
assertThat(client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists(), equalTo(true));
|
assertThat(client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists(), equalTo(true));
|
||||||
|
@ -426,8 +432,13 @@ public class LocalGatewayIndexStateTests extends AbstractNodesTests {
|
||||||
health = client("node1").admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
health = client("node1").admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").execute().actionGet();
|
||||||
assertThat(health.isTimedOut(), equalTo(false));
|
assertThat(health.isTimedOut(), equalTo(false));
|
||||||
|
|
||||||
// we need to wait for the allocate dangled to kick in
|
// spin a bit waiting for the index to exists
|
||||||
Thread.sleep(500);
|
long time = System.currentTimeMillis();
|
||||||
|
while ((System.currentTimeMillis() - time) < TimeValue.timeValueSeconds(10).millis()) {
|
||||||
|
if (client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("--> verify that the dangling index exists");
|
logger.info("--> verify that the dangling index exists");
|
||||||
assertThat(client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists(), equalTo(true));
|
assertThat(client("node1").admin().indices().prepareExists("test").execute().actionGet().isExists(), equalTo(true));
|
||||||
|
|
Loading…
Reference in New Issue