-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
75 additions
and
63 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
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,6 +1,3 @@ | ||
[defaults] | ||
callback_plugins=../ | ||
|
||
[loki] | ||
url=http://localhost:3100/loki/api/v1/push | ||
default_tags=run:test |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
- hosts: 127.0.0.1 | ||
gather_facts: false | ||
connection: local | ||
name: "Checking results" | ||
tasks: | ||
- name: "Fetching number of recorded logs" | ||
uri: | ||
url: http://localhost:3100/loki/api/v1/query_range?query={{ '{run="test"}' | urlencode }} | ||
body_format: json | ||
register: logs | ||
- name: tmp1 | ||
ansible.builtin.debug: | ||
var: expected_records | ||
- name: tmp2 | ||
ansible.builtin.debug: | ||
var: logs.json.data.result | length | ||
- fail: | ||
msg: "Invalid number of records" | ||
when: logs.json.data.result | length != expected_records | int |
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,9 @@ | ||
- hosts: 127.0.0.1 | ||
gather_facts: false | ||
connection: local | ||
name: Stop Loki | ||
tasks: | ||
- name: Stop Loki container | ||
docker_container: | ||
name: "ansible-loki-callback-test" | ||
state: stopped |
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,21 @@ | ||
- hosts: 127.0.0.1 | ||
gather_facts: false | ||
connection: local | ||
name: Start Loki | ||
tasks: | ||
- name: Start Loki container | ||
docker_container: | ||
image: "grafana/loki:3.0.1" | ||
name: "ansible-loki-callback-test" | ||
auto_remove: true | ||
published_ports: | ||
- "3100:3100" | ||
state: started | ||
register: loki_container | ||
- name: Wait for Loki to be ready | ||
uri: | ||
url: "http://localhost:3100/ready" | ||
register: _result | ||
until: _result.status == 200 | ||
retries: 100 | ||
delay: 5 |
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,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
function run() { | ||
if ! LOG=$("$@" 2>&1); then | ||
STATUS=$? | ||
echo "$LOG" | ||
exit $STATUS | ||
fi | ||
} | ||
|
||
echo "Running default test" | ||
run python -m ansible.cli.playbook playbook_prepare.yaml | ||
ANSIBLE_CALLBACK_PLUGINS=.. run python -m ansible.cli.playbook default/playbook.yaml -i default/inventory.yaml -vvv | ||
run python -m ansible.cli.playbook playbook_check.yaml -e expected_records=20 -vvv | ||
run python -m ansible.cli.playbook playbook_cleanup.yaml | ||
|
||
# Check with dumps | ||
echo "Running dump test" | ||
run python -m ansible.cli.playbook playbook_prepare.yaml | ||
LOKI_ENABLED_DUMPS=task ANSIBLE_CALLBACK_PLUGINS=.. run python -m ansible.cli.playbook default/playbook.yaml -i default/inventory.yaml -vvv | ||
run python -m ansible.cli.playbook playbook_check.yaml -e expected_records=26 -vvv | ||
run python -m ansible.cli.playbook playbook_cleanup.yaml |