Skip to content

Commit ad62604

Browse files
kjs1095claude
andauthored
HDDS-17840. Create CI check for Python unit tests (#12090)
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
1 parent ac9c5bc commit ad62604

5 files changed

Lines changed: 58 additions & 34 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ jobs:
208208
uses: $/.github/workflows/check.yml
209209
with:
210210
checkout-fetch-depth: ${{ matrix.check != 'bats' && 1 || 0 }}
211-
java-version: ${{ !contains('author,bats', matrix.check) && needs.build-info.outputs.java-version || '' }}
211+
java-version: ${{ !contains('author,bats,pyunit', matrix.check) && needs.build-info.outputs.java-version || '' }}
212212
ratis-args: ${{ inputs.ratis_args }}
213-
runner: ${{ contains('author,bats', matrix.check) && 'ubuntu-slim' || 'ubuntu-24.04' }}
213+
runner: ${{ contains('author,bats,pyunit', matrix.check) && 'ubuntu-slim' || 'ubuntu-24.04' }}
214214
script: ${{ matrix.check }}
215215
sha: ${{ needs.build-info.outputs.sha }}
216216
timeout-minutes: 30

‎dev-support/ci/junit_summary.bats‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎dev-support/ci/selective_ci_checks.bats‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ load ${TOOLS_DIR}/bats/bats-assert/load.bash
325325
@test "CI lib change" {
326326
run dev-support/ci/selective_ci_checks.sh ceb79acaa
327327

328-
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","rat"]'
328+
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","pyunit","rat"]'
329329
assert_output -p needs-build=true
330330
assert_output -p needs-compile=true
331331
assert_output -p needs-compose-tests=true
@@ -336,7 +336,7 @@ load ${TOOLS_DIR}/bats/bats-assert/load.bash
336336
@test "CI workflow change" {
337337
run dev-support/ci/selective_ci_checks.sh 90a8d7c01
338338

339-
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","rat"]'
339+
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","pyunit","rat"]'
340340
assert_output -p needs-build=true
341341
assert_output -p needs-compile=true
342342
assert_output -p needs-compose-tests=true
@@ -359,7 +359,7 @@ load ${TOOLS_DIR}/bats/bats-assert/load.bash
359359
@test "CI workflow change (check.yml)" {
360360
run dev-support/ci/selective_ci_checks.sh 1468af02067ec75b255f605816c32f8bf4dfaabf
361361

362-
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","rat"]'
362+
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","pyunit","rat"]'
363363
assert_output -p needs-build=true
364364
assert_output -p needs-compile=true
365365
assert_output -p needs-compose-tests=true
@@ -370,7 +370,7 @@ load ${TOOLS_DIR}/bats/bats-assert/load.bash
370370
@test "CI workflow change (ci.yaml)" {
371371
run dev-support/ci/selective_ci_checks.sh 90fd5f2adc
372372

373-
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","rat"]'
373+
assert_output -p 'basic-checks=["author","bats","checkstyle","errorprone","findbugs","pmd","pyunit","rat"]'
374374
assert_output -p needs-build=true
375375
assert_output -p needs-compile=true
376376
assert_output -p needs-compose-tests=true
@@ -476,3 +476,14 @@ load ${TOOLS_DIR}/bats/bats-assert/load.bash
476476
assert_output -p needs-integration-tests=true
477477
assert_output -p needs-kubernetes-tests=false
478478
}
479+
480+
@test "python helper change" {
481+
run dev-support/ci/selective_ci_checks.sh c917a6e60d
482+
483+
assert_output -p 'basic-checks=["rat","pyunit"]'
484+
assert_output -p needs-build=true
485+
assert_output -p needs-compile=false
486+
assert_output -p needs-compose-tests=false
487+
assert_output -p needs-integration-tests=false
488+
assert_output -p needs-kubernetes-tests=false
489+
}

‎dev-support/ci/selective_ci_checks.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,21 @@ function check_needs_pmd() {
497497
start_end::group_end
498498
}
499499

500+
function check_needs_pyunit() {
501+
start_end::group_start "Check if pyunit is needed"
502+
local pattern_array=(
503+
"^dev-support/ci/.*\.py$"
504+
"^hadoop-ozone/dev-support/checks/pyunit.sh"
505+
)
506+
filter_changed_files
507+
508+
if [[ ${match_count} != "0" ]]; then
509+
add_basic_check pyunit
510+
fi
511+
512+
start_end::group_end
513+
}
514+
500515
# Counts other files which do not need to trigger any functional test
501516
# (i.e. no compose/integration/kubernetes)
502517
function get_count_misc_files() {
@@ -640,5 +655,6 @@ check_needs_checkstyle
640655
check_needs_errorprone
641656
check_needs_findbugs
642657
check_needs_pmd
658+
check_needs_pyunit
643659
calculate_test_types_to_run
644660
set_outputs
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env bash
2-
32
# Licensed to the Apache Software Foundation (ASF) under one or more
43
# contributor license agreements. See the NOTICE file distributed with
54
# this work for additional information regarding copyright ownership.
@@ -15,8 +14,28 @@
1514
# See the License for the specific language governing permissions and
1615
# limitations under the License.
1716

18-
@test "coverage_summary.py unit tests" {
19-
cd "${BATS_TEST_DIRNAME}"
20-
run python3 -m unittest test_coverage_summary
21-
[ "$status" -eq 0 ]
22-
}
17+
#checks:basic
18+
19+
set -u -o pipefail
20+
21+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
22+
# from <ozone-root>/hadoop-ozone/dev-support/checks to <ozone-root>
23+
cd "${DIR}/../../.." || exit 1
24+
BASE_DIR="$(pwd -P)"
25+
26+
CHECK=pyunit
27+
28+
REPORT_DIR=${OUTPUT_DIR:-"${BASE_DIR}/target/${CHECK}"}
29+
mkdir -p "${REPORT_DIR}"
30+
31+
REPORT_FILE="${REPORT_DIR}/summary.txt"
32+
33+
python3 -m unittest discover -v -s dev-support/ci -p 'test_*.py' 2>&1 \
34+
| tee "${REPORT_DIR}/output.log"
35+
rc=$?
36+
37+
grep '^\(FAIL\|ERROR\): ' "${REPORT_DIR}/output.log" > "${REPORT_FILE}"
38+
grep -c '^\(FAIL\|ERROR\): ' "${REPORT_FILE}" > "${REPORT_DIR}/failures"
39+
40+
ERROR_PATTERN=""
41+
source "${DIR}/_post_process.sh"

0 commit comments

Comments
 (0)