#383 add regression test for handling abort playbook
Merged 3 years ago by astepano. Opened 3 years ago by bgoncalv.
bgoncalv/standard-test-roles tests  into  master

file modified
+33 -3
@@ -1,5 +1,7 @@ 

  #!/bin/sh

  

+ set -x

+ 

  #

  # This invokes the tests using the local inventory and roles rather

  # than what's installed on system. This is aslight deviation from
@@ -8,6 +10,34 @@ 

  

  cd $(dirname $0)/..

  

- rm -rf /tmp/artifacts/ /tmp/local-artifacts/

- TEST_ARTIFACTS=/tmp PATH=$PWD/scripts:$PATH ANSIBLE_INVENTORY=$PWD/inventory \

- 	ansible-playbook --extra-vars=artifacts=/tmp/local-artifacts --tags=classic tests/tests.yml

+ export TEST_ARTIFACTS=/tmp

+ export PATH=$PWD/scripts:$PATH

+ export ANSIBLE_INVENTORY=$PWD/inventory

+ 

+ rm -rf /tmp/artifacts

+ ansible-playbook --tags=classic tests/tests.yml

+ 

+ rm -rf /tmp/artifacts/

+ timeout 2m ansible-playbook --tags=classic tests/test-basic-abort-playbook.yml

+ sleep 2 # sleep few seconds to make sure logs are synced

+ # make sure expected files are created on TEST_ARTIFACTS

+ if [[ ! -f ${TEST_ARTIFACTS}/artifacts/ERROR-str_test-abort-playbook-basic.log ]] || \

+    [[ ! -f ${TEST_ARTIFACTS}/artifacts/test.log ]] || \

+    [[ ! -f ${TEST_ARTIFACTS}/artifacts/results.yml ]]; then

+     ls ${TEST_ARTIFACTS}/artifacts

+     echo "FAIL: Not all expected files were created when playbook aborts on basic role"

+     exit 1

+ fi

+ 

+ rm -rf /tmp/artifacts/

+ timeout 2m ansible-playbook --tags=classic tests/test-beakerlib-abort-playbook.yml

+ sleep 2 # sleep few seconds to make sure logs are synced

+ # make sure expected files are created on TEST_ARTIFACTS

+ if [[ ! -f ${TEST_ARTIFACTS}/artifacts/ERROR-test-beakerlib-abort-playbook-err.log ]] || \

+    [[ ! -f ${TEST_ARTIFACTS}/artifacts/ERROR-test-beakerlib-abort-playbook-err.log ]] || \

+    [[ ! -f ${TEST_ARTIFACTS}/artifacts/test.log ]] || \

+    [[ ! -f ${TEST_ARTIFACTS}/artifacts/results.yml ]]; then

+     ls ${TEST_ARTIFACTS}/artifacts

+     echo "FAIL: Not all expected files were created when playbook aborts on beakerlib role"

+     exit 1

+ fi

@@ -0,0 +1,9 @@ 

+ # Make sure the role report error when playbook aborts

+ - hosts: localhost

+   tags:

+   - classic

+   roles:

+   - role: standard-test-basic

+     tests:

+     - test-abort-playbook-basic:

+         run: sleep 240

@@ -0,0 +1,8 @@ 

+ # Make sure the role report error when playbook aborts

+ - hosts: localhost

+   tags:

+   - classic

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - test-beakerlib-abort-playbook

@@ -0,0 +1,12 @@ 

+ #!/bin/bash

+ # Include Beaker environment

+ . /usr/share/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="bash"

+ 

+ rlJournalStart

+     rlPhaseStartTest "test abort playbook with beakerlib role"

+         rlRun "sleep 240"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd