diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:18:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:18:34 +0000 |
commit | 3667197efb7b18ec842efd504785965911f8ac4b (patch) | |
tree | 0b986a4bc6879d080b100666a97cdabbc9ca1f28 /ansible_collections/community/grafana/tests/integration | |
parent | Adding upstream version 9.5.1+dfsg. (diff) | |
download | ansible-upstream/10.0.0+dfsg.tar.xz ansible-upstream/10.0.0+dfsg.zip |
Adding upstream version 10.0.0+dfsg.upstream/10.0.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/grafana/tests/integration')
6 files changed, 132 insertions, 1 deletions
diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml index ff05b93f5..be5873574 100644 --- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/elastic.yml @@ -286,6 +286,32 @@ - result.datasource.secureJsonFields.secureTest == true - result.diff.after.secureJsonData is defined +- name: Delete elasticsearch legacy datasource + register: result + community.grafana.grafana_datasource: + name: datasource/elasticLegacy + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + state: absent + +- ansible.builtin.assert: + that: + - result.changed + +- name: Delete elasticsearch legacy datasource (idempotency) + register: result + community.grafana.grafana_datasource: + name: datasource/elasticLegacy + grafana_url: "{{ grafana_url }}" + grafana_user: "{{ grafana_username }}" + grafana_password: "{{ grafana_password }}" + state: absent + +- ansible.builtin.assert: + that: + - not result.changed + - name: Delete elasticsearch datasource register: result community.grafana.grafana_datasource: diff --git a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml index b07bc752b..8945e2bdd 100644 --- a/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml +++ b/ansible_collections/community/grafana/tests/integration/targets/grafana_datasource/tasks/postgres.yml @@ -56,7 +56,7 @@ - result.datasource.jsonData.timescaledb == true - result.datasource.name == 'datasource-postgres' - result.datasource.orgId == 1 - - result.datasource.type == 'postgres' + - result.datasource.type in ['postgres', 'grafana-postgresql-datasource'] - result.datasource.url == 'postgres.company.com:5432' - result.datasource.user == 'postgres' - result.datasource.withCredentials == false 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 |