瀏覽代碼

Use separate translog dir in testDeleteWithFatalError

This test currently opens a new engine but shares the same translog
directory of the previous opening engine.
Nhat Nguyen 6 年之前
父節點
當前提交
790fdb156c

+ 2 - 1
server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

@@ -3315,7 +3315,8 @@ public class InternalEngineTests extends EngineTestCase {
                     return tombstoneDocSupplier().newNoopTombstoneDoc(reason);
                 }
             };
-            try (InternalEngine engine = createEngine(null, null, null, config(this.engine.config(), store, tombstoneDocSupplier))) {
+            EngineConfig config = config(this.engine.config(), store, createTempDir(), tombstoneDocSupplier);
+            try (InternalEngine engine = createEngine(null, null, null, config)) {
                 final ParsedDocument doc = testParsedDocument("1", null, testDocumentWithTextField(), SOURCE, null);
                 engine.index(indexForDoc(doc));
                 expectThrows(IllegalStateException.class,

+ 4 - 2
test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java

@@ -697,14 +697,16 @@ public abstract class EngineTestCase extends ESTestCase {
                 tombstoneDocSupplier());
     }
 
-    protected EngineConfig config(EngineConfig config, Store store, EngineConfig.TombstoneDocSupplier tombstoneDocSupplier) {
+    protected EngineConfig config(EngineConfig config, Store store, Path translogPath,
+                                  EngineConfig.TombstoneDocSupplier tombstoneDocSupplier) {
         IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test",
             Settings.builder().put(config.getIndexSettings().getSettings())
                 .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build());
+        TranslogConfig translogConfig = new TranslogConfig(shardId, translogPath, indexSettings, BigArrays.NON_RECYCLING_INSTANCE);
         return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(),
             indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
             new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(),
-            config.getTranslogConfig(), config.getFlushMergesAfter(), config.getExternalRefreshListener(),
+            translogConfig, config.getFlushMergesAfter(), config.getExternalRefreshListener(),
             config.getInternalRefreshListener(), config.getIndexSort(), config.getCircuitBreakerService(),
             config.getGlobalCheckpointSupplier(), config.retentionLeasesSupplier(),
             config.getPrimaryTermSupplier(), tombstoneDocSupplier);