blob: 61d36ef4a9800f8136482290dc53541badd87e85 [file] [log] [blame]
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00001import json
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05002import pytest
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00003
4
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05005@pytest.mark.full
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00006def test_etc_hosts(local_salt_client):
7 nodes_info = local_salt_client.cmd(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -05008 tgt='*',
9 param='cat /etc/hosts',
Oleksii Zhurba26a3a1c2018-01-16 19:10:20 +000010 expr_form='compound')
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000011 result = {}
12 for node in nodes_info.keys():
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050013 if isinstance(nodes_info[node], bool):
14 result[node] = 'Cannot access this node'
15 continue
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000016 for nd in nodes_info.keys():
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050017 if nd not in nodes_info[node]:
18 if node in result:
19 result[node] += ',' + nd
20 else:
21 result[node] = nd
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000022 assert len(result) <= 1, \
23 "Some hosts are not presented in /etc/hosts: {0}".format(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050024 json.dumps(result, indent=4))