Skip to content

Commit

Permalink
Make all tests run in TEST scope
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Sep 1, 2023
1 parent 55bd2ac commit 7f06e8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ protected final void beforeInternal() throws Exception {
final Scope currentClusterScope = getCurrentClusterScope();
Callable<Void> setup = () -> {
cluster().beforeTest(random());
cluster().wipe(excludeTemplates(), List.of(REPOSITORY_NAME, REPOSITORY_2_NAME));
cluster().wipe(excludeTemplates());
randomIndexTemplate();
return null;
};
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -1893,7 +1893,7 @@ private static <A extends Annotation> A getAnnotation(Class<?> clazz, Class<A> a
}

private Scope getCurrentClusterScope() {
return getCurrentClusterScope(this.getClass());
return Scope.TEST;//getCurrentClusterScope(this.getClass());
}

private static Scope getCurrentClusterScope(Class<?> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> excludeTemplates, List<String> excludeRepositories) {
public void wipe(Set<String> excludeTemplates) {
wipeAllDataStreams();
wipeIndices("_all");
wipeAllTemplates(excludeTemplates);
GetRepositoriesResponse response = client().admin().cluster().prepareGetRepositories("*").execute().actionGet();
List<String> allRepositories = response.repositories().stream().map(RepositoryMetadata::name).collect(Collectors.toList());
wipeRepositories(allRepositories, excludeRepositories);
wipeRepositories(allRepositories);
}

/**
Expand Down Expand Up @@ -250,12 +250,9 @@ public void wipeTemplates(String... templates) {
/**
* Deletes repositories, supports wildcard notation.
*/
public void wipeRepositories(List<String> allRepositories, List<String> excludeRepositories) {
public void wipeRepositories(List<String> allRepositories) {
if (size() > 0) {
for (String repository : allRepositories) {
if(excludeRepositories.contains(repository)) {
continue;
}
try {
client().admin().cluster().prepareDeleteRepository(repository).execute().actionGet();
} catch (RepositoryMissingException ex) {
Expand Down

0 comments on commit 7f06e8e

Please sign in to comment.