blob: 1db29c83859c52af9a9b58312bfb087286fa5c75 [file] [log] [blame]
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00001import pytest
2import json
Oleksii Zhurba26a3a1c2018-01-16 19:10:20 +00003import os
4from cvp_checks import utils
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00005
6
7def test_etc_hosts(local_salt_client):
Oleksii Zhurba26a3a1c2018-01-16 19:10:20 +00008 active_nodes = utils.get_active_nodes()
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +00009 nodes_info = local_salt_client.cmd(
Oleksii Zhurba26a3a1c2018-01-16 19:10:20 +000010 utils.list_to_target_string(active_nodes, 'or'), 'cmd.run',
11 ['cat /etc/hosts'],
12 expr_form='compound')
Oleksii Zhurbaedb0a212018-01-16 17:02:55 +000013 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))