Skip to content

Commit

Permalink
Only populate snapshot repo once in docs tests (elastic#68013)
Browse files Browse the repository at this point in the history
In elastic#67829 we introduced a `@Before` method to set up the repository for
the docs tests. In fact this only needs to run once for the whole suite,
not once per test.

Relates elastic#67853
  • Loading branch information
DaveCTurner authored Jan 26, 2021
1 parent 29d1d25 commit 80107e8
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,15 @@ public void waitForRequirements() throws Exception {
}
}

private static boolean snapshotRepositoryPopulated;

@Before
public void populateSnapshotRepository() throws IOException {

if (snapshotRepositoryPopulated) {
return;
}

// The repository UUID is only created on the first write to the repo, so it may or may not exist when running the tests. However to
// include the output from the put-repository and get-repositories APIs in the docs we must be sure whether the UUID is returned or
// not, so we prepare by taking a snapshot first to ensure that the UUID really has been created.
Expand All @@ -128,6 +135,8 @@ public void populateSnapshotRepository() throws IOException {

final Request deleteRepoRequest = new Request("DELETE", "/_snapshot/test_setup_repo");
assertOK(adminClient().performRequest(deleteRepoRequest));

snapshotRepositoryPopulated = true;
}

@After
Expand Down

0 comments on commit 80107e8

Please sign in to comment.