Skip to content

Commit

Permalink
chore: get cloud e2e test result total (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
JashBook authored Dec 30, 2024
1 parent 0f6db80 commit 4cc04f2
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 6 deletions.
14 changes: 12 additions & 2 deletions .github/archive/workflows/cloud-e2e-with-k3s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,18 @@ jobs:
make ${TEST_TYPE} | tee -a ${file_log}
test_ret="$( grep "Test Suite Failed" ${file_log} || true )"
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep '\-\-' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
TEST_RESULT_ALL="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true))"
echo "test result all:${TEST_RESULT_ALL}"
TEST_RESULT_ALL=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$TEST_RESULT_ALL")
test_result=$(bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 41 --test-result "${TEST_RESULT_ALL}")
echo "test result total:${test_result}"
if [[ -z "$test_result" ]]; then
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
fi
if [[ -z "$test_result" ]]; then
test_result="[PASSED]"
if [[ -n "$test_ret" ]]; then
Expand Down
39 changes: 39 additions & 0 deletions .github/utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Usage: $(basename "$0") <options>
38) get cloud test result
39) get cloud pre version
40) get ginkgo test result
41) get ginkgo test result total
-tn, --tag-name Release tag name
-gr, --github-repo Github Repo
-gt, --github-token Github token
Expand Down Expand Up @@ -977,6 +978,41 @@ get_cloud_pre_version() {
echo "$PRE_VERSION"
}

get_ginkgo_test_result_total() {
if [[ -z "${TEST_RESULT}" ]]; then
return
fi
total_passed=0
total_failed=0
total_pending=0
total_skipped=0
for test_result in $(echo "${TEST_RESULT}"); do
case $test_result in
Passed)
total_passed=$(($total_passed + $test_result_tmp))
;;
Failed)
total_failed=$(($total_failed + $test_result_tmp))
;;
Pending)
total_pending=$(($total_pending + $test_result_tmp))
;;
Skipped)
total_skipped=$(($total_skipped + $test_result_tmp))
;;
*)
test_result_tmp=$test_result
;;
esac
done

if [ $total_failed -gt 0 ]; then
echo "FAIL! -- ${total_passed} Passed | ${total_failed} Failed | ${total_pending} Pending | ${total_skipped} Skipped"
else
echo "SUCCESS! -- ${total_passed} Passed | ${total_failed} Failed | ${total_pending} Pending | ${total_skipped} Skipped"
fi
}

parse_command_line() {
while :; do
case "${1:-}" in
Expand Down Expand Up @@ -1298,6 +1334,9 @@ main() {
40)
get_ginkgo_test_result
;;
41)
get_ginkgo_test_result_total
;;
esac
}

Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/cloud-e2e-k3s-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,18 @@ jobs:
make ${TEST_TYPE} | tee -a ${file_log}
test_ret="$( grep "Test Suite Failed" ${file_log} || true )"
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep '\-\-' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
TEST_RESULT_ALL="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true))"
echo "test result all:${TEST_RESULT_ALL}"
TEST_RESULT_ALL=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$TEST_RESULT_ALL")
test_result=$(bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 41 --test-result "${TEST_RESULT_ALL}")
echo "test result total:${test_result}"
if [[ -z "$test_result" ]]; then
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
fi
if [[ -z "$test_result" ]]; then
test_result="[PASSED]"
if [[ -n "$test_ret" ]]; then
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/cloud-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,18 @@ jobs:
make ${TEST_TYPE} | tee -a ${file_log}
test_ret="$( grep "Test Suite Failed" ${file_log} || true )"
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep '\-\-' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
TEST_RESULT_ALL="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true))"
echo "test result all:${TEST_RESULT_ALL}"
TEST_RESULT_ALL=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$TEST_RESULT_ALL")
test_result=$(bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh --type 41 --test-result "${TEST_RESULT_ALL}")
echo "test result total:${test_result}"
if [[ -z "$test_result" ]]; then
test_result="$(cat ${file_log} | (egrep 'SUCCESS!|FAIL!' | grep -- '--' || true) | tail -n 1)"
test_result=$(python3 ${{ github.workspace }}/apecloud-cd/.github/utils/remove_ansi.py --ansi-str "$test_result")
fi
if [[ -z "$test_result" ]]; then
test_result="[PASSED]"
if [[ -n "$test_ret" ]]; then
Expand Down

0 comments on commit 4cc04f2

Please sign in to comment.