Bläddra i källkod

Remember project creation status across tests

We want to create and delete projects only once around the entire YAML
test suite. Therefore the project creation status needs to be remembered
across tests. This commit changes the field to be static. It also moves
initialization of projectIds to be static.
Yang Wang 8 månader sedan
förälder
incheckning
cf4a0ae117

+ 11 - 4
x-pack/qa/multi-project/yaml-test-framework/src/main/java/org/elasticsearch/multiproject/test/MultipleProjectsClientYamlSuiteTestCase.java

@@ -22,6 +22,7 @@ import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
 import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.BeforeClass;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -49,15 +50,21 @@ public abstract class MultipleProjectsClientYamlSuiteTestCase extends ESClientYa
      */
     protected static final String PASS = Objects.requireNonNull(System.getProperty("tests.rest.cluster.password", "test-password"));
 
-    // The active project-id is slightly longer, and has a fixed suffix so that it's easier to pick in error messages etc.
-    private final String activeProject = randomAlphaOfLength(8).toLowerCase(Locale.ROOT) + "00active";
-    private final Set<String> extraProjects = randomSet(1, 3, () -> randomAlphaOfLength(12).toLowerCase(Locale.ROOT));
-    private boolean projectsConfigured = false;
+    private static String activeProject;
+    private static Set<String> extraProjects;
+    private static boolean projectsConfigured = false;
 
     public MultipleProjectsClientYamlSuiteTestCase(ClientYamlTestCandidate testCandidate) {
         super(testCandidate);
     }
 
+    @BeforeClass
+    public static void initializeProjectIds() {
+        // The active project-id is slightly longer, and has a fixed suffix so that it's easier to pick in error messages etc.
+        activeProject = randomAlphaOfLength(8).toLowerCase(Locale.ROOT) + "00active";
+        extraProjects = randomSet(1, 3, () -> randomAlphaOfLength(12).toLowerCase(Locale.ROOT));
+    }
+
     @Override
     protected RestClient getCleanupClient() {
         return client();