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 | """ |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 12 | mounts_by_nodes = local_salt_client.cmd(tgt="L@"+','.join(nodes_in_group), |
| 13 | param="df -h | awk '{print $1}'", |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 14 | expr_form='compound') |
| 15 | |
| 16 | # Let's exclude cmp, kvm, ceph OSD nodes, mon, cid, k8s-ctl, k8s-cmp nodes |
| 17 | # These nodes will have different mounts and this is expected |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 18 | exclude_nodes = local_salt_client.test_ping( |
| 19 | tgt="I@nova:compute or " |
| 20 | "I@ceph:osd or " |
| 21 | "I@salt:control or " |
| 22 | "I@prometheus:server and not I@influxdb:server or " |
| 23 | "I@kubernetes:* and not I@etcd:* or " |
Hanna Arhipova | 80514de | 2019-04-25 12:33:28 +0300 | [diff] [blame] | 24 | "I@docker:host and not I@prometheus:server and not I@kubernetes:* or " |
| 25 | "I@gerrit:client and I@kubernetes:pool and not I@salt:master", |
Oleksii Zhurba | 4bfd2ee | 2019-04-10 21:56:58 -0500 | [diff] [blame] | 26 | expr_form='compound').keys() |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 27 | |
| 28 | if len(mounts_by_nodes.keys()) < 2: |
| 29 | pytest.skip("Nothing to compare - only 1 node") |
| 30 | |
| 31 | result = {} |
| 32 | pretty_result = {} |
| 33 | |
| 34 | for node in mounts_by_nodes: |
| 35 | if node in exclude_nodes: |
| 36 | continue |
Oleksii Zhurba | 075cc7a | 2019-05-17 14:04:28 -0500 | [diff] [blame^] | 37 | if isinstance(mounts_by_nodes[node], bool): |
| 38 | result[node] = 'Cannot access this node' |
| 39 | pretty_result[node] = 'Cannot access this node' |
| 40 | else: |
| 41 | result[node] = "\n".join(sorted(mounts_by_nodes[node].split())) |
| 42 | pretty_result[node] = sorted(mounts_by_nodes[node].split()) |
Ievgeniia Zadorozhna | 45ae6b6 | 2019-03-05 18:52:44 +0300 | [diff] [blame] | 43 | |
| 44 | if not result: |
| 45 | pytest.skip("These nodes are skipped") |
| 46 | |
| 47 | assert len(set(result.values())) == 1,\ |
| 48 | "The nodes in the same group have different mounts:\n{}".format( |
| 49 | json.dumps(pretty_result, indent=4)) |