Skip to content

Commit 64f5109

Browse files
authored
Merge pull request #41 from T-Systems-MMS/localtest
make local testing without ansible-test work
2 parents db5342b + 1abcdb9 commit 64f5109

27 files changed

Lines changed: 44 additions & 43 deletions

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ Local Testing
9696

9797
```
9898
# run icinga in a container and forward port 80
99-
> docker run -it -p 80:80 jordan/icinga2
99+
> docker run -d -p 80:80 jordan/icinga2
100100
101-
# run the ansible-playbook against the container
102-
> ansible-playbook tests/integration/test.yml -e icinga_url=http://127.0.0.1/icingaweb2
101+
# run the ansible playbooks against the container
102+
> ansible-playbook tests/integration/targets/icinga/normalmode.yml
103+
> ansible-playbook tests/integration/targets/icinga/checkmode.yml
103104
```
104105

105106
License

hacking/update_examples_and_tests.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ for module in ../plugins/modules/*.py; do
99
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../examples/${module_name}.yml"
1010

1111
# create tests
12-
echo "---" | tee "../tests/integration/targets/icinga/tasks/${module_name}.yml"
13-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/tasks/${module_name}.yml"
12+
echo "---" | tee "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"
13+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"
1414

1515
# create create working tests deleting the hosts
16-
echo "---" | tee "../tests/integration/targets/icinga/tasks/absent_${module_name}.yml"
17-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/tasks/absent_${module_name}.yml"
18-
sed -i 's/state: present/state: absent/g' "../tests/integration/targets/icinga/tasks/absent_${module_name}.yml"
16+
echo "---" | tee "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
17+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
18+
sed -i 's/state: present/state: absent/g' "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
1919

2020
# create failing tests with wrong password
21-
echo "---" | tee "../tests/integration/targets/icinga/tasks/wrong_pass_${module_name}.yml"
22-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/tasks/wrong_pass_${module_name}.yml"
21+
echo "---" | tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
22+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
2323
# replace password variable with wrong password
24-
sed -i 's/{{ icinga_pass }}/iamwrong/g' "../tests/integration/targets/icinga/tasks/wrong_pass_${module_name}.yml"
24+
sed -i 's/{{ icinga_pass }}/iamwrong/g' "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
2525

2626
# add ignore_errors to the creation-task and an assert task that checks for failure
2727
echo -n "
@@ -32,15 +32,15 @@ for module in ../plugins/modules/*.py; do
3232
assert:
3333
that:
3434
- \"result.failed\"
35-
- \"result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized'\" # noqa
36-
" >> "../tests/integration/targets/icinga/tasks/wrong_pass_${module_name}.yml"
35+
- \"result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'\" # noqa
36+
" >> "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
3737

3838
# create failing tests with wrong host
3939
# add test
40-
echo "---" | tee "../tests/integration/targets/icinga/tasks/wrong_host_${module_name}.yml"
41-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/tasks/wrong_host_${module_name}.yml"
40+
echo "---" | tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
41+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}' "${module}" | tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
4242
# replace url varuable with nonexisting url
43-
sed -i 's/{{ icinga_url }}/http:\/\/nonexistant/g' "../tests/integration/targets/icinga/tasks/wrong_host_${module_name}.yml"
43+
sed -i 's/{{ icinga_url }}/http:\/\/nonexistant/g' "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
4444

4545
# add ignore_errors to the creation-task and an assert task that checks for failure
4646
echo -n "
@@ -51,6 +51,6 @@ for module in ../plugins/modules/*.py; do
5151
assert:
5252
that:
5353
- \"result.failed\"
54-
- \"result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'\" # noqa
55-
" >> "../tests/integration/targets/icinga/tasks/wrong_host_${module_name}.yml"
54+
- \"result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'\" # noqa
55+
" >> "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
5656
done

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
assert:
6666
that:
6767
- "result.failed"
68-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
68+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_command_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@
6363
assert:
6464
that:
6565
- "result.failed"
66-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
66+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_host.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
assert:
2626
that:
2727
- "result.failed"
28-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
28+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_host_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
assert:
2222
that:
2323
- "result.failed"
24-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
24+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_hostgroup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
assert:
1717
that:
1818
- "result.failed"
19-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
19+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_notification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
assert:
2525
that:
2626
- "result.failed"
27-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
27+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_service_apply.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
assert:
2828
that:
2929
- "result.failed"
30-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
30+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_icinga_service_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
assert:
2020
that:
2121
- "result.failed"
22-
- "result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>'" # noqa
22+
- "result.msg == 'bad return code while creating: 401. Error message: HTTP Error 401: Unauthorized' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -3] Temporary failure in name resolution>' or result.msg == 'bad return code while creating: -1. Error message: Request failed: <urlopen error [Errno -2] Name or service not known>'" # noqa

0 commit comments

Comments
 (0)