Skip to content

Commit

Permalink
check if task should have failed when actually skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Mar 6, 2023
1 parent dc2e77f commit f6a1a29
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugins/callback/monkeyble_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def v2_runner_on_failed(self, result, *args, **kwargs):
def v2_runner_on_skipped(self, result, **kwargs):
self._display.debug("Run v2_runner_on_skipped")
self.check_if_task_should_have_been_skipped(task_has_been_actually_skipped=True)
self.check_if_task_should_have_failed(task_has_actually_failed=False)

def test_output(self, result_dict):

Expand Down
5 changes: 3 additions & 2 deletions tests/ansible_test/run_ansible_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ function assert_playbook_fail () {
-e "@${VARS_PATH}" \
-e "monkeyble_scenario=$scenario"
then
printf "${RED}Monkeyble scenario '$scenario' has not failed as expected${NC}\n"
printf "${RED} Monkeyble scenario '$scenario' has not failed as expected${NC}\n"
exit 1
else
printf "✔️${GREEN}Monkeyble check fail success${NC}\n"
printf "✔️${GREEN} Monkeyble check fail success${NC}\n"
fi
echo "###########################"
done
Expand Down Expand Up @@ -71,6 +71,7 @@ LIST_SCENARIO=(
"should_not_be_skipped"
"should_fail"
"should_not_failed"
skipped_but_should_have_failed
)
PLAYBOOK_PATH="test_task_state/playbook.yml"
VARS_PATH="test_task_state/test_state_failed/vars.yml"
Expand Down
6 changes: 6 additions & 0 deletions tests/ansible_test/test_task_state/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@
debug:
msg: "destroy the death star"
ignore_errors: true

- when: var_false
name: "skipped_but_should_have_failed"
fail:
msg: "save Palpatine"
ignore_errors: true
5 changes: 5 additions & 0 deletions tests/ansible_test/test_task_state/test_state_failed/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ monkeyble_scenarios:
tasks_to_test:
- task: "should_not_failed"
should_fail: true

skipped_but_should_have_failed:
task_to_tests:
- task: "skipped_but_should_have_failed"
should_fail: true

0 comments on commit f6a1a29

Please sign in to comment.