Skip to content

Commit 65a9d6c

Browse files
HDDS-12587. Detect test class module in flaky-test-check (apache#8162)
Co-authored-by: Peter Lee <[email protected]>
1 parent aac9383 commit 65a9d6c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/intermittent-test-check.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ env:
6161
RATIS_REPO: ${{ github.event.inputs.ratis-repo }}
6262
RATIS_VERSION: ${{ github.event.inputs.ratis-ref }}
6363
JAVA_VERSION: ${{ github.event.inputs.java-version }}
64+
# Surefire 3.0.0-M4 is used because newer versions do not reliably kill the fork on timeout
65+
# SUREFIRE-1722, SUREFIRE-1815
66+
SUREFIRE_VERSION: 3.0.0-M4
6467
run-name: ${{ github.event_name == 'workflow_dispatch' && format('{0}#{1}[{2}]-{3}x{4}-java{5}', inputs.test-class, inputs.test-name, inputs.ref, inputs.splits, inputs.iterations, inputs.java-version) || '' }}
6568
jobs:
6669
prepare-job:
@@ -87,11 +90,54 @@ jobs:
8790
with:
8891
repo: ${{ github.event.inputs.ratis-repo || format('{0}/ratis', github.repository_owner) }}
8992
ref: ${{ github.event.inputs.ratis-ref }}
93+
find-tests:
94+
if: ${{ always() }}
95+
needs:
96+
- prepare-job
97+
runs-on: ubuntu-24.04
98+
outputs:
99+
modules: ${{ steps.modules.outputs.modules }}
100+
steps:
101+
- uses: actions/checkout@v4
102+
with:
103+
ref: ${{ github.event.inputs.ref }}
104+
- name: Cache for maven dependencies
105+
uses: actions/cache/restore@v4
106+
with:
107+
path: |
108+
~/.m2/repository/*/*/*
109+
!~/.m2/repository/org/apache/ozone
110+
key: maven-repo-${{ hashFiles('**/pom.xml') }}
111+
restore-keys: |
112+
maven-repo-
113+
- name: Setup java
114+
uses: actions/setup-java@v4
115+
with:
116+
distribution: 'temurin'
117+
java-version: ${{ github.event.inputs.java-version }}
118+
- name: Find tests
119+
run: |
120+
# find tests to be run in splits by running them with very short timeout
121+
hadoop-ozone/dev-support/checks/junit.sh -DexcludedGroups="native|slow|unhealthy" -DskipShade \
122+
-Dtest="$TEST_CLASS,Abstract*Test*\$*" \
123+
-Dsurefire.fork.timeout=1 -Dmaven-surefire-plugin.version=${{ env.SUREFIRE_VERSION }} \
124+
|| true # ignore errors
125+
env:
126+
ITERATIONS: 1
127+
- name: Find modules
128+
id: modules
129+
run: |
130+
grep -e 'surefire:${{ env.SUREFIRE_VERSION }}:test' -e 'Running org.apache' target/unit/output.log | grep -B1 'Running org.apache'
131+
modules=$(grep -e 'surefire:${{ env.SUREFIRE_VERSION }}:test' -e 'Running org.apache' target/unit/output.log | grep -B1 'Running org.apache' \
132+
| grep surefire | cut -f2 -d'@' | awk '{ print $1 }' | sed 's/^/:/' | xargs | sed -e 's/ /,/g')
133+
echo "modules=$modules" >> $GITHUB_OUTPUT
134+
if: ${{ !cancelled() }}
90135
build:
91136
if: ${{ always() }}
92137
needs:
93138
- prepare-job
94139
- ratis
140+
- find-tests
95141
runs-on: ubuntu-24.04
96142
timeout-minutes: 60
97143
steps:
@@ -129,6 +175,10 @@ jobs:
129175
args="$args -Dgrpc.protobuf-compile.version=${{ needs.ratis.outputs.protobuf-version }}"
130176
fi
131177
178+
if [[ -n "${{ needs.find-tests.outputs.modules }}" ]]; then
179+
args="$args -am -pl ${{ needs.find-tests.outputs.modules }}"
180+
fi
181+
132182
hadoop-ozone/dev-support/checks/build.sh $args
133183
- name: Store Maven repo for tests
134184
uses: actions/upload-artifact@v4
@@ -143,6 +193,7 @@ jobs:
143193
- prepare-job
144194
- ratis
145195
- build
196+
- find-tests
146197
name: Run-Split
147198
runs-on: ubuntu-24.04
148199
strategy:
@@ -197,6 +248,10 @@ jobs:
197248
args="$args -Dgrpc.protobuf-compile.version=${{ needs.ratis.outputs.protobuf-version }}"
198249
fi
199250
251+
if [[ -n "${{ needs.find-tests.outputs.modules }}" ]]; then
252+
args="$args -pl ${{ needs.find-tests.outputs.modules }}"
253+
fi
254+
200255
if [ "$TEST_METHOD" = "ALL" ]; then
201256
echo "Running all tests from $TEST_CLASS"
202257
set -x

0 commit comments

Comments
 (0)