blob: 3f025dd3a3091152d741bb3c95b3a363b69a6cac [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 """
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020012 group, nodes = nodes_in_group
Oleksii Zhurbac8109352019-05-28 17:29:49 -050013 exclude_mounts = 'grep -v "overlay\|tmpfs\|shm\|Filesystem"'
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020014 mounts_by_nodes = local_salt_client.cmd(tgt="L@"+','.join(nodes),
Oleksii Zhurbac8109352019-05-28 17:29:49 -050015 param="df -h | awk '{print $1}'" +
16 " |" + exclude_mounts,
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030017 expr_form='compound')
18
19 # Let's exclude cmp, kvm, ceph OSD nodes, mon, cid, k8s-ctl, k8s-cmp nodes
20 # These nodes will have different mounts and this is expected
Ekaterina Chernovae32e3f92019-11-12 14:56:03 +030021 exclude_nodes = list(local_salt_client.test_ping(
Oleksii Zhurba4bfd2ee2019-04-10 21:56:58 -050022 tgt="I@nova:compute or "
23 "I@ceph:osd or "
24 "I@salt:control or "
25 "I@prometheus:server and not I@influxdb:server or "
26 "I@kubernetes:* and not I@etcd:* or "
Hanna Arhipova80514de2019-04-25 12:33:28 +030027 "I@docker:host and not I@prometheus:server and not I@kubernetes:* or "
28 "I@gerrit:client and I@kubernetes:pool and not I@salt:master",
Ekaterina Chernovae32e3f92019-11-12 14:56:03 +030029 expr_form='compound').keys())
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030030
Ekaterina Chernovae32e3f92019-11-12 14:56:03 +030031 if len(list(mounts_by_nodes.keys())) < 2:
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030032 pytest.skip("Nothing to compare - only 1 node")
33
34 result = {}
35 pretty_result = {}
36
37 for node in mounts_by_nodes:
38 if node in exclude_nodes:
39 continue
Oleksii Zhurba075cc7a2019-05-17 14:04:28 -050040 if isinstance(mounts_by_nodes[node], bool):
41 result[node] = 'Cannot access this node'
42 pretty_result[node] = 'Cannot access this node'
43 else:
44 result[node] = "\n".join(sorted(mounts_by_nodes[node].split()))
45 pretty_result[node] = sorted(mounts_by_nodes[node].split())
Ievgeniia Zadorozhna45ae6b62019-03-05 18:52:44 +030046
47 if not result:
48 pytest.skip("These nodes are skipped")
49
Dmitriy Kruglova34a3042019-08-20 11:45:35 +020050 assert len(set(result.values())) == 1, (
51 "Nodes in '{}' group have different mounts:\n{}".format(
52 group, json.dumps(pretty_result, indent=4))
53 )