TEST: Use different translog dir for a new engine

In #testPruneOnlyDeletesAtMostLocalCheckpoint, we create a new engine
but mistakenly use the same translog directory of  the existing engine.
This prevents translog files from cleaning up when closing the engines.

ERROR   0.12s J2 | InternalEngineTests.testPruneOnlyDeletesAtMostLocalCheckpoint <<< FAILURES!
   > Throwable #1: java.io.IOException: could not remove the following files (in the order of attempts):
   >    translog-primary-060/translog-2.tlog:  java.io.IOException: access denied:

This commit makes sure to use a separate directory for each engine in
this tes.
This commit is contained in:
Nhat Nguyen 2018-03-27 09:45:51 -04:00
parent 8d6832c5ee
commit d1d3edf156
1 changed files with 1 additions and 8 deletions

View File

@ -4474,21 +4474,14 @@ public class InternalEngineTests extends EngineTestCase {
final AtomicLong clock = new AtomicLong(0);
threadPool = spy(threadPool);
when(threadPool.relativeTimeInMillis()).thenAnswer(invocation -> clock.get());
final EngineConfig config = engine.config();
final long gcInterval = randomIntBetween(0, 10);
final IndexSettings indexSettings = engine.config().getIndexSettings();
final IndexMetaData indexMetaData = IndexMetaData.builder(indexSettings.getIndexMetaData())
.settings(Settings.builder().put(indexSettings.getSettings())
.put(IndexSettings.INDEX_GC_DELETES_SETTING.getKey(), TimeValue.timeValueMillis(gcInterval).getStringRep())).build();
indexSettings.updateIndexMetaData(indexMetaData);
try (Store store = createStore();
InternalEngine engine = createEngine(new EngineConfig(config.getShardId(), config.getAllocationId(), threadPool,
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(), Collections.emptyList(),
config.getIndexSort(), config.getTranslogRecoveryRunner(), config.getCircuitBreakerService(),
config.getGlobalCheckpointSupplier()))) {
InternalEngine engine = createEngine(store, createTempDir())) {
engine.config().setEnableGcDeletes(false);
for (int i = 0, docs = scaledRandomIntBetween(0, 10); i < docs; i++) {
index(engine, i);