Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 1 | import json |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 2 | import pytest |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 3 | |
| 4 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame^] | 5 | @pytest.mark.full |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 6 | def test_etc_hosts(local_salt_client): |
| 7 | nodes_info = local_salt_client.cmd( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 8 | tgt='*', |
| 9 | param='cat /etc/hosts', |
Oleksii Zhurba | 26a3a1c | 2018-01-16 19:10:20 +0000 | [diff] [blame] | 10 | expr_form='compound') |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 11 | result = {} |
| 12 | for node in nodes_info.keys(): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 13 | if isinstance(nodes_info[node], bool): |
| 14 | result[node] = 'Cannot access this node' |
| 15 | continue |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 16 | for nd in nodes_info.keys(): |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 17 | if nd not in nodes_info[node]: |
| 18 | if node in result: |
| 19 | result[node] += ',' + nd |
| 20 | else: |
| 21 | result[node] = nd |
Oleksii Zhurba | edb0a21 | 2018-01-16 17:02:55 +0000 | [diff] [blame] | 22 | assert len(result) <= 1, \ |
| 23 | "Some hosts are not presented in /etc/hosts: {0}".format( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 24 | json.dumps(result, indent=4)) |