[TEST] Disable translog flush in CorruptedTranslogTests

This commit is contained in:
Lee Hinman 2014-09-09 17:47:57 +02:00
parent 32201c762b
commit c328397eb6
2 changed files with 14 additions and 0 deletions

View File

@ -80,6 +80,7 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest {
for (int i = 0; i < builders.length; i++) {
builders[i] = client().prepareIndex("test", "type").setSource("foo", "bar");
}
disableTranslogFlush("test");
indexRandom(false, false, builders);
// Corrupt the translog file(s)
@ -89,6 +90,7 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest {
internalCluster().fullRestart();
// node needs time to start recovery and discover the translog corruption
sleep(1000);
enableTranslogFlush("test");
try {
client().prepareSearch("test").setQuery(matchAllQuery()).get();

View File

@ -1316,6 +1316,18 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
}
/** Disables translog flushing for the specified index */
public static void disableTranslogFlush(String index) {
Settings settings = ImmutableSettings.builder().put(TranslogService.INDEX_TRANSLOG_DISABLE_FLUSH, true).build();
client().admin().indices().prepareUpdateSettings(index).setSettings(settings).get();
}
/** Enables translog flushing for the specified index */
public static void enableTranslogFlush(String index) {
Settings settings = ImmutableSettings.builder().put(TranslogService.INDEX_TRANSLOG_DISABLE_FLUSH, false).build();
client().admin().indices().prepareUpdateSettings(index).setSettings(settings).get();
}
private static CountDownLatch newLatch(List<CountDownLatch> latches) {
CountDownLatch l = new CountDownLatch(1);
latches.add(l);