Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 1 | import pytest |
| 2 | import json |
Oleksii Zhurba | 26a3a1c | 2018-01-16 19:10:20 +0000 | [diff] [blame] | 3 | import os |
| 4 | from cvp_checks import utils |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 5 | |
| 6 | |
| 7 | def test_etc_hosts(local_salt_client): |
Oleksii Zhurba | 26a3a1c | 2018-01-16 19:10:20 +0000 | [diff] [blame] | 8 | active_nodes = utils.get_active_nodes() |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 9 | nodes_info = local_salt_client.cmd( |
Oleksii Zhurba | 26a3a1c | 2018-01-16 19:10:20 +0000 | [diff] [blame] | 10 | utils.list_to_target_string(active_nodes, 'or'), 'cmd.run', |
| 11 | ['cat /etc/hosts'], |
| 12 | expr_form='compound') |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 13 | result = {} |
| 14 | for node in nodes_info.keys(): |
| 15 | for nd in nodes_info.keys(): |
| 16 | if node not in nodes_info[nd]: |
| 17 | if node in result: |
| 18 | result[node]+=','+nd |
| 19 | else: |
| 20 | result[node]=nd |
| 21 | assert len(result) <= 1, \ |
| 22 | "Some hosts are not presented in /etc/hosts: {0}".format( |
| 23 | json.dumps(result, indent=4)) |