From 2e22ab312a179492e1826fa67476f6fe88d65ed5 Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Dec 04 2018 11:30:47 +0000 Subject: Merge #10 `WIP: tests: Execute tests from upstream instead` --- diff --git a/.gitignore b/.gitignore index 40dd468..c83f5ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/tests/str/ /standard-test-roles-0.2.tar.gz /standard-test-roles-0.3.tar.gz /standard-test-roles-0.4.tar.gz diff --git a/tests/avocado.yml b/tests/avocado.yml deleted file mode 100644 index 846cd8c..0000000 --- a/tests/avocado.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Tests for avocado role -- hosts: localhost - tags: - - classic - - container - roles: - - role: standard-test-avocado - tests: - - /bin/true - - role: standard-test-avocado - tests: - - /bin/false - ignore_errors: yes - tasks: - - name: Read test.log on test environment - set_fact: - test_log: "{{ lookup('file', artifacts + '/test.log') }}" - - name: Check for FAIL on test.log on test environment - fail: msg="Could not find expected text on test log" - when: > - (test_log.find('/bin/false: FAIL') == -1) or - (test_log.find('/bin/true: PASS') == -1) - # We should fail when we can not find FAIL string on log - # -1 means string not found diff --git a/tests/basic.yml b/tests/basic.yml deleted file mode 100644 index 8233a04..0000000 --- a/tests/basic.yml +++ /dev/null @@ -1,38 +0,0 @@ -- import_playbook: prepare.yml - -# Tests for basic role -- hosts: localhost - tags: - - atomic - - classic - - container - roles: - - role: standard-test-basic - tests: - - test-basic-simple - - test-basic-parameters: - dir: ./ - run: echo "check parameters on basic role" | grep "check parameters on basic role" - required_packages: - # Test if we can install required packages - - "{{req_pkg}}" - tasks: - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml - -# Make sure the role behaves correctly if test fails -- hosts: localhost - tags: - - atomic - - classic - - container - roles: - - role: standard-test-basic - tests: - - test-basic-fail - ignore_errors: yes - tasks: - # 'verify_failed_test' tasks should run after 'test-basic-fail' - - import_tasks: shared-tasks/verify_failed_test.yml - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml diff --git a/tests/beakerlib.yml b/tests/beakerlib.yml deleted file mode 100644 index 5f84bda..0000000 --- a/tests/beakerlib.yml +++ /dev/null @@ -1,35 +0,0 @@ -- import_playbook: prepare.yml - -# Tests for beakerlib role -- hosts: localhost - tags: - - atomic - - classic - - container - roles: - - role: standard-test-beakerlib - tests: - - test-beakerlib-simple - required_packages: - - "{{req_pkg}}" - tasks: - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml - - -# Make sure the role behaves correctly if test fails -- hosts: localhost - tags: - - atomic - - classic - - container - roles: - - role: standard-test-beakerlib - tests: - - test-beakerlib-fail - ignore_errors: yes - tasks: - # 'tests_verify_failed_test' tasks should run after 'test-beakerlib-fail' - - import_tasks: shared-tasks/verify_failed_test.yml - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml diff --git a/tests/inventory.yml b/tests/inventory.yml deleted file mode 100644 index 9cd725d..0000000 --- a/tests/inventory.yml +++ /dev/null @@ -1,14 +0,0 @@ -- hosts: localhost - tags: - - always - tasks: - - name: Get inventory with empty input - command: merge-standard-inventory - environment: - # Reset vars to default values - TEST_SUBJECTS: - register: inventory - delegate_to: localhost - - name: Assert merge-standard-inventory produces correct JSON inventory (empty) - fail: - when: inventory.stdout != '{}' diff --git a/tests/prepare.yml b/tests/prepare.yml deleted file mode 100644 index 4cc4cce..0000000 --- a/tests/prepare.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Preparation steps -- hosts: localhost - vars: - # Must be the same as in str-common/defaults/main.yml - artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" - remote_artifacts: /tmp/artifacts/ - tasks: - - import_tasks: shared-tasks/artifacts.yml - tags: - - always - - import_tasks: shared-tasks/req-pkg.yml - tags: - - always diff --git a/tests/rhts.yml b/tests/rhts.yml deleted file mode 100644 index d9b2ea8..0000000 --- a/tests/rhts.yml +++ /dev/null @@ -1,33 +0,0 @@ -- import_playbook: prepare.yml - -# Tests for rhts role only runs on classic tag -- hosts: localhost - tags: - - classic - roles: - - role: standard-test-rhts - tests: - - test-rhts-simple - required_packages: - # Test if we can install required packages - - "{{req_pkg}}" - tasks: - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml - -# Make sure the role behaves correctly if test fails -- hosts: localhost - tags: - - classic - roles: - - role: standard-test-rhts - tags: - - classic - tests: - - test-rhts-fail - ignore_errors: yes - tasks: - # 'verify_failed_test' tasks should run after 'testi-rhts-fail' - - import_tasks: shared-tasks/verify_failed_test.yml - - import_tasks: shared-tasks/artifacts_test_env.yml - - import_tasks: shared-tasks/artifacts_test_runner.yml diff --git a/tests/shared-tasks/artifacts.yml b/tests/shared-tasks/artifacts.yml deleted file mode 100644 index 2c51da3..0000000 --- a/tests/shared-tasks/artifacts.yml +++ /dev/null @@ -1,9 +0,0 @@ -# STR requires that artifacts dir must be absent -- name: "Check if {{artifacts}} is absent at test-environment." - stat: - path: "{{remote_artifacts}}" - register: st_te - -- fail: - msg: "Remove {{remote_artifacts}} before test run at test-environment." - when: st_te.stat.exists diff --git a/tests/shared-tasks/artifacts_test_env.yml b/tests/shared-tasks/artifacts_test_env.yml deleted file mode 100644 index 4d8ae88..0000000 --- a/tests/shared-tasks/artifacts_test_env.yml +++ /dev/null @@ -1,9 +0,0 @@ -# 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/shared-tasks/artifacts_test_runner.yml b/tests/shared-tasks/artifacts_test_runner.yml deleted file mode 100644 index 85b59d8..0000000 --- a/tests/shared-tasks/artifacts_test_runner.yml +++ /dev/null @@ -1,10 +0,0 @@ -# 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/shared-tasks/req-pkg.yml b/tests/shared-tasks/req-pkg.yml deleted file mode 100644 index d871f41..0000000 --- a/tests/shared-tasks/req-pkg.yml +++ /dev/null @@ -1,12 +0,0 @@ -- import_role: - name: str-common-pkgs - tasks_from: inspect.yml - -- set_fact: - req_pkg: zsh - -- name: Remove a test package from test-environment - package: - name: "{{req_pkg}}" - state: absent - when: not is_atomic diff --git a/tests/shared-tasks/verify_failed_test.yml b/tests/shared-tasks/verify_failed_test.yml deleted file mode 100644 index a51af94..0000000 --- a/tests/shared-tasks/verify_failed_test.yml +++ /dev/null @@ -1,11 +0,0 @@ -# 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/test-basic-fail/runtest.sh b/tests/test-basic-fail/runtest.sh deleted file mode 100644 index a7f2a1c..0000000 --- a/tests/test-basic-fail/runtest.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -echo "Running a command that should fail" - -false - diff --git a/tests/test-basic-simple/runtest.sh b/tests/test-basic-simple/runtest.sh deleted file mode 100644 index 87c587b..0000000 --- a/tests/test-basic-simple/runtest.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -PACKAGE="bash" - -echo "Using $PACKAGE version:" -rpm -q $PACKAGE diff --git a/tests/test-beakerlib-fail/runtest.sh b/tests/test-beakerlib-fail/runtest.sh deleted file mode 100644 index f1e63f7..0000000 --- a/tests/test-beakerlib-fail/runtest.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="bash" - -rlJournalStart - rlPhaseStartTest "Simple beakerlib test" - # Running a command that should fail - rlRun "false" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/test-beakerlib-simple/runtest.sh b/tests/test-beakerlib-simple/runtest.sh deleted file mode 100644 index fb77e47..0000000 --- a/tests/test-beakerlib-simple/runtest.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="bash" - -rlJournalStart - rlPhaseStartTest "Simple beakerlib test" - rlRun "ls /" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/test-rhts-fail/Makefile b/tests/test-rhts-fail/Makefile deleted file mode 100644 index 9ae494f..0000000 --- a/tests/test-rhts-fail/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -export TESTVERSION=1.0 - -BUILT_FILES= - -FILES=$(METADATA) runtest.sh Makefile - -.PHONY: all install clean - -run: $(FILES) build - ./runtest.sh - -build: $(BUILT_FILES) - test -x runtest.sh || chmod a+x runtest.sh - -clean: - rm -f *~ $(BUILT_FILES) - - -include /usr/share/rhts/lib/rhts-make.include - -$(METADATA): Makefile - @echo "Owner: Bruno Goncalves " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "Description: fail rhts test role" >> $(METADATA) - @echo "Type: Sanity" >> $(METADATA) - @echo "TestTime: 10m" >> $(METADATA) - @echo "Priority: Normal" >> $(METADATA) - @echo "License: GPLv2" >> $(METADATA) - @echo "Confidential: no" >> $(METADATA) - @echo "Destructive: no" >> $(METADATA) - - rhts-lint $(METADATA) diff --git a/tests/test-rhts-fail/runtest.sh b/tests/test-rhts-fail/runtest.sh deleted file mode 100644 index f1e63f7..0000000 --- a/tests/test-rhts-fail/runtest.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="bash" - -rlJournalStart - rlPhaseStartTest "Simple beakerlib test" - # Running a command that should fail - rlRun "false" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/test-rhts-simple/Makefile b/tests/test-rhts-simple/Makefile deleted file mode 100644 index eb0d996..0000000 --- a/tests/test-rhts-simple/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -export TESTVERSION=1.0 - -BUILT_FILES= - -FILES=$(METADATA) runtest.sh Makefile - -.PHONY: all install clean - -run: $(FILES) build - ./runtest.sh - -build: $(BUILT_FILES) - test -x runtest.sh || chmod a+x runtest.sh - -clean: - rm -f *~ $(BUILT_FILES) - - -include /usr/share/rhts/lib/rhts-make.include - -$(METADATA): Makefile - @echo "Owner: Bruno Goncalves " > $(METADATA) - @echo "Name: $(TEST)" >> $(METADATA) - @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) - @echo "Path: $(TEST_DIR)" >> $(METADATA) - @echo "Description: simple rhts test role" >> $(METADATA) - @echo "Type: Sanity" >> $(METADATA) - @echo "TestTime: 10m" >> $(METADATA) - @echo "Priority: Normal" >> $(METADATA) - @echo "License: GPLv2" >> $(METADATA) - @echo "Confidential: no" >> $(METADATA) - @echo "Destructive: no" >> $(METADATA) - - rhts-lint $(METADATA) diff --git a/tests/test-rhts-simple/runtest.sh b/tests/test-rhts-simple/runtest.sh deleted file mode 100644 index fb77e47..0000000 --- a/tests/test-rhts-simple/runtest.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# Include Beaker environment -. /usr/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGE="bash" - -rlJournalStart - rlPhaseStartTest "Simple beakerlib test" - rlRun "ls /" - rlPhaseEnd -rlJournalPrintText -rlJournalEnd diff --git a/tests/tests.yml b/tests/tests.yml index 6e1486b..dc7d665 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -1,5 +1,18 @@ ---- -- import_playbook: inventory.yml -- import_playbook: basic.yml -- import_playbook: beakerlib.yml -- import_playbook: avocado.yml +- hosts: localhost + roles: + - role: standard-test-beakerlib + tags: + - classic + repositories: + - repo: "https://pagure.io/standard-test-roles.git" + dest: "str" + version: "2.17" + tests: + - str/tests/test-basic-fail + - str/tests/test-basic-simple + - str/tests/test-beakerlib-fail + - str/tests/test-beakerlib-simple + - str/tests/test-rhts-fail + - str/tests/test-rhts-simple + tasks: + - include_tasks: str/tests/inventory-tasks.yml