Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 1 | import json |
Oleksii Zhurba | 23c1833 | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 2 | import pytest |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 3 | |
| 4 | |
Oleksii Zhurba | 23c1833 | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 5 | @pytest.mark.full |
Hanna Arhipova | e6ed8e4 | 2019-05-15 16:27:08 +0300 | [diff] [blame] | 6 | def test_etc_hosts(local_salt_client): |
| 7 | nodes_info = local_salt_client.cmd( |
| 8 | tgt='*', |
| 9 | param='cat /etc/hosts', |
| 10 | expr_form='compound') |
| 11 | result = {} |
| 12 | for node in nodes_info.keys(): |
| 13 | if isinstance(nodes_info[node], bool): |
| 14 | result[node] = 'Cannot access this node' |
| 15 | continue |
| 16 | for nd in nodes_info.keys(): |
| 17 | if nd not in nodes_info[node]: |
| 18 | if node in result: |
| 19 | result[node] += ',' + nd |
| 20 | else: |
| 21 | result[node] = nd |
| 22 | assert len(result) <= 1, \ |
| 23 | "Some hosts are not presented in /etc/hosts: {0}".format( |
Dmitriy Kruglov | bc0a88b | 2019-08-20 11:45:35 +0200 | [diff] [blame^] | 24 | json.dumps(result, indent=4)) |