blob: bf881e7d5746d3e3434da98621cccb8cb0104b19 [file] [log] [blame]
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03001import json
Oleksii Zhurba23c18332019-05-09 18:53:40 -05002import pytest
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03003
4
Oleksii Zhurba23c18332019-05-09 18:53:40 -05005@pytest.mark.full
Hanna Arhipovae6ed8e42019-05-15 16:27:08 +03006def 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 Kruglovbc0a88b2019-08-20 11:45:35 +020024 json.dumps(result, indent=4))