-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Lathrop
committed
May 7, 2024
1 parent
9b92deb
commit b054f20
Showing
5 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/test_zabbix_discoveryrule/meta/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- setup_zabbix |
29 changes: 29 additions & 0 deletions
29
tests/integration/targets/test_zabbix_discoveryrule/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: test - do not run tests for Zabbix < 6.4 | ||
meta: end_play | ||
when: zabbix_version is version('6.4', '<') | ||
|
||
- block: | ||
# setup stuff | ||
- include_tasks: zabbix_setup.yml | ||
|
||
# zabbix_item module tests | ||
- include_tasks: zabbix_tests.yml | ||
|
||
# tear down stuff set up earlier | ||
- include_tasks: zabbix_teardown.yml | ||
|
||
always: | ||
- name: "cleanup discoveryrule if tests failed" | ||
community.zabbix.zabbix_discoveryrule: | ||
host_name: ExampleHost | ||
name: ExampleRule | ||
state: absent | ||
ignore_errors: true | ||
|
||
- name: "cleanup discoveryrule if tests failed" | ||
community.zabbix.zabbix_discoveryrule: | ||
template_name: ExampleTemplate | ||
name: ExampleRule | ||
state: absent | ||
ignore_errors: true |
25 changes: 25 additions & 0 deletions
25
tests/integration/targets/test_zabbix_discoveryrule/tasks/zabbix_setup.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
|
||
- name: Create test template | ||
community.zabbix.zabbix_template: | ||
template_name: ExampleTemplate | ||
template_groups: | ||
- Templates | ||
|
||
- name: Create test host | ||
community.zabbix.zabbix_host: | ||
host_name: ExampleHost | ||
host_groups: | ||
- Linux servers | ||
- Zabbix servers | ||
link_templates: | ||
- ExampleTemplate | ||
status: enabled | ||
state: present | ||
interfaces: | ||
- type: 1 | ||
main: 1 | ||
useip: 1 | ||
ip: 10.1.1.1 | ||
dns: "" | ||
port: "10050" |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/test_zabbix_discoveryrule/tasks/zabbix_teardown.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- name: remove test host | ||
community.zabbix.zabbix_host: | ||
host_name: ExampleHost | ||
state: absent | ||
|
||
- name: remove test template | ||
community.zabbix.zabbix_template: | ||
template_name: ExampleTemplate | ||
state: absent |
147 changes: 147 additions & 0 deletions
147
tests/integration/targets/test_zabbix_discoveryrule/tasks/zabbix_tests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
--- | ||
|
||
- name: test - create new Zabbix discoveryrule on host with many options set | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
host_name: ExampleHost | ||
params: | ||
type: zabbix_agent_active | ||
key: 'vfs.fs.discovery' | ||
interval: 1m | ||
enabled: True | ||
tags: | ||
- tag: tag | ||
value: value | ||
state: present | ||
register: zbxhostrule_new | ||
|
||
- name: assert that rule was created | ||
ansible.builtin.assert: | ||
that: zbxhostrule_new is changed | ||
|
||
- name: test - create same Zabbix discoveryrule once again | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
host_name: ExampleHost | ||
params: | ||
type: zabbix_agent_active | ||
key: 'vfs.fs.discovery' | ||
interval: 1m | ||
enabled: True | ||
tags: | ||
- tag: tag | ||
value: value | ||
state: present | ||
register: zbxhostrule_existing | ||
|
||
- name: assert that nothing has been changed | ||
ansible.builtin.assert: | ||
that: not zbxhostrule_existing is changed | ||
|
||
- name: test - update existing zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
host_name: ExampleHost | ||
params: | ||
interval: 2m | ||
state: present | ||
register: zbxhostrule_changed | ||
|
||
- name: expect to succeed and that things changed | ||
ansible.builtin.assert: | ||
that: zbxhostrule_changed is changed | ||
|
||
- name: test - attempt to delete previously created zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
host_name: ExampleHost | ||
state: absent | ||
register: zbxhostrule_existing_delete | ||
|
||
- name: assert that trigger was deleted | ||
ansible.builtin.assert: | ||
that: zbxhostrule_existing_delete is changed | ||
|
||
- name: test - attempt to delete non-existing zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
host_name: ExampleHost | ||
state: absent | ||
register: zbxhostrule_missing_delete | ||
|
||
- name: assert that nothing has been changed | ||
ansible.builtin.assert: | ||
that: not zbxhostrule_missing_delete is changed | ||
|
||
- name: test - create new Zabbix discoveryrule on template with many options set | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
template_name: ExampleTemplate | ||
params: | ||
type: zabbix_agent_active | ||
key: 'vfs.fs.discovery' | ||
interval: 1m | ||
enabled: True | ||
tags: | ||
- tag: tag | ||
value: value | ||
state: present | ||
register: zbxtemprule_new | ||
|
||
- name: assert that rule was created | ||
ansible.builtin.assert: | ||
that: zbxtemprule_new is changed | ||
|
||
- name: test - create same Zabbix discoveryrule once again | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
template_name: ExampleTemplate | ||
params: | ||
type: zabbix_agent_active | ||
key: 'vfs.fs.discovery' | ||
interval: 1m | ||
enabled: True | ||
tags: | ||
- tag: tag | ||
value: value | ||
state: present | ||
register: zbxtemprule_existing | ||
|
||
- name: assert that nothing has been changed | ||
ansible.builtin.assert: | ||
that: not zbxtemprule_existing is changed | ||
|
||
- name: test - update existing zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
template_name: ExampleTemplate | ||
params: | ||
interval: 2m | ||
state: present | ||
register: zbxtemprule_changed | ||
|
||
- name: expect to succeed and that things changed | ||
ansible.builtin.assert: | ||
that: zbxtemprule_changed is changed | ||
|
||
- name: test - attempt to delete previously created zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
template_name: ExampleTemplate | ||
state: absent | ||
register: zbxtemprule_existing_delete | ||
|
||
- name: assert that trigger was deleted | ||
ansible.builtin.assert: | ||
that: zbxtemprule_existing_delete is changed | ||
|
||
- name: test - attempt to delete non-existing zabbix discoveryrule | ||
community.zabbix.zabbix_discoveryrule: | ||
name: TestRule | ||
template_name: ExampleTemplate | ||
state: absent | ||
register: zbxtemprule_missing_delete | ||
|
||
- name: assert that nothing has been changed | ||
ansible.builtin.assert: | ||
that: not zbxtemprule_missing_delete is changed |