diff --git a/plugins/repository-azure/src/internalClusterTest/java/org/opensearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java b/plugins/repository-azure/src/internalClusterTest/java/org/opensearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java index 6ba1177ee93a9..837aeb6c3ec32 100644 --- a/plugins/repository-azure/src/internalClusterTest/java/org/opensearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java +++ b/plugins/repository-azure/src/internalClusterTest/java/org/opensearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java @@ -49,13 +49,16 @@ import org.opensearch.secure_sm.AccessController; import org.opensearch.test.OpenSearchIntegTestCase; import org.junit.AfterClass; +import org.junit.Before; import java.net.HttpURLConnection; import java.util.Collection; +import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import reactor.core.scheduler.Schedulers; +import static org.opensearch.test.OpenSearchTestCase.assertBusy; import static org.hamcrest.Matchers.blankOrNullString; import static org.hamcrest.Matchers.not; @@ -65,6 +68,26 @@ public static void shutdownSchedulers() { Schedulers.shutdownNow(); } + @Before + public void waitForAzureFixtureReady() throws Exception { + ensureGreen(); + + assertBusy(() -> { + assertThat(System.getProperty("test.azure.container"), not(blankOrNullString())); + assertThat(System.getProperty("test.azure.base"), not(blankOrNullString())); + }, 60, TimeUnit.SECONDS); + } + + @Override + public void tearDown() throws Exception { + try { + client().admin().indices().prepareDelete("*").get(); + client().admin().cluster().prepareDeleteRepository("_all").get(); + } finally { + super.tearDown(); + } + } + @Override protected Collection> getPlugins() { return pluginList(AzureRepositoryPlugin.class); @@ -101,6 +124,12 @@ protected SecureSettings credentials() { return secureSettings; } + private T eventually(Supplier supplier) throws Exception { + final AtomicReference result = new AtomicReference<>(); + assertBusy(() -> result.set(supplier.get()), 30, TimeUnit.SECONDS); + return result.get(); + } + @Override protected void createRepository(String repoName) { Settings.Builder settings = Settings.builder()