From 7f06e8efe56503347c02db2f044895bc50ea9a47 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Fri, 1 Sep 2023 11:18:50 +0530 Subject: [PATCH] Make all tests run in TEST scope Signed-off-by: Sachin Kale --- .../org/opensearch/test/OpenSearchIntegTestCase.java | 6 +++--- .../src/main/java/org/opensearch/test/TestCluster.java | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index 9fbf92aad0e45..f4eeb104e1e2d 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -406,7 +406,7 @@ protected final void beforeInternal() throws Exception { final Scope currentClusterScope = getCurrentClusterScope(); Callable setup = () -> { cluster().beforeTest(random()); - cluster().wipe(excludeTemplates(), List.of(REPOSITORY_NAME, REPOSITORY_2_NAME)); + cluster().wipe(excludeTemplates()); randomIndexTemplate(); return null; }; @@ -620,7 +620,7 @@ private void afterInternal(boolean afterClass) throws Exception { ensureClusterStateConsistency(); ensureClusterStateCanBeReadByNodeTool(); beforeIndexDeletion(); - cluster().wipe(excludeTemplates(), List.of(REPOSITORY_NAME, REPOSITORY_2_NAME)); // wipe after to make sure we fail in the test that didn't ack the delete + cluster().wipe(excludeTemplates()); // wipe after to make sure we fail in the test that didn't ack the delete if (afterClass || currentClusterScope == Scope.TEST) { cluster().close(); } @@ -1893,7 +1893,7 @@ private static A getAnnotation(Class clazz, Class a } private Scope getCurrentClusterScope() { - return getCurrentClusterScope(this.getClass()); + return Scope.TEST;//getCurrentClusterScope(this.getClass()); } private static Scope getCurrentClusterScope(Class clazz) { diff --git a/test/framework/src/main/java/org/opensearch/test/TestCluster.java b/test/framework/src/main/java/org/opensearch/test/TestCluster.java index fd17e625ab2f3..a0dd54e070064 100644 --- a/test/framework/src/main/java/org/opensearch/test/TestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/TestCluster.java @@ -88,13 +88,13 @@ public void beforeTest(Random random) throws IOException, InterruptedException { /** * Wipes any data that a test can leave behind: indices, templates (except exclude templates) and repositories */ - public void wipe(Set excludeTemplates, List excludeRepositories) { + public void wipe(Set excludeTemplates) { wipeAllDataStreams(); wipeIndices("_all"); wipeAllTemplates(excludeTemplates); GetRepositoriesResponse response = client().admin().cluster().prepareGetRepositories("*").execute().actionGet(); List allRepositories = response.repositories().stream().map(RepositoryMetadata::name).collect(Collectors.toList()); - wipeRepositories(allRepositories, excludeRepositories); + wipeRepositories(allRepositories); } /** @@ -250,12 +250,9 @@ public void wipeTemplates(String... templates) { /** * Deletes repositories, supports wildcard notation. */ - public void wipeRepositories(List allRepositories, List excludeRepositories) { + public void wipeRepositories(List allRepositories) { if (size() > 0) { for (String repository : allRepositories) { - if(excludeRepositories.contains(repository)) { - continue; - } try { client().admin().cluster().prepareDeleteRepository(repository).execute().actionGet(); } catch (RepositoryMissingException ex) {