blob: 417bc1a338ecd8caf1ac00cb5a963e370ca30ff1 [file] [log] [blame]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00001import pytest
2import json
Hanna Arhipova16e93fb2019-01-23 19:03:01 +02003import utils
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +00004import os
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +00005
6
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -05007def test_mtu(local_salt_client, nodes_in_group):
Oleksii Zhurba3dbed242017-10-31 19:58:53 +00008 testname = os.path.basename(__file__).split('.')[0]
Oleksii Zhurbae0668ae2017-10-27 23:58:18 +00009 config = utils.get_configuration()
Oleksii Zhurba3dbed242017-10-31 19:58:53 +000010 skipped_ifaces = config.get(testname)["skipped_ifaces"] or \
Oleksii Zhurba1dd1d962018-08-07 15:01:40 -050011 ["bonding_masters", "lo", "veth", "tap", "cali", "qv", "qb", "br-int", "vxlan"]
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000012 total = {}
13 network_info = local_salt_client.cmd(
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -050014 "L@"+','.join(nodes_in_group), 'cmd.run', ['ls /sys/class/net/'], expr_form='compound')
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000015
16 kvm_nodes = local_salt_client.cmd(
17 'salt:control', 'test.ping', expr_form='pillar').keys()
18
19 if len(network_info.keys()) < 2:
20 pytest.skip("Nothing to compare - only 1 node")
21
22 for node, ifaces_info in network_info.iteritems():
23 if node in kvm_nodes:
24 kvm_info = local_salt_client.cmd(node, 'cmd.run',
25 ["virsh list | "
26 "awk '{print $2}' | "
27 "xargs -n1 virsh domiflist | "
28 "grep -v br-pxe | grep br- | "
29 "awk '{print $1}'"])
30 ifaces_info = kvm_info.get(node)
31 node_ifaces = ifaces_info.split('\n')
32 ifaces = {}
33 for iface in node_ifaces:
34 for skipped_iface in skipped_ifaces:
35 if skipped_iface in iface:
36 break
37 else:
38 iface_mtu = local_salt_client.cmd(node, 'cmd.run',
39 ['cat /sys/class/'
40 'net/{}/mtu'.format(iface)])
41 ifaces[iface] = iface_mtu.get(node)
42 total[node] = ifaces
43
44 nodes = []
45 mtu_data = []
46 my_set = set()
47
48 for node in total:
49 nodes.append(node)
50 my_set.update(total[node].keys())
51 for interf in my_set:
52 diff = []
53 row = []
54 for node in nodes:
55 if interf in total[node].keys():
56 diff.append(total[node][interf])
57 row.append("{}: {}".format(node, total[node][interf]))
58 else:
Oleksii Zhurba24b71aa2019-02-27 17:02:05 -060059 # skip node with no virbr0 or virbr0-nic interfaces
60 if interf not in ['virbr0', 'virbr0-nic']:
61 row.append("{}: No interface".format(node))
Oleksii Zhurbaa10927b2017-09-27 22:09:23 +000062 if diff.count(diff[0]) < len(nodes):
63 row.sort()
64 row.insert(0, interf)
65 mtu_data.append(row)
66 assert len(mtu_data) == 0, \
Oleksii Zhurbaa32d92f2018-03-29 16:22:35 -050067 "Several problems found: {0}".format(
Oleksii Zhurbad0ae87f2018-03-26 13:36:25 -050068 json.dumps(mtu_data, indent=4))