Skip to content

Commit

Permalink
Enable extended integration tests, using a hack.
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-checkmk committed Feb 16, 2024
1 parent 160f068 commit d46ce0a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
12 changes: 8 additions & 4 deletions tests/integration/files/includes/vars/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ checkmk_server_edition_mapping:
cce: cloud
cme: managed

ansible_lookup_checkmk_server_url: "{{ checkmk_var_server_url }}"
ansible_lookup_checkmk_site: "{{ outer_item.site }}"
ansible_lookup_checkmk_automation_user: "{{ checkmk_var_automation_user }}"
ansible_lookup_checkmk_automation_secret: "{{ checkmk_var_automation_secret }}"

# This is a very hacky workaround, as it is not possible to assign variables
# to other variables when using them in lookup modules.
ansible_lookup_checkmk_server_url: "http://127.0.0.1"
ansible_lookup_checkmk_site: "stable_cee" # This is especially hacky.
# All integration tests were adapted to run the specific task only on this site.
ansible_lookup_checkmk_automation_user: "cmkadmin"
ansible_lookup_checkmk_automation_secret: "Sup3rSec4et!"
ansible_lookup_checkmk_validate_certs: false
18 changes: 7 additions & 11 deletions tests/integration/targets/lookup_bakery/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@
("'exception' in looked_up_bakery.msg")

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call."
ansible.builtin.debug:
msg: "Bakery status is {{ bakery }}"
ansible.builtin.assert:
that: ("'finished' in bakery.msg") or
("'running' in bakery.msg") or
("'initialized' in bakery.msg") or
("'stopped' in bakery.msg") or
("'exception' in bakery.msg")
vars:
bakery: "{{ lookup('checkmk.general.bakery') }}"
delegate_to: localhost
register: looked_up_bakery

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify bakery status."
ansible.builtin.assert:
that: ("'finished' in looked_up_bakery.msg") or
("'running' in looked_up_bakery.msg") or
("'initialized' in looked_up_bakery.msg") or
("'stopped' in looked_up_bakery.msg") or
("'exception' in looked_up_bakery.msg")
when: outer_item.edition == "stable_cee"
1 change: 1 addition & 0 deletions tests/integration/targets/lookup_folder/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@
extensions: "{{ lookup('checkmk.general.folder', checkmk_folder.path) }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
when: outer_item.edition == "stable_cee"
3 changes: 2 additions & 1 deletion tests/integration/targets/lookup_folders/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@
delegate_to: localhost
run_once: true # noqa run-once[task]

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify number of folders."
- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call."
ansible.builtin.assert:
# The looked up list contains the main folder, as well.
that: "( 1 + checkmk_var_folders|length ) == folders|length"
vars:
folders: "{{ lookup('checkmk.general.folders', '/', recursive=True) }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
when: outer_item.edition == "stable_cee"
1 change: 1 addition & 0 deletions tests/integration/targets/lookup_host/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@
extensions: "{{ lookup('checkmk.general.host', checkmk_host.name) }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
when: outer_item.edition == "stable_cee"
1 change: 1 addition & 0 deletions tests/integration/targets/lookup_hosts/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@
folders: "{{ lookup('checkmk.general.hosts') }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
when: outer_item.edition == "stable_cee"
2 changes: 2 additions & 0 deletions tests/integration/targets/lookup_rules/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ cpu_load_ruleset.rules }}"
when: outer_item.edition == "stable_cee"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rules."
ansible.builtin.assert:
Expand All @@ -113,3 +114,4 @@
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_rulesets }}"
when: outer_item.edition == "stable_cee"
2 changes: 2 additions & 0 deletions tests/integration/targets/lookup_rulesets/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_ruleset_regexes }}"
when: outer_item.edition == "stable_cee"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Use variables outside the module call: rulesets."
ansible.builtin.debug:
Expand All @@ -98,3 +99,4 @@
rulesets: "{{ lookup('checkmk.general.rulesets', regex='file', rulesets_used=False, rulesets_deprecated=False) }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
when: outer_item.edition == "stable_cee"
1 change: 1 addition & 0 deletions tests/integration/targets/lookup_version/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
version: "{{ lookup('checkmk.general.version') }}"
delegate_to: localhost
register: looked_up_version
when: outer_item.edition == "stable_cee"

0 comments on commit d46ce0a

Please sign in to comment.