File tree Expand file tree Collapse file tree 7 files changed +75
-63
lines changed Expand file tree Collapse file tree 7 files changed +75
-63
lines changed Original file line number Diff line number Diff line change 27
27
run : |
28
28
python -m pip install --upgrade pip
29
29
pip install -r requirements.txt -r requirements-dev.txt
30
- - name : Run default test
30
+ - name : Run testsuite
31
31
working-directory : test
32
- run : python -m ansible.cli.playbook playbook.yaml -i default/inventory.yaml -e expected_records=21 -vvv
33
- - name : Run dump configuration test
34
- working-directory : test
35
- env :
36
- LOKI_ENABLED_DUMPS : play
37
- run : python -m ansible.cli.playbook playbook.yaml -i default/inventory.yaml -e expected_records=27 -vvv
32
+ run : /usr/bin/env bash test.sh
Original file line number Diff line number Diff line change 1
- [defaults]
2
- callback_plugins =../
3
-
4
1
[loki]
5
2
url =http://localhost:3100/loki/api/v1/push
6
3
default_tags =run:test
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ - hosts : 127.0.0.1
2
+ gather_facts : false
3
+ connection : local
4
+ name : " Checking results"
5
+ tasks :
6
+ - name : " Fetching number of recorded logs"
7
+ uri :
8
+ url : http://localhost:3100/loki/api/v1/query_range?query={{ '{run="test"}' | urlencode }}
9
+ body_format : json
10
+ register : logs
11
+ - name : tmp1
12
+ ansible.builtin.debug :
13
+ var : expected_records
14
+ - name : tmp2
15
+ ansible.builtin.debug :
16
+ var : logs.json.data.result | length
17
+ - fail :
18
+ msg : " Invalid number of records"
19
+ when : logs.json.data.result | length != expected_records | int
Original file line number Diff line number Diff line change
1
+ - hosts : 127.0.0.1
2
+ gather_facts : false
3
+ connection : local
4
+ name : Stop Loki
5
+ tasks :
6
+ - name : Stop Loki container
7
+ docker_container :
8
+ name : " ansible-loki-callback-test"
9
+ state : stopped
Original file line number Diff line number Diff line change
1
+ - hosts : 127.0.0.1
2
+ gather_facts : false
3
+ connection : local
4
+ name : Start Loki
5
+ tasks :
6
+ - name : Start Loki container
7
+ docker_container :
8
+ image : " grafana/loki:3.0.1"
9
+ name : " ansible-loki-callback-test"
10
+ auto_remove : true
11
+ published_ports :
12
+ - " 3100:3100"
13
+ state : started
14
+ register : loki_container
15
+ - name : Wait for Loki to be ready
16
+ uri :
17
+ url : " http://localhost:3100/ready"
18
+ register : _result
19
+ until : _result.status == 200
20
+ retries : 100
21
+ delay : 5
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ function run() {
6
+ if ! LOG=$( " $@ " 2>&1 ) ; then
7
+ STATUS=$?
8
+ echo " $LOG "
9
+ exit $STATUS
10
+ fi
11
+ }
12
+
13
+ echo " Running default test"
14
+ run python -m ansible.cli.playbook playbook_prepare.yaml
15
+ ANSIBLE_CALLBACK_PLUGINS=.. run python -m ansible.cli.playbook default/playbook.yaml -i default/inventory.yaml -vvv
16
+ run python -m ansible.cli.playbook playbook_check.yaml -e expected_records=20 -vvv
17
+ run python -m ansible.cli.playbook playbook_cleanup.yaml
18
+
19
+ # Check with dumps
20
+ echo " Running dump test"
21
+ run python -m ansible.cli.playbook playbook_prepare.yaml
22
+ LOKI_ENABLED_DUMPS=task ANSIBLE_CALLBACK_PLUGINS=.. run python -m ansible.cli.playbook default/playbook.yaml -i default/inventory.yaml -vvv
23
+ run python -m ansible.cli.playbook playbook_check.yaml -e expected_records=26 -vvv
24
+ run python -m ansible.cli.playbook playbook_cleanup.yaml
You can’t perform that action at this time.
0 commit comments