Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchableSnapshotsIntegTests should wait for shard index folder to be cleaned up #80341

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.common.util.concurrent.AtomicArray;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.Index;
Expand Down Expand Up @@ -65,6 +66,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;

@ESIntegTestCase.ClusterScope(supportsDedicatedMasters = false, numClientNodes = 0)
public abstract class BaseSearchableSnapshotsIntegTestCase extends AbstractSnapshotIntegTestCase {
Expand All @@ -75,7 +77,7 @@ protected boolean addMockInternalEngine() {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return List.of(LocalStateSearchableSnapshots.class);
return CollectionUtils.appendToCopy(super.nodePlugins(), LocalStateSearchableSnapshots.class);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is independant but looks wrong so I fixed it.

}

@Override
Expand Down Expand Up @@ -234,9 +236,17 @@ protected void assertShardFolders(String indexName, boolean snapshotDirectory) t
final ShardPath shardPath = ShardPath.loadShardPath(logger, service, shardId, customDataPath);
if (shardPath != null && Files.exists(shardPath.getDataPath())) {
shardFolderFound = true;
assertEquals(snapshotDirectory, Files.notExists(shardPath.resolveIndex()));

assertTrue(Files.exists(shardPath.resolveTranslog()));
final boolean indexExists = Files.exists(shardPath.resolveIndex());
final boolean translogExists = Files.exists(shardPath.resolveTranslog());
logger.info(
"--> [{}] verifying shard data path [{}] (index exists: {}, translog exists: {})",
node,
shardPath.getDataPath(),
indexExists,
translogExists
);
assertThat(snapshotDirectory, not(indexExists));
assertTrue(translogExists);
try (Stream<Path> dir = Files.list(shardPath.resolveTranslog())) {
final long translogFiles = dir.filter(path -> path.getFileName().toString().contains("translog")).count();
if (snapshotDirectory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception {
// TODO: fix
// assertSearchableSnapshotStats(restoredIndexName, true, nonCachedExtensions);
ensureGreen(restoredIndexName);
assertShardFolders(restoredIndexName, true);
assertBusy(() -> assertShardFolders(restoredIndexName, true));

assertThat(
client().admin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception {
assertSearchableSnapshotStats(restoredIndexName, cacheEnabled, nonCachedExtensions);

ensureGreen(restoredIndexName);
assertShardFolders(restoredIndexName, true);
assertBusy(() -> assertShardFolders(restoredIndexName, true));

assertThat(
client().admin()
Expand Down