-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
147 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
minor_changes: | ||
- Add parameter `org_name` to `grafana_dashboard` | ||
|
||
trivial: | ||
- Add tests for new `grafana_dashboard`-parameter `org_name` | ||
- Refactor tests for `grafana_dashboard` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
tests/integration/targets/grafana_dashboard/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
--- | ||
|
||
grafana_url: "http://grafana:3000/" | ||
grafana_username: "admin" | ||
grafana_password: "admin" | ||
|
||
... |
38 changes: 38 additions & 0 deletions
38
tests/integration/targets/grafana_dashboard/tasks/dashboard-by-org-name.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
- module_defaults: | ||
community.grafana.grafana_dashboard: | ||
org_name: Main Org. | ||
block: | ||
- name: Check import grafana dashboard from file | ||
community.grafana.grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: present | ||
commit_message: Updated by ansible | ||
path: /tmp/dashboard.json | ||
overwrite: true | ||
register: result | ||
- ansible.builtin.assert: | ||
that: | ||
- "result.failed == false" | ||
- "result.changed == true" | ||
- "result.msg == 'Dashboard test created'" | ||
|
||
- name: Check import grafana dashboard from file idempotency | ||
community.grafana.grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: present | ||
commit_message: Updated by ansible | ||
path: /tmp/dashboard.json | ||
overwrite: true | ||
register: result | ||
- ansible.builtin.assert: | ||
that: | ||
- "result.failed == false" | ||
- "result.changed == false" | ||
- "result.msg == 'Dashboard test unchanged.'" | ||
|
||
- ansible.builtin.include_tasks: delete-dashboard.yml |
26 changes: 10 additions & 16 deletions
26
tests/integration/targets/grafana_dashboard/tasks/dashboard-export.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 15 additions & 30 deletions
45
tests/integration/targets/grafana_dashboard/tasks/dashboard-folder-destination.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,18 @@ | ||
--- | ||
- name: copy dashboard file | ||
copy: | ||
src: "files/dashboard.json" | ||
dest: "/tmp/dashboard.json" | ||
|
||
- block: | ||
- name: Check import grafana dashboard from file to unknown folder fails | ||
grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: present | ||
commit_message: Updated by ansible | ||
path: /tmp/dashboard.json | ||
overwrite: true | ||
folder: inexistent | ||
register: result | ||
ignore_errors: true | ||
|
||
- debug: | ||
var: result | ||
|
||
- set_fact: | ||
# XXX: Too many quotes of different types to do inline. | ||
# I did not manage to find a good way of having it inline. | ||
expected_error: "error : Dashboard folder 'inexistent' does not exist." | ||
|
||
- assert: | ||
- name: Check import grafana dashboard from file to unknown folder fails | ||
community.grafana.grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: present | ||
commit_message: Updated by ansible | ||
path: /tmp/dashboard.json | ||
overwrite: true | ||
folder: inexistent | ||
register: result | ||
ignore_errors: true | ||
- ansible.builtin.assert: | ||
that: | ||
- "result.changed == false" | ||
- "result.failed == true" | ||
- "result.msg == expected_error" | ||
- "result.changed == false" | ||
- "result.msg == 'error : Dashboard folder \\'inexistent\\' does not exist.'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
tests/integration/targets/grafana_dashboard/tasks/delete-dashboard.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
- name: Check delete dashboard is working | ||
grafana_dashboard: | ||
--- | ||
- name: Delete dashboard | ||
community.grafana.grafana_dashboard: | ||
grafana_url: "{{ grafana_url }}" | ||
grafana_user: "{{ grafana_username }}" | ||
grafana_password: "{{ grafana_password }}" | ||
state: absent | ||
uid: "{{ result.uid }}" | ||
register: result | ||
|
||
- debug: | ||
var: result | ||
|
||
- assert: | ||
- ansible.builtin.assert: | ||
that: | ||
- "result.failed == false" | ||
- "result.changed == true" | ||
- "result.msg == 'Dashboard {{ result.uid }} deleted'" | ||
- "result.msg == 'Dashboard ' ~ result.uid ~ ' deleted'" |
Oops, something went wrong.