tests.yml 1.45 KB
Newer Older
1
2
3
4
---
- block:
  - name: check if grafana running
    command: pgrep -x grafana-server -c
Aleksey Shirokih's avatar
Aleksey Shirokih committed
5
    failed_when: "False"
EKbfh's avatar
EKbfh committed
6
    changed_when: false
7
    register: grafana_running
Aleksey Shirokih's avatar
Aleksey Shirokih committed
8
    check_mode: "False"
9
10
11
12
13
14
15
16
17
18
19
20
21

  - name: fail if no grafana found
    debug:
      msg: |
        There should be grafana proccess. But `pgrep -x grafana -c` can't find any
    when:
      - grafana_running.rc != 0

  #tests uses static grafana port cause we do not have acces to defaults dir
  - name: check if grafana http iface is reachable
    uri:
      url: http://127.0.0.1:8002/api/health
    register: grafana_ping
Aleksey Shirokih's avatar
Aleksey Shirokih committed
22
23
    failed_when: "False"
    check_mode: "False"
24
25
26
27
28
29
30
31
32
33
34
35

  - name: fail if grafana http iface is not reachable
    debug:
      msg: |
        grafana is not answering ping request.
        Check with `curl http://127.0.0.1:8002/api/health`
    when:
      - grafana_ping.status != 200

  - name: check for consul service status
    uri:
      url: "http://127.0.0.1:8500/v1/health/service/grafana"
Aleksey Shirokih's avatar
Aleksey Shirokih committed
36
      return_content: "True"
37
    register: consul_req
EKbfh's avatar
EKbfh committed
38
    changed_when: false
Aleksey Shirokih's avatar
Aleksey Shirokih committed
39
    check_mode: "False"
40
41
42
43
44

  - name: fail if no grafana found
    debug:
      msg: |
        There are toubles with grafana on
EKbfh's avatar
EKbfh committed
45
        {{ consul_req.json | json_query("[].Checks[?ServiceName=='grafana'].{node:Node, status:Status}[]") | to_nice_yaml }}
46
47
48
49
    when:
      - "'passing' not in consul_req.json | json_query(\"[].Checks[?ServiceName=='grafana'].Status[]\")"

  when:
Aleksey Shirokih's avatar
Aleksey Shirokih committed
50
51
52
    - has_svc_grafana is defined
  tags:
    - tests