-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement check-result: test check failure affects test result by default #3239
Open
martinhoyer
wants to merge
6
commits into
teemtee:main
Choose a base branch
from
martinhoyer:check-results
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
41bb466
Initial check-result implementation
martinhoyer 730fc74
Add check-result key
martinhoyer f91ea05
Refactor to test.check.result
martinhoyer 0efce7c
fixup! Add check-result key
martinhoyer 795d175
Incorporating suggestions
martinhoyer 7fa2cbc
hacking
martinhoyer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
#!/bin/bash | ||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
rlJournalStart | ||
rlPhaseStartSetup | ||
rlRun "run=\$(mktemp -d)" 0 "Create run directory" | ||
rlRun "pushd check_results" | ||
rlRun "set -o pipefail" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Check results are respected" | ||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-pass execute -vv report -vv 2>&1 >/dev/null" 0 | ||
rlAssertGrep "pass /test/check-pass" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (after-test check)" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-fail-respect execute -vv report -vv 2>&1 >/dev/null" 1 | ||
rlAssertGrep "fail /test/check-fail-respect" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (after-test check)" $rlRun_LOG | ||
rlAssertGrep "check failed" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-fail-ignore execute -vv report -vv 2>&1 >/dev/null" 0 | ||
rlAssertGrep "pass /test/check-fail-ignore" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (after-test check)" $rlRun_LOG | ||
rlAssertNotGrep "check failed" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-xfail-pass execute -vv report -vv 2>&1 >/dev/null" 1 | ||
rlAssertGrep "fail /test/check-xfail-pass" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (after-test check)" $rlRun_LOG | ||
rlAssertGrep "unexpected pass" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-xfail-fail execute -vv report -vv 2>&1 >/dev/null" 0 | ||
rlAssertGrep "pass /test/check-xfail-fail" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (after-test check)" $rlRun_LOG | ||
rlAssertGrep "expected failure" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-multiple execute -vv report -vv 2>&1 >/dev/null" 1 | ||
rlAssertGrep "fail /test/check-multiple" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (after-test check)" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "check failed" $rlRun_LOG | ||
rlAssertGrep "unexpected pass" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-override execute -vv report -vv 2>&1 >/dev/null" 0 | ||
rlAssertGrep "pass /test/check-override" $rlRun_LOG | ||
rlAssertGrep "pass dmesg (before-test check)" $rlRun_LOG | ||
rlAssertGrep "fail dmesg (after-test check)" $rlRun_LOG | ||
rlAssertNotGrep "check failed" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-warn execute -vv report -vv 2>&1 >/dev/null" 1 | ||
rlAssertGrep "warn /test/check-warn" $rlRun_LOG | ||
rlAssertGrep "warn dmesg (after-test check)" $rlRun_LOG | ||
|
||
rlRun -s "tmt run --id \${run} --scratch provision --how local test --name /test/check-info execute -vv report -vv 2>&1 >/dev/null" 0 | ||
rlAssertGrep "info /test/check-info" $rlRun_LOG | ||
rlAssertGrep "info dmesg (after-test check)" $rlRun_LOG | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Verify results.yaml content" | ||
results_file="${run}/default/plan/execute/results.yaml" | ||
rlAssertExists "$results_file" | ||
|
||
rlRun -s "yq e '.[0]' $results_file" | ||
rlAssertGrep "name: /test/check-pass" $rlRun_LOG | ||
rlAssertGrep "result: pass" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[1]' $results_file" | ||
rlAssertGrep "name: /test/check-fail-respect" $rlRun_LOG | ||
rlAssertGrep "result: fail" $rlRun_LOG | ||
rlAssertGrep "note: check failed" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[2]' $results_file" | ||
rlAssertGrep "name: /test/check-fail-ignore" $rlRun_LOG | ||
rlAssertGrep "result: pass" $rlRun_LOG | ||
rlAssertNotGrep "note: check failed" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[3]' $results_file" | ||
rlAssertGrep "name: /test/check-xfail-pass" $rlRun_LOG | ||
rlAssertGrep "result: fail" $rlRun_LOG | ||
rlAssertGrep "note: unexpected pass" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[4]' $results_file" | ||
rlAssertGrep "name: /test/check-xfail-fail" $rlRun_LOG | ||
rlAssertGrep "result: pass" $rlRun_LOG | ||
rlAssertGrep "note: expected failure" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[5]' $results_file" | ||
rlAssertGrep "name: /test/check-multiple" $rlRun_LOG | ||
rlAssertGrep "result: fail" $rlRun_LOG | ||
rlAssertGrep "note: check failed, unexpected pass" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[6]' $results_file" | ||
rlAssertGrep "name: /test/check-override" $rlRun_LOG | ||
rlAssertGrep "result: pass" $rlRun_LOG | ||
rlAssertNotGrep "note: check failed" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: pass" $rlRun_LOG | ||
rlAssertGrep " event: before-test" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: fail" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[7]' $results_file" | ||
rlAssertGrep "name: /test/check-warn" $rlRun_LOG | ||
rlAssertGrep "result: warn" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: warn" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
|
||
rlRun -s "yq e '.[8]' $results_file" | ||
rlAssertGrep "name: /test/check-info" $rlRun_LOG | ||
rlAssertGrep "result: info" $rlRun_LOG | ||
rlAssertGrep "check:" $rlRun_LOG | ||
rlAssertGrep "- how: dmesg" $rlRun_LOG | ||
rlAssertGrep " result: info" $rlRun_LOG | ||
rlAssertGrep " event: after-test" $rlRun_LOG | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "popd" | ||
rlRun "rm -r ${run}" 0 "Remove run directory" | ||
rlPhaseEnd | ||
rlJournalEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
summary: Tests for check results behaviour | ||
description: Verify that check results, including after-test checks, are correctly handled | ||
|
||
/test/check-pass: | ||
summary: Test with passing checks | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
result: respect | ||
# Expected outcome: PASS (test passes, check passes) | ||
|
||
/test/check-fail-respect: | ||
summary: Test with failing dmesg check (respect) | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: respect | ||
# Expected outcome: FAIL (test passes, but check fails and is respected) | ||
|
||
/test/check-fail-ignore: | ||
summary: Test with failing dmesg check (ignore) | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: ignore | ||
# Expected outcome: PASS (test passes, check fails but is ignored) | ||
|
||
/test/check-xfail-pass: | ||
summary: Test with passing dmesg check (xfail) | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
result: xfail | ||
# Expected outcome: FAIL (test passes, check passes but xfail expects it to fail) | ||
|
||
/test/check-xfail-fail: | ||
summary: Test with failing dmesg check (xfail) | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: xfail | ||
# Expected outcome: PASS (test passes, check fails but xfail expects it to fail) | ||
|
||
/test/check-multiple: | ||
summary: Test with multiple checks with different result interpretations | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
check: | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: respect | ||
- how: dmesg | ||
result: xfail | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: ignore | ||
# Expected outcome: FAIL (first dmesg check fails and is respected, second dmesg check passes but xfail expects it to fail, third failing dmesg check is ignored) | ||
|
||
/test/check-override: | ||
summary: Test with failing dmesg check but overridden by test result | ||
test: echo "Test passed" | ||
framework: shell | ||
duration: 1m | ||
result: pass | ||
check: | ||
- how: dmesg | ||
failure-pattern: '.*' | ||
result: respect | ||
# Expected outcome: PASS (test passes, check fails but is overridden by 'result: pass') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can switch from
Any
toResultInterpret
, if we add thefrom_spec()
method to it,unserialize
could use it. Might need alsonormalize
callback, but I'd pay that price for getting rid ofAny
. WithAny
, no user of this field can't be sure what the value is.