From 598da04591d356bc29fed448b51494eeb0def58a Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:07:49 +0200 Subject: [PATCH] test: duration integration tests --- .../grafana_silence/tasks/create-delete.yml | 6 +- .../grafana_silence/tasks/duration.yml | 83 +++++++++++++++++++ .../targets/grafana_silence/tasks/main.yml | 9 +- 3 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 tests/integration/targets/grafana_silence/tasks/duration.yml diff --git a/tests/integration/targets/grafana_silence/tasks/create-delete.yml b/tests/integration/targets/grafana_silence/tasks/create-delete.yml index 1561eb59..bd17f9da 100644 --- a/tests/integration/targets/grafana_silence/tasks/create-delete.yml +++ b/tests/integration/targets/grafana_silence/tasks/create-delete.yml @@ -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" @@ -41,7 +41,7 @@ that: - "result.changed == false" - "result.msg != ''" - + - name: Delete the silence community.grafana.grafana_silence: comment: "a testcomment" @@ -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" diff --git a/tests/integration/targets/grafana_silence/tasks/duration.yml b/tests/integration/targets/grafana_silence/tasks/duration.yml new file mode 100644 index 00000000..3770a0a3 --- /dev/null +++ b/tests/integration/targets/grafana_silence/tasks/duration.yml @@ -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'" diff --git a/tests/integration/targets/grafana_silence/tasks/main.yml b/tests/integration/targets/grafana_silence/tasks/main.yml index f8756077..9ab61381 100644 --- a/tests/integration/targets/grafana_silence/tasks/main.yml +++ b/tests/integration/targets/grafana_silence/tasks/main.yml @@ -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