Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 1 | import json |
| 2 | import pytest |
| 3 | |
| 4 | |
Oleksii Zhurba | 5b15b9b | 2019-05-09 18:53:40 -0500 | [diff] [blame] | 5 | @pytest.mark.smoke |
| 6 | #full? |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 7 | def 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 Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 12 | group, nodes = nodes_in_group |
Oleksii Zhurba | c810935 | 2019-05-28 17:29:49 -0500 | [diff] [blame] | 13 | exclude_mounts = 'grep -v "overlay\|tmpfs\|shm\|Filesystem"' |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 14 | mounts_by_nodes = local_salt_client.cmd(tgt="L@"+','.join(nodes), |
Oleksii Zhurba | c810935 | 2019-05-28 17:29:49 -0500 | [diff] [blame] | 15 | param="df -h | awk '{print $1}'" + |
| 16 | " |" + exclude_mounts, |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 17 | 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 Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame^] | 21 | exclude_nodes = list(local_salt_client.test_ping( |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 22 | 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 Arhipova | 80514de | 2019-04-25 12:33:28 +0300 | [diff] [blame] | 27 | "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 Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame^] | 29 | expr_form='compound').keys()) |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 30 | |
Ekaterina Chernova | e32e3f9 | 2019-11-12 14:56:03 +0300 | [diff] [blame^] | 31 | if len(list(mounts_by_nodes.keys())) < 2: |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 32 | 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 Zhurba | 075cc7a | 2019-05-17 14:04:28 -0500 | [diff] [blame] | 40 | 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 Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 46 | |
| 47 | if not result: |
| 48 | pytest.skip("These nodes are skipped") |
| 49 | |
Dmitriy Kruglov | a34a304 | 2019-08-20 11:45:35 +0200 | [diff] [blame] | 50 | assert len(set(result.values())) == 1, ( |
| 51 | "Nodes in '{}' group have different mounts:\n{}".format( |
| 52 | group, json.dumps(pretty_result, indent=4)) |
| 53 | ) |