Browse Source

TruncateTranslogIT.testCorruptTranslogTruncation should wait for replica to allocate

The test checks if a file based or ops based recovery happened, but if the replica shard never finished recovering expectations are not met.

Fixes #25761
Boaz Leskes 8 years ago
parent
commit
194f267110

+ 3 - 5
core/src/test/java/org/elasticsearch/index/translog/TruncateTranslogIT.java

@@ -56,7 +56,6 @@ import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.test.ESIntegTestCase;
 import org.elasticsearch.test.InternalTestCluster;
 import org.elasticsearch.test.engine.MockEngineSupport;
-import org.elasticsearch.test.junit.annotations.TestLogging;
 import org.elasticsearch.test.transport.MockTransportService;
 
 import java.io.IOException;
@@ -83,7 +82,6 @@ import static org.hamcrest.Matchers.greaterThan;
 import static org.hamcrest.Matchers.notNullValue;
 
 @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 0)
-@TestLogging("_root:DEBUG")
 public class TruncateTranslogIT extends ESIntegTestCase {
 
     @Override
@@ -91,7 +89,6 @@ public class TruncateTranslogIT extends ESIntegTestCase {
         return Arrays.asList(MockTransportService.TestPlugin.class, MockEngineFactoryPlugin.class);
     }
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/25761")
     public void testCorruptTranslogTruncation() throws Exception {
         internalCluster().startNodes(2, Settings.EMPTY);
 
@@ -109,6 +106,7 @@ public class TruncateTranslogIT extends ESIntegTestCase {
         assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder()
             .put("index.routing.allocation.exclude._name", (String)null)
         ));
+        ensureGreen();
 
         // Index some documents
         int numDocsToKeep = randomIntBetween(0, 100);
@@ -246,8 +244,8 @@ public class TruncateTranslogIT extends ESIntegTestCase {
         ensureGreen();
 
         // Index some documents
-        logger.info("--> indexing more doc to be kept");
         int numDocsToKeep = randomIntBetween(0, 100);
+        logger.info("--> indexing [{}] docs to be kept", numDocsToKeep);
         IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocsToKeep];
         for (int i = 0; i < builders.length; i++) {
             builders[i] = client().prepareIndex("test", "type").setSource("foo", "bar");
@@ -257,7 +255,7 @@ public class TruncateTranslogIT extends ESIntegTestCase {
         disableTranslogFlush("test");
         // having no extra docs is an interesting case for seq no based recoveries - test it more often
         int numDocsToTruncate = randomBoolean() ? 0 : randomIntBetween(0, 100);
-        logger.info("--> indexing [{}] more doc to be truncated", numDocsToTruncate);
+        logger.info("--> indexing [{}] more docs to be truncated", numDocsToTruncate);
         builders = new IndexRequestBuilder[numDocsToTruncate];
         for (int i = 0; i < builders.length; i++) {
             builders[i] = client().prepareIndex("test", "type").setSource("foo", "bar");