Use separate translog dir in testDeleteWithFatalError

This test currently opens a new engine but shares the same translog
directory of the previous opening engine.
This commit is contained in:
Nhat Nguyen 2019-03-20 10:19:34 -04:00
parent 49a7c6e0e8
commit efaf95628b
2 changed files with 6 additions and 3 deletions

View File

@ -3315,7 +3315,8 @@ public class InternalEngineTests extends EngineTestCase {
return tombstoneDocSupplier().newNoopTombstoneDoc(reason); 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); final ParsedDocument doc = testParsedDocument("1", null, testDocumentWithTextField(), SOURCE, null);
engine.index(indexForDoc(doc)); engine.index(indexForDoc(doc));
expectThrows(IllegalStateException.class, expectThrows(IllegalStateException.class,

View File

@ -697,14 +697,16 @@ public abstract class EngineTestCase extends ESTestCase {
tombstoneDocSupplier()); 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", IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test",
Settings.builder().put(config.getIndexSettings().getSettings()) Settings.builder().put(config.getIndexSettings().getSettings())
.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build()); .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(), return new EngineConfig(config.getShardId(), config.getAllocationId(), config.getThreadPool(),
indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(), indexSettings, config.getWarmer(), store, config.getMergePolicy(), config.getAnalyzer(), config.getSimilarity(),
new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), 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.getInternalRefreshListener(), config.getIndexSort(), config.getCircuitBreakerService(),
config.getGlobalCheckpointSupplier(), config.retentionLeasesSupplier(), config.getGlobalCheckpointSupplier(), config.retentionLeasesSupplier(),
config.getPrimaryTermSupplier(), tombstoneDocSupplier); config.getPrimaryTermSupplier(), tombstoneDocSupplier);