[TEST] Disable translog flush in CorruptedTranslogTests
This commit is contained in:
parent
32201c762b
commit
c328397eb6
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue