From 80107e8bd87e331be063d86c2fe448bfbc54c831 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 26 Jan 2021 18:10:54 +0000 Subject: [PATCH] Only populate snapshot repo once in docs tests (#68013) 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 --- .../smoketest/DocsClientYamlTestSuiteIT.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java index 3db07b96610d4..bf0b56094c9aa 100644 --- a/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java +++ b/docs/src/test/java/org/elasticsearch/smoketest/DocsClientYamlTestSuiteIT.java @@ -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. @@ -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