This is an automated email from the ASF dual-hosted git repository. krathbun pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new bdbe4f5173 Fix to some shared mini cluster ITs (#5579) bdbe4f5173 is described below commit bdbe4f5173d49ddc347fc58be48796fe15a863b1 Author: Kevin Rathbun <krath...@apache.org> AuthorDate: Fri May 23 10:57:07 2025 -0400 Fix to some shared mini cluster ITs (#5579) * Fix to some shared mini cluster ITs: Some mini cluster ITs were missing a `SharedMiniClusterBase.stopMiniCluster()` in a JUnit AfterAll. Added to those that were missing. * Add check for new ITs that don't stop mini --------- Co-authored-by: Christopher Tubbs <ctubb...@apache.org> --- .github/workflows/maven.yaml | 2 + src/build/ci/find-startMini-without-stopMini.sh | 54 ++++++++++++++++++++++ .../test/compaction/ExternalCompaction_1_IT.java | 6 +++ .../test/compaction/ExternalCompaction_2_IT.java | 6 +++ .../test/compaction/ExternalCompaction_3_IT.java | 6 +++ 5 files changed, 74 insertions(+) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index ad7c810418..120e74dad6 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -50,6 +50,8 @@ jobs: run: src/build/ci/find-unapproved-chars.sh - name: Check for unapproved JUnit API usage run: src/build/ci/find-unapproved-junit.sh + - name: Check for unapproved use of startMiniCluster without stopMiniCluster + run: src/build/ci/find-startMini-without-stopMini.sh - name: Build with Maven (Fast Build) timeout-minutes: 20 run: mvn -B -V -e -ntp "-Dstyle.color=always" clean package dependency:resolve -DskipTests -DskipFormat -DverifyFormat diff --git a/src/build/ci/find-startMini-without-stopMini.sh b/src/build/ci/find-startMini-without-stopMini.sh new file mode 100755 index 0000000000..937909e2fe --- /dev/null +++ b/src/build/ci/find-startMini-without-stopMini.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# The purpose of this ci script is to ensure that a pull request doesn't +# unintentionally add a test with startMiniCluster without stopping it +# with stopMiniCluster. +NUM_EXPECTED=0 +ALLOWED=( + #Uncomment when merging to main + #test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_2_IT.java + #test/src/main/java/org/apache/accumulo/test/compaction/FlakyExternalCompaction2IT.java +) + +ALLOWED_PIPE_SEP=$({ for x in "${ALLOWED[@]}"; do echo "$x"; done; } | paste -sd'|') + +function findallstopminiproblems() { + # -F for fixed-string matching, -R for recursive, -l for matching files + local opts='-FRL' + if [[ $1 == 'print' ]]; then + # -F for fixed-string matching, -R for recursive, -l for matching files, -H for always showing filenames + opts='-FRLH' + fi + # find any new classes using startMiniCluster without using stopMiniCluster, except those allowed + grep -FRl --include='*.java' startMiniCluster | xargs grep "$opts" stopMiniCluster | grep -Pv "^(${ALLOWED_PIPE_SEP//./[.]})\$" +} + +function comparecounts() { + local count + count=$(findallstopminiproblems | wc -l) + if [[ $NUM_EXPECTED -ne $count ]]; then + echo "Expected $NUM_EXPECTED, but found $count unapproved classes using startMiniCluster without stopMiniCluster:" + findallstopminiproblems 'print' + return 1 + fi +} + +comparecounts && echo "Found exactly $NUM_EXPECTED unapproved uses of startMiniCluster without stopMiniCluster, as expected" diff --git a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java index ba6c0167b3..ae4efd75fd 100644 --- a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java +++ b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java @@ -101,6 +101,7 @@ import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.accumulo.test.functional.SlowIterator; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -126,6 +127,11 @@ public class ExternalCompaction_1_IT extends SharedMiniClusterBase { startMiniClusterWithConfig(new ExternalCompaction1Config()); } + @AfterAll + public static void afterTests() { + stopMiniCluster(); + } + @AfterEach public void tearDown() throws Exception { // The ExternalDoNothingCompactor needs to be restarted between tests diff --git a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_2_IT.java b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_2_IT.java index 117a46bb5a..027e447948 100644 --- a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_2_IT.java +++ b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_2_IT.java @@ -66,6 +66,7 @@ import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.accumulo.test.functional.SlowIterator; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -88,6 +89,11 @@ public class ExternalCompaction_2_IT extends SharedMiniClusterBase { startMiniClusterWithConfig(new ExternalCompaction2Config()); } + @AfterAll + public static void afterTests() { + stopMiniCluster(); + } + @AfterEach public void tearDown() throws Exception { // The ExternalDoNothingCompactor needs to be restarted between tests diff --git a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_3_IT.java b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_3_IT.java index 15356e2347..bdad347ee5 100644 --- a/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_3_IT.java +++ b/test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_3_IT.java @@ -54,6 +54,7 @@ import org.apache.accumulo.minicluster.ServerType; import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -72,6 +73,11 @@ public class ExternalCompaction_3_IT extends SharedMiniClusterBase { startMiniClusterWithConfig(new ExternalCompaction3Config()); } + @AfterAll + public static void afterTests() { + stopMiniCluster(); + } + @AfterEach public void tearDown() throws Exception { // The ExternalDoNothingCompactor needs to be restarted between tests