Oleksii Zhurba | 11de14e | 2017-10-23 19:13:00 +0000 | [diff] [blame] | 1 | import pytest |
| 2 | import json |
| 3 | |
| 4 | def test_k8s_get_cs_status(local_salt_client): |
| 5 | result = local_salt_client.cmd( |
| 6 | 'etcd:server', 'cmd.run', |
| 7 | ['kubectl get cs'], |
| 8 | expr_form='pillar' |
| 9 | ) |
| 10 | errors = [] |
| 11 | if not result: |
| 12 | pytest.skip("k8s is not found on this environment") |
| 13 | for node in result: |
| 14 | for line in result[node].split('\n'): |
| 15 | line = line.strip() |
| 16 | if 'MESSAGE' in line: |
| 17 | continue |
| 18 | else: |
| 19 | if 'Healthy' not in line: |
| 20 | errors.append (line) |
| 21 | break |
| 22 | assert not errors, 'k8s is not healthy: {}'.format(json.dumps( |
| 23 | errors, |
| 24 | indent=4)) |
| 25 | |
| 26 | |
| 27 | def test_k8s_get_nodes_status(local_salt_client): |
| 28 | result = local_salt_client.cmd( |
| 29 | 'etcd:server', 'cmd.run', |
| 30 | ['kubectl get nodes'], |
| 31 | expr_form='pillar' |
| 32 | ) |
| 33 | errors = [] |
| 34 | if not result: |
| 35 | pytest.skip("k8s is not found on this environment") |
| 36 | for node in result: |
| 37 | for line in result[node].split('\n'): |
| 38 | line = line.strip() |
| 39 | if 'STATUS' in line: |
| 40 | continue |
| 41 | else: |
| 42 | if 'Ready' not in line: |
| 43 | errors.append (line) |
| 44 | break |
| 45 | assert not errors, 'k8s is not healthy: {}'.format(json.dumps( |
| 46 | errors, |
| 47 | indent=4)) |