blob: 469323e34ca077bba5697452f38716f4cae5e2a0 [file] [log] [blame]
Oleksii Zhurba1f17f6c2017-10-31 18:41:03 +00001import requests
2import csv
3import json
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05004import pytest
Oleksii Zhurba1f17f6c2017-10-31 18:41:03 +00005
6
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05007@pytest.mark.full
8#probably in sl
Hanna Arhipova50a21672019-04-25 12:20:52 +03009def test_oss_status(local_salt_client, check_cicd):
10 """
11 # Get IP of HAPROXY interface from pillar using 'salt -C "I@docker:swarm:role:master" pillar.get haproxy:proxy:listen:stats:binds:address'
12 # Read info from web-page "http://{haproxy:proxy:listen:stats:binds:address}:9600/haproxy?stats;csv"
13 # Check that each service from list 'aptly', 'openldap', 'gerrit', 'jenkins', 'postgresql',
14 'pushkin', 'rundeck', 'elasticsearch' :
15 * has UP status
16 * has OPEN status
17 """
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050018 HAPROXY_STATS_IP = local_salt_client.pillar_get(
19 tgt='docker:swarm:role:master',
20 param='haproxy:proxy:listen:stats:binds:address')
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050021 proxies = {"http": None, "https": None}
Oleksii Zhurba1f17f6c2017-10-31 18:41:03 +000022 csv_result = requests.get('http://{}:9600/haproxy?stats;csv"'.format(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050023 HAPROXY_STATS_IP),
Oleksii Zhurbae592ed12018-06-21 18:01:09 -050024 proxies=proxies).content
Oleksii Zhurba1f17f6c2017-10-31 18:41:03 +000025 data = csv_result.lstrip('# ')
26 wrong_data = []
27 list_of_services = ['aptly', 'openldap', 'gerrit', 'jenkins', 'postgresql',
28 'pushkin', 'rundeck', 'elasticsearch']
29 for service in list_of_services:
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050030 check = local_salt_client.test_ping(tgt='{}:client'.format(service))
Oleksii Zhurba1f17f6c2017-10-31 18:41:03 +000031 if check:
32 lines = [row for row in csv.DictReader(data.splitlines())
33 if service in row['pxname']]
34 for row in lines:
35 info = "Service {0} with svname {1} and status {2}".format(
36 row['pxname'], row['svname'], row['status'])
37 if row['svname'] == 'FRONTEND' and row['status'] != 'OPEN':
38 wrong_data.append(info)
39 if row['svname'] != 'FRONTEND' and row['status'] != 'UP':
40 wrong_data.append(info)
41
42 assert len(wrong_data) == 0, \
43 '''Some haproxy services are in wrong state
44 {}'''.format(json.dumps(wrong_data, indent=4))