From efaf95628b0ea6d116d5c0327f20f4233cf63698 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Wed, 20 Mar 2019 10:19:34 -0400 Subject: [PATCH] Use separate translog dir in testDeleteWithFatalError This test currently opens a new engine but shares the same translog directory of the previous opening engine. --- .../org/elasticsearch/index/engine/InternalEngineTests.java | 3 ++- .../java/org/elasticsearch/index/engine/EngineTestCase.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 0104958c0c4..1157539719b 100644 --- a/server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/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, diff --git a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java index 2c620a585aa..c97d2892154 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/engine/EngineTestCase.java +++ b/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);