blob: dfb67e93678cf11fd2505013892facb5be384f83 [file] [log] [blame]
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +03001import json
2import pytest
3
4
Oleksii Zhurba5b15b9b2019-05-09 18:53:40 -05005@pytest.mark.smoke
6#full?
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +03007def test_mounted_file_systems(local_salt_client, nodes_in_group):
8 """
9 # Get all mount points from each node in the group with the next command: `df -h | awk '{print $1}'`
10 # Check that all mount points are similar for each node in the group
11 """
Oleksii Zhurbac8109352019-05-28 17:29:49 -050012 exclude_mounts = 'grep -v "overlay\|tmpfs\|shm\|Filesystem"'
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050013 mounts_by_nodes = local_salt_client.cmd(tgt="L@"+','.join(nodes_in_group),
Oleksii Zhurbac8109352019-05-28 17:29:49 -050014 param="df -h | awk '{print $1}'" +
15 " |" + exclude_mounts,
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030016 expr_form='compound')
17
18 # Let's exclude cmp, kvm, ceph OSD nodes, mon, cid, k8s-ctl, k8s-cmp nodes
19 # These nodes will have different mounts and this is expected
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050020 exclude_nodes = local_salt_client.test_ping(
21 tgt="I@nova:compute or "
22 "I@ceph:osd or "
23 "I@salt:control or "
24 "I@prometheus:server and not I@influxdb:server or "
25 "I@kubernetes:* and not I@etcd:* or "
Hanna Arhipova80514de2019-04-25 12:33:28 +030026 "I@docker:host and not I@prometheus:server and not I@kubernetes:* or "
27 "I@gerrit:client and I@kubernetes:pool and not I@salt:master",
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050028 expr_form='compound').keys()
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030029
30 if len(mounts_by_nodes.keys()) < 2:
31 pytest.skip("Nothing to compare - only 1 node")
32
33 result = {}
34 pretty_result = {}
35
36 for node in mounts_by_nodes:
37 if node in exclude_nodes:
38 continue
Oleksii Zhurba075cc7a2019-05-17 14:04:28 -050039 if isinstance(mounts_by_nodes[node], bool):
40 result[node] = 'Cannot access this node'
41 pretty_result[node] = 'Cannot access this node'
42 else:
43 result[node] = "\n".join(sorted(mounts_by_nodes[node].split()))
44 pretty_result[node] = sorted(mounts_by_nodes[node].split())
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030045
46 if not result:
47 pytest.skip("These nodes are skipped")
48
49 assert len(set(result.values())) == 1,\
50 "The nodes in the same group have different mounts:\n{}".format(
51 json.dumps(pretty_result, indent=4))