@@ -1622,7 +1622,7 @@ protected Settings restAdminSettings() {
16221622 * Returns the REST client used for cleaning up the cluster.
16231623 */
16241624 protected Settings cleanupClientSettings () {
1625- if (multiProjectEnabled == false ) {
1625+ if (multiProjectEnabled == false || shouldConfigureProjects () == false ) {
16261626 return restAdminSettings ();
16271627 }
16281628 return addProjectIdToSettings (restAdminSettings ());
@@ -2726,8 +2726,17 @@ protected static void assertResultMap(
27262726 assertMap (result , mapMatcher .entry ("columns" , columnMatcher ).entry ("values" , valuesMatcher ));
27272727 }
27282728
2729+ /**
2730+ * Whether the test framework should configure an active projects and some extra projects. This is true by default (when multi-project
2731+ * is enabled). Subclasses can override this method to avoid configuring projects - e.g. when they configure projects themselves.
2732+ */
2733+ protected boolean shouldConfigureProjects () {
2734+ assert multiProjectEnabled ;
2735+ return true ;
2736+ }
2737+
27292738 private void configureProjects () throws IOException {
2730- if (projectsConfigured || multiProjectEnabled == false ) {
2739+ if (projectsConfigured || multiProjectEnabled == false || shouldConfigureProjects () == false ) {
27312740 return ;
27322741 }
27332742 projectsConfigured = true ;
@@ -2747,7 +2756,7 @@ private void configureProjects() throws IOException {
27472756
27482757 @ After
27492758 public final void assertEmptyProjects () throws Exception {
2750- if (multiProjectEnabled == false ) {
2759+ if (projectsConfigured == false ) {
27512760 return ;
27522761 }
27532762 assertEmptyProject (Metadata .DEFAULT_PROJECT_ID .id ());
@@ -2756,10 +2765,6 @@ public final void assertEmptyProjects() throws Exception {
27562765 }
27572766 }
27582767
2759- public static String activeProject () {
2760- return activeProject ;
2761- }
2762-
27632768 protected void createProject (String project ) throws IOException {
27642769 assert multiProjectEnabled ;
27652770 final Request request = new Request ("PUT" , "/_project/" + project );
@@ -2796,16 +2801,18 @@ private Collection<String> getProjectIds(RestClient client) throws IOException {
27962801 }
27972802
27982803 protected void cleanUpProjects () throws IOException {
2804+ assert multiProjectEnabled ;
27992805 final var projectIds = getProjectIds (adminClient ());
28002806 for (String projectId : projectIds ) {
2801- if (projectId .equals (ProjectId .DEFAULT .id ()) || projectId . equals ( activeProject ) || extraProjects . contains ( projectId ) ) {
2807+ if (projectId .equals (ProjectId .DEFAULT .id ())) {
28022808 continue ;
28032809 }
28042810 deleteProject (projectId );
28052811 }
28062812 }
28072813
28082814 private void deleteProject (String project ) throws IOException {
2815+ assert multiProjectEnabled ;
28092816 final Request request = new Request ("DELETE" , "/_project/" + project );
28102817 cleanupClient ().performRequest (request );
28112818 }
0 commit comments