From ed0673d046ca3b5ecb5fd36cbe593e889f12ca84 Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Mar 09 2018 10:13:26 +0000 Subject: rework of check artifacts tests --- diff --git a/tests/basic-fix-failed-test/runtest.sh b/tests/basic-fix-failed-test/runtest.sh deleted file mode 100644 index 11e0a78..0000000 --- a/tests/basic-fix-failed-test/runtest.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -test_log="/tmp/artifacts/test.log" - -echo "Make sure test log has failed test" -grep -e "^FAIL" ${test_log} - -echo "Change FAIL results to PASS" -sed -i -e 's/^FAIL/PASS/g' ${test_log} - diff --git a/tests/basic-verify-test/runtest.sh b/tests/basic-verify-test/runtest.sh deleted file mode 100644 index 0ce4d8c..0000000 --- a/tests/basic-verify-test/runtest.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -# Make sure test log from previous tests were created -ls ../artifacts/test.log - -# Previous test log should be available on /tmp/artifacts -ls /tmp/artifacts/test.log - -# Clean up log directories -rm -rf ../artifacts diff --git a/tests/beakerlib-fix-failed-test/runtest.sh b/tests/beakerlib-fix-failed-test/runtest.sh deleted file mode 100644 index ff33b8a..0000000 --- a/tests/beakerlib-fix-failed-test/runtest.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -test_log="/tmp/artifacts/test.log" - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="bash" - -rlJournalStart - rlPhaseStartTest "Fix beakerlib failed test" - # Make sure test log has failed test - rlRun "grep -e '^FAIL' ${test_log}" - # Change FAIL results to PASS - rlRun "sed -i -e 's/^FAIL/PASS/g' ${test_log}" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd - - diff --git a/tests/beakerlib-verify-test/runtest.sh b/tests/beakerlib-verify-test/runtest.sh deleted file mode 100644 index fb925c3..0000000 --- a/tests/beakerlib-verify-test/runtest.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="standard-test-roles" - -rlJournalStart - rlPhaseStartTest "Check output files" - # Previous test log should have created local artifacts - rlRun "ls ../artifacts/test.log" - # Previous test log should be available on /tmp/artifacts - rlRun "ls /tmp/artifacts/test.log" - rlPhaseEnd - rlPhaseStartCleanup - rlRun "rm -rf ../artifacts" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/rhts-fail-test/Makefile b/tests/rhts-fail-test/Makefile index 05cafbe..9ae494f 100644 --- a/tests/rhts-fail-test/Makefile +++ b/tests/rhts-fail-test/Makefile @@ -4,7 +4,7 @@ BUILT_FILES= FILES=$(METADATA) runtest.sh Makefile -.PHONY: all install download clean +.PHONY: all install clean run: $(FILES) build ./runtest.sh diff --git a/tests/rhts-fix-failed-test/runtest.sh b/tests/rhts-fix-failed-test/runtest.sh deleted file mode 100644 index 11e0a78..0000000 --- a/tests/rhts-fix-failed-test/runtest.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -test_log="/tmp/artifacts/test.log" - -echo "Make sure test log has failed test" -grep -e "^FAIL" ${test_log} - -echo "Change FAIL results to PASS" -sed -i -e 's/^FAIL/PASS/g' ${test_log} - diff --git a/tests/rhts-simple-test/Makefile b/tests/rhts-simple-test/Makefile index d49515c..eb0d996 100644 --- a/tests/rhts-simple-test/Makefile +++ b/tests/rhts-simple-test/Makefile @@ -4,7 +4,7 @@ BUILT_FILES= FILES=$(METADATA) runtest.sh Makefile -.PHONY: all install download clean +.PHONY: all install clean run: $(FILES) build ./runtest.sh diff --git a/tests/rhts-verify-test/runtest.sh b/tests/rhts-verify-test/runtest.sh deleted file mode 100644 index 0ce4d8c..0000000 --- a/tests/rhts-verify-test/runtest.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -e - -# Make sure test log from previous tests were created -ls ../artifacts/test.log - -# Previous test log should be available on /tmp/artifacts -ls /tmp/artifacts/test.log - -# Clean up log directories -rm -rf ../artifacts diff --git a/tests/tests_artifacts_test_env.yml b/tests/tests_artifacts_test_env.yml new file mode 100644 index 0000000..4d8ae88 --- /dev/null +++ b/tests/tests_artifacts_test_env.yml @@ -0,0 +1,9 @@ +# These tasks should run after as test that fails +- name: "Check if {{remote_artifacts}} was created properly on test environment" + shell: "ls {{remote_artifacts}}/test.log" + +- name: "Clean up {{remote_artifacts}} to not affect other tests on test environment" + file: + state: absent + path: "{{remote_artifacts}}/" + diff --git a/tests/tests_artifacts_test_runner.yml b/tests/tests_artifacts_test_runner.yml new file mode 100644 index 0000000..85b59d8 --- /dev/null +++ b/tests/tests_artifacts_test_runner.yml @@ -0,0 +1,10 @@ +# These tasks should run after as test that fails +- name: "Check if {{artifacts}} was created properly on test runner" + shell: "ls {{artifacts}}/test.log" + delegate_to: localhost + +- name: "Clean up {{artifacts}} to not affect other tests on test runner" + file: + state: absent + path: "{{artifacts}}/" + delegate_to: localhost diff --git a/tests/tests_basic.yml b/tests/tests_basic.yml index cee6b2c..0962d25 100644 --- a/tests/tests_basic.yml +++ b/tests/tests_basic.yml @@ -1,11 +1,11 @@ # Tests for basic role - hosts: localhost + tags: + - atomic + - classic + - container roles: - role: standard-test-basic - tags: - - atomic - - classic - - container tests: - basic-simple-test - basic-parameters-test: @@ -14,41 +14,25 @@ required_packages: - iscsi-initiator-utils # test if we can install packages -# Tests to verify basic role execution -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - atomic - - classic - - container - tests: - - basic-verify-test - -- import_playbook: tests_verify_local.yml + tasks: + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml #### Make sure the role behaves correctly if test fails - hosts: localhost + tags: + - atomic + - classic + - container + roles: - role: standard-test-basic - tags: - - atomic - - classic - - container tests: - basic-fail-test ignore_errors: yes -# Tests to verify failed role execution -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - atomic - - classic - - container - tests: - - basic-fix-failed-test - - basic-verify-test - -- import_playbook: tests_verify_local.yml + tasks: + # 'tests_verify_failed_test' tasks should run after 'basic-fail-test' + - import_tasks: tests_verify_failed_test.yml + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml diff --git a/tests/tests_beakerlib.yml b/tests/tests_beakerlib.yml index 01dd883..db94326 100644 --- a/tests/tests_beakerlib.yml +++ b/tests/tests_beakerlib.yml @@ -1,51 +1,35 @@ # Tests for beakerlib role - hosts: localhost + tags: + - atomic + - classic + - container roles: - role: standard-test-beakerlib - tags: - - atomic - - classic - - container tests: - beakerlib-simple-test required_packages: - iscsi-initiator-utils # test if we can install packages -# Tests to verify beakerlib role execution -- hosts: localhost - roles: - - role: standard-test-beakerlib - tags: - - atomic - - classic - - container - tests: - - beakerlib-verify-test + tasks: + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml -- import_playbook: tests_verify_local.yml #### Make sure the role behaves correctly if test fails - hosts: localhost + tags: + - atomic + - classic + - container roles: - role: standard-test-beakerlib - tags: - - atomic - - classic - - container tests: - beakerlib-fail-test ignore_errors: yes -# Tests to verify failed role execution -- hosts: localhost - roles: - - role: standard-test-beakerlib - tags: - - atomic - - classic - - container - tests: - - beakerlib-fix-failed-test - - beakerlib-verify-test - -- import_playbook: tests_verify_local.yml + tasks: + # 'tests_verify_failed_test' tasks should run after 'beakerlib-fail-test' + - import_tasks: tests_verify_failed_test.yml + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml diff --git a/tests/tests_rhts.yml b/tests/tests_rhts.yml index a710253..eb47766 100644 --- a/tests/tests_rhts.yml +++ b/tests/tests_rhts.yml @@ -1,28 +1,22 @@ # Tests for rhts role only runs on classic tag - hosts: localhost + tags: + - classic roles: - role: standard-test-rhts - tags: - - classic tests: - rhts-simple-test required_packages: - iscsi-initiator-utils # test if we can install packages -# Tests to verify rhts role execution -# Using basic role becasue it is easier to know where the artifacts should be created -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - tests: - - rhts-verify-test - -- import_playbook: tests_verify_local.yml + tasks: + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml #### Make sure the role behaves correctly if test fails - hosts: localhost + tags: + - classic roles: - role: standard-test-rhts tags: @@ -31,14 +25,8 @@ - rhts-fail-test ignore_errors: yes -# Tests to verify failed role execution -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - tests: - - rhts-fix-failed-test - - rhts-verify-test - -- import_playbook: tests_verify_local.yml + tasks: + # 'tests_verify_failed_test' tasks should run after 'rhts-fail-test' + - import_tasks: tests_verify_failed_test.yml + - import_tasks: tests_artifacts_test_env.yml + - import_tasks: tests_artifacts_test_runner.yml diff --git a/tests/tests_verify_failed_test.yml b/tests/tests_verify_failed_test.yml new file mode 100644 index 0000000..a51af94 --- /dev/null +++ b/tests/tests_verify_failed_test.yml @@ -0,0 +1,11 @@ +# These tasks should run after as test that fails +- name: Read test.log on test environment + shell: "cat {{remote_artifacts}}/test.log" + register: test_log + +- name: Check for FAIL on test.log on test environment + fail: msg="Could not find FAIL on test log" + when: test_log.stdout.find("FAIL") == -1 + # We should fail when we can not find FAIL string on log + # -1 means string not found + diff --git a/tests/tests_verify_local.yml b/tests/tests_verify_local.yml deleted file mode 100644 index 8c28423..0000000 --- a/tests/tests_verify_local.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Run after role test, check if role created expected files -- hosts: localhost - tags: - - atomic - - classic - - container - tasks: - - name: check if artifacts is created locally - shell: ls artifacts/test.log - delegate_to: localhost - # remove artifacts directory after check so it does not affect other tests - - name: remove artifacts directory - shell: rm -rf artifacts - delegate_to: localhost -