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