Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 1 | import json |
| 2 | import requests |
Oleksii Zhurba | 84ce7fe | 2018-01-16 21:34:01 +0000 | [diff] [blame] | 3 | import datetime |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 4 | import pytest |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 5 | |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 6 | import utils |
| 7 | import logging |
| 8 | |
| 9 | # ################################ FIXTURES ################################## |
| 10 | |
| 11 | |
| 12 | def prometheus_rules(): |
| 13 | salt = utils.init_salt_client() |
| 14 | |
| 15 | IP = salt.pillar_get(param='_param:cluster_public_host') |
| 16 | proto = salt.pillar_get( |
| 17 | param='_param:cluster_public_protocol') |
| 18 | proxies = {"http": None, "https": None} |
| 19 | |
| 20 | prometheus_password = ( |
| 21 | # new password in 2019.2.7 |
| 22 | salt.pillar_get( |
| 23 | tgt="nginx:server", |
| 24 | param='_param:nginx_proxy_prometheus_server_password') |
| 25 | |
| 26 | # Generated password ~2019.2.4 |
| 27 | or salt.pillar_get( |
| 28 | param='_param:prometheus_server_proxy_password_generated') |
| 29 | |
| 30 | # old password ~ 2019.2.0 |
| 31 | or salt.pillar_get( |
| 32 | param='_param:keepalived_prometheus_vip_password_generated') |
Hanna Arhipova | 2b93dfc | 2020-05-20 16:23:57 +0300 | [diff] [blame] | 33 | |
| 34 | or "" |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 35 | ) |
| 36 | |
Hanna Arhipova | 2b93dfc | 2020-05-20 16:23:57 +0300 | [diff] [blame] | 37 | if prometheus_password == "": |
| 38 | logging.warning("Got empty prometheus_password. \ |
| 39 | Possibly this cluster with no Stacklight component") |
| 40 | return dict() |
| 41 | |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 42 | response = requests.get( |
| 43 | '{0}://{1}:15010/api/v1/rules'.format(proto, IP), |
| 44 | proxies=proxies, |
| 45 | auth=('prometheus', prometheus_password), |
| 46 | verify=False) |
| 47 | |
| 48 | if not response.status_code == 200: |
Hanna Arhipova | 2b93dfc | 2020-05-20 16:23:57 +0300 | [diff] [blame] | 49 | logging.warning( |
| 50 | "Got response with incorrect status: {}".format(response)) |
| 51 | return dict() |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 52 | |
| 53 | content = json.loads(response.content.decode()) |
| 54 | rules = content['data']['groups'][0]["rules"] |
| 55 | |
| 56 | # collect rules with dict {'rulename' : {<rulecontent>}} |
| 57 | alerts_by_name = {rule['name']: rule['alerts'] |
| 58 | for rule in rules |
| 59 | } |
| 60 | logging.debug("collected next rules: {}".format(alerts_by_name)) |
| 61 | return alerts_by_name |
| 62 | |
| 63 | |
| 64 | prometheus_rules = prometheus_rules() |
| 65 | |
| 66 | |
Hanna Arhipova | 2b93dfc | 2020-05-20 16:23:57 +0300 | [diff] [blame] | 67 | @pytest.mark.usefixtures('check_prometheus') |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 68 | @pytest.fixture(scope='session', |
| 69 | ids=prometheus_rules.keys(), |
| 70 | params=prometheus_rules.values()) |
| 71 | def alert_in_prometheus(request): |
| 72 | return request.param |
| 73 | |
| 74 | # ############################## TESTS ####################################### |
| 75 | |
| 76 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 77 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 78 | # ElasticsearchClusterHealthStatusMajor or stacklight-pytest |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 79 | @pytest.mark.full |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 80 | @pytest.mark.usefixtures('check_kibana') |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 81 | def test_elasticsearch_cluster(local_salt_client): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 82 | salt_output = local_salt_client.pillar_get( |
| 83 | tgt='kibana:server', |
| 84 | param='_param:haproxy_elasticsearch_bind_host') |
Oleksii Zhurba | 85f55fe | 2019-06-10 17:30:53 -0500 | [diff] [blame] | 85 | ssl = local_salt_client.pillar_get( |
| 86 | tgt='elasticsearch:server', |
| 87 | param='haproxy:proxy:listen:elasticsearch:binds:ssl:enabled') |
| 88 | proto = "https" if ssl else "http" |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 89 | |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 90 | proxies = {"http": None, "https": None} |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 91 | IP = salt_output |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 92 | response = requests.get( |
| 93 | '{0}://{1}:9200/'.format(proto, IP), |
| 94 | proxies=proxies, |
| 95 | verify=False) |
| 96 | assert response.status_code == 200, ( |
| 97 | "Issues with accessing elasticsearch on {}.".format(IP)) |
| 98 | response = requests.get( |
| 99 | '{0}://{1}:9200/_cat/health'.format(proto, IP), |
| 100 | proxies=proxies, |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 101 | verify=False).content.decode() |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 102 | msg = "elasticsearch is not healthy:\n{}".format( |
| 103 | json.dumps(response, indent=4)) |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 104 | assert response.split()[3] == 'green', msg |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 105 | assert response.split()[4] == '3', msg |
| 106 | assert response.split()[5] == '3', msg |
| 107 | assert response.split()[10] == '0', msg |
| 108 | assert response.split()[13] == '100.0%', msg |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 109 | |
| 110 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 111 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 112 | # stacklight-pytest |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 113 | @pytest.mark.full |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 114 | @pytest.mark.usefixtures('check_kibana') |
Ievgeniia Zadorozhna | 511f0ce | 2018-11-08 17:43:10 +0300 | [diff] [blame] | 115 | def test_kibana_status(local_salt_client): |
| 116 | proxies = {"http": None, "https": None} |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 117 | IP = local_salt_client.pillar_get(param='_param:stacklight_log_address') |
Oleksii Zhurba | 85f55fe | 2019-06-10 17:30:53 -0500 | [diff] [blame] | 118 | ssl = local_salt_client.pillar_get( |
| 119 | tgt='kibana:server', |
| 120 | param='haproxy:proxy:listen:kibana:binds:ssl:enabled') |
| 121 | proto = "https" if ssl else "http" |
| 122 | |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 123 | response = requests.get( |
| 124 | '{0}://{1}:5601/api/status'.format(proto, IP), |
| 125 | proxies=proxies, |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 126 | verify=False).content.decode() |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 127 | body = json.loads(response) |
| 128 | assert body['status']['overall']['state'] == "green", ( |
| 129 | "Kibana overall status is not 'green':\n{}".format( |
| 130 | body['status']['overall']) |
| 131 | ) |
Ievgeniia Zadorozhna | 511f0ce | 2018-11-08 17:43:10 +0300 | [diff] [blame] | 132 | for i in body['status']['statuses']: |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 133 | assert i['state'] == "green", ( |
| 134 | "Kibana statuses are unexpected:\n{}".format(i)) |
Ievgeniia Zadorozhna | 511f0ce | 2018-11-08 17:43:10 +0300 | [diff] [blame] | 135 | |
| 136 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 137 | @pytest.mark.smoke |
| 138 | #TODO: recheck |
Ievgeniia Zadorozhna | 511f0ce | 2018-11-08 17:43:10 +0300 | [diff] [blame] | 139 | @pytest.mark.usefixtures('check_kibana') |
Oleksii Zhurba | 84ce7fe | 2018-01-16 21:34:01 +0000 | [diff] [blame] | 140 | def test_elasticsearch_node_count(local_salt_client): |
| 141 | now = datetime.datetime.now() |
| 142 | today = now.strftime("%Y.%m.%d") |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 143 | salt_output = local_salt_client.pillar_get( |
| 144 | tgt='kibana:server', |
| 145 | param='_param:haproxy_elasticsearch_bind_host') |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 146 | |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 147 | IP = salt_output |
Oleksii Zhurba | 85f55fe | 2019-06-10 17:30:53 -0500 | [diff] [blame] | 148 | ssl = local_salt_client.pillar_get( |
| 149 | tgt='elasticsearch:server', |
| 150 | param='haproxy:proxy:listen:elasticsearch:binds:ssl:enabled') |
| 151 | proto = "https" if ssl else "http" |
| 152 | |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 153 | headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 154 | proxies = {"http": None, "https": None} |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 155 | data = ('{"size": 0, "aggs": ' |
| 156 | '{"uniq_hostname": ' |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 157 | '{"terms": {"size": 500, ' |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 158 | '"field": "Hostname.keyword"}}}}') |
| 159 | response = requests.post( |
Oleksii Zhurba | 85f55fe | 2019-06-10 17:30:53 -0500 | [diff] [blame] | 160 | '{0}://{1}:9200/log-{2}/_search?pretty'.format(proto, IP, today), |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 161 | proxies=proxies, |
| 162 | headers=headers, |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 163 | verify=False, |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 164 | data=data) |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 165 | assert response.status_code == 200, ( |
| 166 | 'Issues with accessing elasticsearch on {}:\n{}'.format( |
| 167 | IP, response.text) |
| 168 | ) |
Tatyana Leontovich | 30bd90c | 2019-01-11 16:26:32 +0200 | [diff] [blame] | 169 | resp = json.loads(response.text) |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 170 | cluster_domain = local_salt_client.pillar_get( |
| 171 | param='_param:cluster_domain') |
Oleksii Zhurba | d2847dc | 2018-02-16 15:13:09 -0600 | [diff] [blame] | 172 | monitored_nodes = [] |
Oleksii Zhurba | 7f46341 | 2018-03-21 16:32:44 -0500 | [diff] [blame] | 173 | for item_ in resp['aggregations']['uniq_hostname']['buckets']: |
Oleksii Zhurba | d2847dc | 2018-02-16 15:13:09 -0600 | [diff] [blame] | 174 | node_name = item_['key'] |
| 175 | monitored_nodes.append(node_name + '.' + cluster_domain) |
| 176 | missing_nodes = [] |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 177 | all_nodes = list(local_salt_client.test_ping(tgt='*').keys()) |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 178 | for node in all_nodes: |
Oleksii Zhurba | d2847dc | 2018-02-16 15:13:09 -0600 | [diff] [blame] | 179 | if node not in monitored_nodes: |
| 180 | missing_nodes.append(node) |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 181 | assert len(missing_nodes) == 0, ( |
| 182 | "Not all nodes are in Elasticsearch. Expected {}, but found {} keys.\n" |
| 183 | "Missing nodes:\n{}".format( |
| 184 | len(monitored_nodes), len(all_nodes), missing_nodes) |
| 185 | ) |
Oleksii Zhurba | 84ce7fe | 2018-01-16 21:34:01 +0000 | [diff] [blame] | 186 | |
| 187 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 188 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 189 | # DockerServiceMonitoring* |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 190 | @pytest.mark.full |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 191 | def test_stacklight_services_replicas(local_salt_client): |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 192 | # TODO |
| 193 | # change to docker:swarm:role:master ? |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 194 | salt_output = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 195 | tgt='I@docker:client:stack:monitoring and I@prometheus:server', |
| 196 | param='docker service ls', |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 197 | expr_form='compound') |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 198 | |
| 199 | if not salt_output: |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 200 | pytest.skip("docker:client:stack:monitoring or \ |
| 201 | prometheus:server pillars are not found on this environment.") |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 202 | |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 203 | wrong_items = [] |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 204 | for line in salt_output[list(salt_output.keys())[0]].split('\n'): |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 205 | if line[line.find('/') - 1] != line[line.find('/') + 1] \ |
| 206 | and 'replicated' in line: |
| 207 | wrong_items.append(line) |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 208 | assert len(wrong_items) == 0, ( |
| 209 | "Some monitoring services don't have the expected number of " |
| 210 | "replicas:\n{}".format(json.dumps(wrong_items, indent=4)) |
| 211 | ) |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 212 | |
| 213 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 214 | @pytest.mark.smoke |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 215 | def test_prometheus_alert_count(alert_in_prometheus): |
Hanna Arhipova | fae5b5b | 2019-12-09 15:57:55 +0200 | [diff] [blame] | 216 | |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 217 | assert len(alert_in_prometheus) == 0, \ |
| 218 | '\n\n\tAlertManager page has some alerts!\n{} \n'.format( |
| 219 | '\n'.join( |
| 220 | [alert['annotations']['description'] |
| 221 | for alert in alert_in_prometheus] |
| 222 | )) |
Oleksii Zhurba | 468e6c7 | 2018-01-16 17:43:15 +0000 | [diff] [blame] | 223 | |
| 224 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 225 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 226 | # DockerServiceMonitoring* ?? |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 227 | @pytest.mark.full |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 228 | def test_stacklight_containers_status(local_salt_client): |
| 229 | salt_output = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 230 | tgt='I@docker:swarm:role:master and I@prometheus:server', |
| 231 | param='docker service ps $(docker stack services -q monitoring)', |
Oleksii Zhurba | 8ce9fcf | 2018-10-05 18:38:22 +0300 | [diff] [blame] | 232 | expr_form='compound') |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 233 | |
| 234 | if not salt_output: |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 235 | pytest.skip("docker:swarm:role:master or prometheus:server pillars " |
| 236 | "are not found on this environment.") |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 237 | |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 238 | result = {} |
Oleksii Zhurba | 468e6c7 | 2018-01-16 17:43:15 +0000 | [diff] [blame] | 239 | # for old reclass models, docker:swarm:role:master can return |
| 240 | # 2 nodes instead of one. Here is temporary fix. |
| 241 | # TODO |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 242 | if len(list(salt_output.keys())) > 1: |
| 243 | if 'CURRENT STATE' not in salt_output[list(salt_output.keys())[0]]: |
| 244 | del salt_output[list(salt_output.keys())[0]] |
| 245 | for line in salt_output[list(salt_output.keys())[0]].split('\n')[1:]: |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 246 | shift = 0 |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 247 | if line.split()[1] == '\\_': |
| 248 | shift = 1 |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 249 | if line.split()[1 + shift] not in list(result.keys()): |
Oleksii Zhurba | 020fab4 | 2017-11-01 20:13:28 +0000 | [diff] [blame] | 250 | result[line.split()[1]] = 'NOT OK' |
| 251 | if line.split()[4 + shift] == 'Running' \ |
| 252 | or line.split()[4 + shift] == 'Ready': |
| 253 | result[line.split()[1 + shift]] = 'OK' |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 254 | assert 'NOT OK' not in list(result.values()), ( |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 255 | "Some containers have incorrect state:\n{}".format( |
| 256 | json.dumps(result, indent=4)) |
| 257 | ) |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 258 | |
| 259 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 260 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 261 | # PrometheusTargetDown |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 262 | @pytest.mark.full |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 263 | def test_running_telegraf_services(local_salt_client): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 264 | salt_output = local_salt_client.cmd(tgt='telegraf:agent', |
| 265 | fun='service.status', |
| 266 | param='telegraf', |
| 267 | expr_form='pillar',) |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 268 | |
| 269 | if not salt_output: |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 270 | pytest.skip("Telegraf or telegraf:agent pillars are not found on " |
| 271 | "this environment.") |
Oleksii Zhurba | 9848e21 | 2018-09-05 10:53:51 -0500 | [diff] [blame] | 272 | |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 273 | result = [{node: status} for node, status |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 274 | in list(salt_output.items()) |
Oleksii Zhurba | e592ed1 | 2018-06-21 18:01:09 -0500 | [diff] [blame] | 275 | if status is False] |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 276 | assert result == [], ( |
| 277 | "Telegraf service is not running on the following nodes:\n{}".format( |
| 278 | result) |
| 279 | ) |
Ievgeniia Zadorozhna | 6775eb7 | 2018-11-09 19:50:04 +0300 | [diff] [blame] | 280 | |
| 281 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 282 | @pytest.mark.sl_dup |
Hanna Arhipova | 481938b | 2020-02-11 22:17:20 +0200 | [diff] [blame] | 283 | # PrometheusTargetDown |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 284 | @pytest.mark.full |
Ievgeniia Zadorozhna | 6775eb7 | 2018-11-09 19:50:04 +0300 | [diff] [blame] | 285 | def test_running_fluentd_services(local_salt_client): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 286 | salt_output = local_salt_client.cmd(tgt='fluentd:agent', |
| 287 | fun='service.status', |
| 288 | param='td-agent', |
Ievgeniia Zadorozhna | 6775eb7 | 2018-11-09 19:50:04 +0300 | [diff] [blame] | 289 | expr_form='pillar') |
| 290 | result = [{node: status} for node, status |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame] | 291 | in list(salt_output.items()) |
Ievgeniia Zadorozhna | 6775eb7 | 2018-11-09 19:50:04 +0300 | [diff] [blame] | 292 | if status is False] |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 293 | assert result == [], ( |
| 294 | "Fluentd check failed - td-agent service is not running on the " |
| 295 | "following nodes:\n{}".format(result) |
| 296 | ) |