blob: 2ff3383f1c49f853dbdf92064003c8ae32710116 [file] [log] [blame]
Oleksii Zhurba11de14e2017-10-23 19:13:00 +00001import pytest
2import json
3
Oleksii Zhurba3dbed242017-10-31 19:58:53 +00004
Oleksii Zhurba11de14e2017-10-23 19:13:00 +00005def test_k8s_get_cs_status(local_salt_client):
6 result = local_salt_client.cmd(
7 'etcd:server', 'cmd.run',
8 ['kubectl get cs'],
9 expr_form='pillar'
10 )
11 errors = []
12 if not result:
13 pytest.skip("k8s is not found on this environment")
14 for node in result:
15 for line in result[node].split('\n'):
16 line = line.strip()
17 if 'MESSAGE' in line:
18 continue
19 else:
20 if 'Healthy' not in line:
Oleksii Zhurba3dbed242017-10-31 19:58:53 +000021 errors.append(line)
Oleksii Zhurba11de14e2017-10-23 19:13:00 +000022 break
23 assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
Oleksii Zhurba3dbed242017-10-31 19:58:53 +000024 errors,
25 indent=4))
Oleksii Zhurba11de14e2017-10-23 19:13:00 +000026
27
28def test_k8s_get_nodes_status(local_salt_client):
29 result = local_salt_client.cmd(
30 'etcd:server', 'cmd.run',
31 ['kubectl get nodes'],
32 expr_form='pillar'
33 )
34 errors = []
35 if not result:
36 pytest.skip("k8s is not found on this environment")
37 for node in result:
38 for line in result[node].split('\n'):
39 line = line.strip()
40 if 'STATUS' in line:
41 continue
42 else:
43 if 'Ready' not in line:
Oleksii Zhurba3dbed242017-10-31 19:58:53 +000044 errors.append(line)
Oleksii Zhurba11de14e2017-10-23 19:13:00 +000045 break
46 assert not errors, 'k8s is not healthy: {}'.format(json.dumps(
Oleksii Zhurba3dbed242017-10-31 19:58:53 +000047 errors,
48 indent=4))