-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save the subresults for tmt-report-result
All the results generated by tmt-report-results become objects of `tmt.result.SubResult`.
- Loading branch information
Showing
13 changed files
with
245 additions
and
42 deletions.
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
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,63 @@ | ||
#!/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_dir=\$(mktemp -d)" 0 "Create run directory" | ||
rlRun "pushd subresults" | ||
rlRun "set -o pipefail" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Test the subresults were generated into results.yaml" | ||
rlRun "tmt run --id $run_dir --scratch -v 2>&1 >/dev/null | tee output" 1 | ||
|
||
# Check the parent test outcomes | ||
rlAssertGrep "fail /test/beakerlib (on default-0)" "output" | ||
rlAssertGrep "fail /test/fail (on default-0)" "output" | ||
rlAssertGrep "pass /test/pass (on default-0)" "output" | ||
rlAssertGrep "total: 1 test passed and 2 tests failed" "output" | ||
|
||
# Check subtests outcomes | ||
|
||
## The internal tests which is checking the TESTID and | ||
## BEAKERLIB_COMMAND_REPORT_RESULT variables must pass | ||
rlAssertGrep "pass /test/beakerlib/Internal-test-of-environment-variable-values" "output" | ||
|
||
rlAssertGrep "pass /test/beakerlib/phase-setup" "output" | ||
rlAssertGrep "pass /test/beakerlib/phase-test-pass" "output" | ||
rlAssertGrep "fail /test/beakerlib/phase-test-fail" "output" | ||
rlAssertGrep "pass /test/beakerlib/phase-cleanup" "output" | ||
|
||
rlAssertGrep "warn /test/fail/subtest/weird" "output" | ||
rlAssertGrep "pass /test/pass/subtest/good2" "output" | ||
|
||
# Check the subresults get correctly saved in results.yaml | ||
rlRun "results_file=${run_dir}/plan/execute/results.yaml" | ||
|
||
rlRun "yq -ey '.[] | select(.name == \"/test/beakerlib\") | .subresult' ${results_file} > subresults_beakerlib.yaml" | ||
rlAssertGrep "name: /test/beakerlib/phase-setup" "subresults_beakerlib.yaml" | ||
rlAssertGrep "name: /test/beakerlib/phase-test-pass" "subresults_beakerlib.yaml" | ||
rlAssertGrep "name: /test/beakerlib/phase-test-fail" "subresults_beakerlib.yaml" | ||
rlAssertGrep "name: /test/beakerlib/phase-cleanup" "subresults_beakerlib.yaml" | ||
|
||
rlRun "yq -ey '.[] | select(.name == \"/test/fail\") | .subresult' ${results_file} > subresults_fail.yaml" | ||
rlAssertGrep "name: /test/fail/subtest/good" "subresults_fail.yaml" | ||
rlAssertGrep "name: /test/fail/subtest/fail" "subresults_fail.yaml" | ||
rlAssertGrep "name: /test/fail/subtest/weird" "subresults_fail.yaml" | ||
|
||
rlRun "yq -ey '.[] | select(.name == \"/test/pass\") | .subresult' ${results_file} > subresults_pass.yaml" | ||
rlAssertGrep "name: /test/pass/subtest/good0" "subresults_pass.yaml" | ||
rlAssertGrep "name: /test/pass/subtest/good1" "subresults_pass.yaml" | ||
rlAssertGrep "name: /test/pass/subtest/good2" "subresults_pass.yaml" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup | ||
rlRun "rm output" | ||
rlRun "rm subresults_{beakerlib,fail,pass}.yaml" | ||
rlRun "popd" | ||
rlRun "rm -rf $run_dir" 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 @@ | ||
1 |
33 changes: 33 additions & 0 deletions
33
tests/execute/result/subresults/beaker-phases-subresults.sh
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,33 @@ | ||
#!/bin/bash | ||
. /usr/share/beakerlib/beakerlib.sh || exit 1 | ||
|
||
|
||
rlJournalStart | ||
rlPhaseStartSetup "phase-setup" | ||
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" | ||
rlRun "pushd $tmp" | ||
rlRun "set -o pipefail" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "Internal test of environment variable values" | ||
rlRun "test -n \"\$TMT_TEST_SERIAL_NUMBER\" -o -n \"\$TESTID\"" 0 "Check the variables are not empty" | ||
rlAssertEquals "TESTID must be set to TMT_TEST_SERIAL_NUMBER" "$TESTID" "$TMT_TEST_SERIAL_NUMBER" | ||
|
||
rlRun "[[ \$BEAKERLIB_COMMAND_REPORT_RESULT =~ tmt-report-result$ ]]" 0 "Check the variable contains path to a tmt-report-result script" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "phase-test pass" | ||
rlRun "echo mytest-pass | tee output" 0 "Check output" | ||
rlAssertGrep "mytest-pass" "output" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartTest "phase-test fail" | ||
rlRun "echo mytest-fail | tee output" 0 "Check output" | ||
rlAssertGrep "asdf-asdf" "output" | ||
rlPhaseEnd | ||
|
||
rlPhaseStartCleanup "phase-cleanup" | ||
rlRun "popd" | ||
rlRun "rm -r $tmp" 0 "Remove tmp 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,12 @@ | ||
/plan: | ||
discover: | ||
how: fmf | ||
provision: | ||
# TODO: | ||
# For some reason the tests are not working on my local machine, | ||
# try to test in CI. Container works fine. | ||
how: local | ||
|
||
#how: container | ||
execute: | ||
how: tmt |
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,21 @@ | ||
/pass: | ||
summary: Basic test of subresults | ||
test: | | ||
tmt-report-result /subtest/good0 PASS | ||
tmt-report-result /subtest/good1 PASS | ||
tmt-report-result /subtest/good2 PASS | ||
|
||
/fail: | ||
summary: Reduced outcome of subresults must be fail | ||
test: | | ||
tmt-report-result /subtest/good PASS | ||
tmt-report-result /subtest/fail FAIL | ||
tmt-report-result /subtest/weird WARN | ||
|
||
/beakerlib: | ||
summary: Beakerlib rlPhaseEnd as tmt subresult | ||
|
||
# Also, explicitly set the framework | ||
framework: beakerlib | ||
|
||
test: ./beaker-phases-subresults.sh |
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
Oops, something went wrong.