Skip to content

Commit

Permalink
Only populate snapshot repo once in docs tests (#68013) (#68016)
Browse files Browse the repository at this point in the history
In #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 #67853

Co-authored-by: David Turner <[email protected]>
  • Loading branch information
original-brownbear and DaveCTurner authored Jan 26, 2021
1 parent 486a2cf commit 9739927
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 9739927

Please sign in to comment.