From 9e271001bc26b9b449c1c8e17e79f01d9bdc678f Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Thu, 7 Oct 2021 12:07:22 +0200 Subject: [PATCH] Fix SearchableSnapshotsBlobStoreCacheIntegTests.testBlobStoreCache (#78616) This test often fails on CI because it does not wait for the data node that hosts the .snapshot-blob-cache primary shard to process the cluster state update and triggers the clean up. Closes #78512 --- .../blob/SearchableSnapshotsBlobStoreCacheIntegTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheIntegTests.java index 8ff3b79164ded..3b07fb37eb8c4 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheIntegTests.java @@ -58,6 +58,7 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.concurrent.TimeUnit; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; @@ -327,8 +328,9 @@ public Settings onNodeStopped(String nodeName) throws Exception { logger.info("--> verifying number of documents in index [{}]", restoredAgainIndex); assertHitCount(client().prepareSearch(restoredAgainIndex).setSize(0).setTrackTotalHits(true).get(), numberOfDocs); - logger.info("--> deleting indices, maintenance service should clean up snapshot blob cache index"); + logger.info("--> deleting indices, maintenance service should clean up [{}] docs in system index", numberOfCachedBlobs); assertAcked(client().admin().indices().prepareDelete("restored-*")); + assertBusy(() -> { refreshSystemIndex(); assertHitCount( @@ -338,7 +340,7 @@ public Settings onNodeStopped(String nodeName) throws Exception { .get(), 0L ); - }); + }, 30L, TimeUnit.SECONDS); } private void checkNoBlobStoreAccess() {