Added logic to skip kvm with no vm running.
Added correct logic to grep ifaces for kvms.
Changed fqdn to domain_name.
Added inline comments.
Change-Id: I74357a85d30e789a72e7d3e4cb6099c4f19c8d55
Closes-Bug: PROD-35340
diff --git a/test_set/cvp-sanity/tests/test_mtu.py b/test_set/cvp-sanity/tests/test_mtu.py
index bfe82d5..da61683 100644
--- a/test_set/cvp-sanity/tests/test_mtu.py
+++ b/test_set/cvp-sanity/tests/test_mtu.py
@@ -32,16 +32,26 @@
for node, ifaces_info in network_info.items():
if isinstance(ifaces_info, bool):
- logging.info("{} node is skipped".format(node))
+ logging.info("{} node skipped. No interfaces available.".format(node))
continue
# if node is a kvm node and virsh is installed there
if node in list(kvm_nodes.keys()) and kvm_nodes[node]:
- kvm_info = local_salt_client.cmd(tgt=node,
- param="virsh list | "
- "awk '{print $2}' | "
- "xargs -n1 virsh domiflist | "
- "grep -v br-pxe | grep br- | "
- "awk '{print $1}'")
+ domain_name = node.split(".", 1)[1]
+ # vms_count calculated separately to have readable output
+ # and for further debug if needed
+ vms_count = local_salt_client.cmd(tgt=node, param="virsh list | grep {}"
+ .format(domain_name))
+ if not vms_count[node]:
+ logging.info("{} node skipped. No OS vm's running.".format(node))
+ continue
+ # param assumes that KVM has OS vm's running.
+ # virsh list | grep domain_name --- fails
+ # if KVM has nothing to grep and test fails
+ param = "virsh list | grep " + domain_name + "| awk '{print $2}' | " \
+ "xargs -n1 virsh domiflist | " \
+ "grep -v br-pxe | grep br- | " \
+ "awk '{print $1}' "
+ kvm_info = local_salt_client.cmd(tgt=node, param=param)
ifaces_info = kvm_info.get(node)
node_ifaces = ifaces_info.split('\n')
ifaces = {}
@@ -79,4 +89,4 @@
assert len(mtu_data) == 0, (
"Non-uniform MTUs are set on the same node interfaces of '{}' group "
"of nodes: {}".format(group, json.dumps(mtu_data, indent=4))
- )
\ No newline at end of file
+ )