|
19 | 19 | import org.opensearch.action.index.IndexRequest;
|
20 | 20 | import org.opensearch.action.index.IndexRequestBuilder;
|
21 | 21 | import org.opensearch.action.index.IndexResponse;
|
| 22 | +import org.opensearch.action.support.IndicesOptions; |
22 | 23 | import org.opensearch.action.support.PlainActionFuture;
|
23 | 24 | import org.opensearch.action.support.WriteRequest;
|
24 | 25 | import org.opensearch.cluster.metadata.IndexMetadata;
|
|
57 | 58 | import java.util.Locale;
|
58 | 59 | import java.util.Map;
|
59 | 60 | import java.util.concurrent.ExecutionException;
|
| 61 | +import java.util.concurrent.TimeUnit; |
60 | 62 | import java.util.concurrent.atomic.AtomicInteger;
|
61 | 63 | import java.util.stream.Collectors;
|
62 | 64 | import java.util.stream.Stream;
|
@@ -257,14 +259,25 @@ protected Settings remoteStoreIndexSettings(int numberOfReplicas, long totalFiel
|
257 | 259 | }
|
258 | 260 |
|
259 | 261 | @After
|
260 |
| - public void teardown() { |
| 262 | + public void teardown() throws Exception { |
261 | 263 | clusterSettingsSuppliedByTest = false;
|
262 | 264 | asyncUploadMockFsRepo = randomBoolean();
|
263 | 265 | metadataSupportedType = randomBoolean();
|
264 | 266 | assertRemoteStoreRepositoryOnAllNodes(REPOSITORY_NAME);
|
265 | 267 | assertRemoteStoreRepositoryOnAllNodes(REPOSITORY_2_NAME);
|
266 | 268 | clusterAdmin().prepareCleanupRepository(REPOSITORY_NAME).get();
|
267 | 269 | clusterAdmin().prepareCleanupRepository(REPOSITORY_2_NAME).get();
|
| 270 | + // Delete is async. |
| 271 | + assertAcked( |
| 272 | + client().admin().indices().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get() |
| 273 | + ); |
| 274 | + assertBusy(() -> { |
| 275 | + try { |
| 276 | + assertEquals(0, getFileCount(translogRepoPath)); |
| 277 | + } catch (IOException e) { |
| 278 | + fail(); |
| 279 | + } |
| 280 | + }, 30, TimeUnit.SECONDS); |
268 | 281 | }
|
269 | 282 |
|
270 | 283 | public RepositoryMetadata buildRepositoryMetadata(DiscoveryNode node, String name) {
|
@@ -313,7 +326,7 @@ public void assertRemoteStoreRepositoryOnAllNodes(String repositoryName) {
|
313 | 326 | }
|
314 | 327 | }
|
315 | 328 |
|
316 |
| - public static int getFileCount(Path path) throws Exception { |
| 329 | + public static int getFileCount(Path path) throws IOException { |
317 | 330 | final AtomicInteger filesExisting = new AtomicInteger(0);
|
318 | 331 | Files.walkFileTree(path, new SimpleFileVisitor<>() {
|
319 | 332 | @Override
|
|
0 commit comments