Skip to content

Commit

Permalink
test: duration integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemental committed Jul 4, 2024
1 parent 2d78bdd commit 598da04
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- "result.changed == true"
- "result.failed == false"
- "result.silence.id != ''"

- name: Check idempotency on silence creation
community.grafana.grafana_silence:
comment: "a testcomment"
Expand All @@ -41,7 +41,7 @@
that:
- "result.changed == false"
- "result.msg != ''"

- name: Delete the silence
community.grafana.grafana_silence:
comment: "a testcomment"
Expand All @@ -61,7 +61,7 @@
- "result.failed == false"
- "result.silence.id != ''"
- - "result.silence.createdBy != 'me'"

- name: Check idempotency on silence deletion
community.grafana.grafana_silence:
comment: "a testcomment"
Expand Down
83 changes: 83 additions & 0 deletions tests/integration/targets/grafana_silence/tasks/duration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
- module_defaults:
community.grafana.grafana_silence:
url: "{{ grafana_url }}"
url_username: "{{ grafana_username }}"
url_password: "{{ grafana_password }}"
block:
- name: Create new silence
community.grafana.grafana_silence:
comment: "a testcomment"
created_by: "me"
starts_at: "2029-07-29T08:45:45.000Z"
duration: "PT17D21H256M387S"
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:
comment: "a testcomment"
created_by: "me"
starts_at: "2029-07-29T08:45:45.000Z"
duration: "PT17D21H256M387S"
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:
comment: "a testcomment"
created_by: "me"
starts_at: "2029-07-29T08:45:45.000Z"
duration: "PT17D21H256M387S"
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:
comment: "a testcomment"
created_by: "me"
starts_at: "2029-07-29T08:45:45.000Z"
duration: "PT17D21H256M387S"
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'"
9 changes: 5 additions & 4 deletions tests/integration/targets/grafana_silence/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: Silence creation and deletion
ansible.builtin.include_tasks: create-delete.yml

- name: Silence creation and deletion for organization
ansible.builtin.include_tasks: org.yml
ansible.builtin.include_tasks: "{{ item ~ '.yml' }}"
loop:
- create-delete
- org
- duration

0 comments on commit 598da04

Please sign in to comment.