diff options
Diffstat (limited to 'ansible_collections/community/grafana/tests/integration/targets/grafana_silence')
4 files changed, 105 insertions, 0 deletions
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/defaults/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/defaults/main.yml new file mode 100644 index 000000000..4abf9bb43 --- /dev/null +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/defaults/main.yml @@ -0,0 +1,5 @@ +--- + +grafana_url: http://grafana:3000/ +grafana_username: admin +grafana_password: admin diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/runme.sh b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/runme.sh new file mode 100755 index 000000000..867afb0d3 --- /dev/null +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/site.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/site.yml new file mode 100644 index 000000000..791582277 --- /dev/null +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_silence + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_silence diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/tasks/main.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/tasks/main.yml new file mode 100644 index 000000000..ad4cfa25d --- /dev/null +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_silence/tasks/main.yml @@ -0,0 +1,89 @@ +--- +- name: Create new silence + community.grafana.grafana_silence: + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + comment: "a testcomment" + created_by: "me" + starts_at: "2029-07-29T08:45:45.000Z" + ends_at: "2029-07-29T08:55:45.000Z" + matchers: + - isEqual: true + isRegex: true + name: environment + value: test + state: present + register: result +- assert: + that: + - "result.changed == true" + - "result.failed == false" + - "result.silence.id != ''" + +- name: Check idempotency on silence creation + community.grafana.grafana_silence: + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + comment: "a testcomment" + created_by: "me" + starts_at: "2029-07-29T08:45:45.000Z" + ends_at: "2029-07-29T08:55:45.000Z" + matchers: + - isEqual: true + isRegex: true + name: environment + value: test + state: present + register: result +- assert: + that: + - "result.changed == false" + - "result.msg != ''" + +- name: Delete the silence + community.grafana.grafana_silence: + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + comment: "a testcomment" + created_by: "me" + starts_at: "2029-07-29T08:45:45.000Z" + ends_at: "2029-07-29T08:55:45.000Z" + matchers: + - isEqual: true + isRegex: true + name: environment + value: test + state: absent + register: result +- assert: + that: + - "result.changed == true" + - "result.failed == false" + - "result.silence.id != ''" + - - "result.silence.createdBy != 'me'" + +- name: Check idempotency on silence deletion + community.grafana.grafana_silence: + url: "{{ grafana_url }}" + url_username: "{{ grafana_username }}" + url_password: "{{ grafana_password }}" + comment: "a testcomment" + created_by: "me" + starts_at: "2029-07-29T08:45:45.000Z" + ends_at: "2029-07-29T08:55:45.000Z" + matchers: + - isEqual: true + isRegex: true + name: environment + value: test + state: absent + register: result + ignore_errors: yes +- assert: + that: + - "result.changed == false" + - "result.failed == false" + - "result.msg == 'Silence does not exist'"
\ No newline at end of file |