From 39018c5d0b2585b49b74dba02a2505f6b924de22 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 19 May 2014 11:20:25 +0200 Subject: [PATCH] [TEST] Added await for yellow status, because the shard the get request for 'test' index, 'type1' type and id 1 is getting executed on may not be in a started state and also added more logging. --- .../gateway/local/LocalGatewayIndexStateTests.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java b/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java index 745917e31ee..8dd825e3e2b 100644 --- a/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java +++ b/src/test/java/org/elasticsearch/gateway/local/LocalGatewayIndexStateTests.java @@ -529,7 +529,14 @@ public class LocalGatewayIndexStateTests extends ElasticsearchIntegrationTest { logger.info("--> index a different doc"); client().prepareIndex("test", "type1", "2").setSource("field1", "value2").setRefresh(true).execute().actionGet(); - assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); + logger.info("--> verify that doc 2 does exist"); assertThat(client().prepareGet("test", "type1", "2").execute().actionGet().isExists(), equalTo(true)); + + // Need an ensure yellow here, since the index gets created (again) when we index doc2, so the shard that doc + // with id 1 is assigned to might not be in a started state. We don't need to do this when verifying if doc 2 + // exists, because we index into the shard that doc gets assigned to. + ensureYellow("test"); + logger.info("--> verify that doc 1 doesn't exist"); + assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); } }