Fixed getting MTU from the VMs
There was some race condition and sometimes MTU at VMs
was fetched, but the report had None in the final output.
Fixed by removing getting MTU from the async tasks.
Related-PROD: PROD-36943
Change-Id: I43bb3dcdf7e5690a55cef4af081cafdb6827de2c
diff --git a/tests/test_vm2vm.py b/tests/test_vm2vm.py
index d6a4242..ac6bbc0 100644
--- a/tests/test_vm2vm.py
+++ b/tests/test_vm2vm.py
@@ -110,9 +110,12 @@
floating_ip=vm_info[i]['fip'], timeout=ssh_timeout)
with ThreadPoolExecutor() as executor:
futures = [
- executor.submit(ssh.install_iperf_at_vms_and_get_mtu, vm_info)
+ executor.submit(ssh.install_iperf_at_vm, vm_info)
for vm_info in vm_info]
- mtus = [future.result() for future in futures]
+ logger.info("Getting MTUs at VMs...")
+ mtus = []
+ for vm in vm_info:
+ mtus.append(ssh.get_mtu_at_vm(vm))
logger.info("MTU at networks: {}, {}".format(
os_resources['net1']['mtu'], os_resources['net2']['mtu']))
# Prepare the result table and run iperf3
diff --git a/tests/test_vm2vm_different_routers.py b/tests/test_vm2vm_different_routers.py
index 8b38a4b..1fa8850 100644
--- a/tests/test_vm2vm_different_routers.py
+++ b/tests/test_vm2vm_different_routers.py
@@ -127,9 +127,12 @@
floating_ip=vm_info[i]['fip'], timeout=ssh_timeout)
with ThreadPoolExecutor() as executor:
futures = [
- executor.submit(ssh.install_iperf_at_vms_and_get_mtu, vm_info)
+ executor.submit(ssh.install_iperf_at_vm, vm_info)
for vm_info in vm_info]
- mtus = [future.result() for future in futures]
+ logger.info("Getting MTUs at VMs...")
+ mtus = []
+ for vm in vm_info:
+ mtus.append(ssh.get_mtu_at_vm(vm))
logger.info(
"MTU at networks: {}, {}".format(
os_resources['net1']['mtu'],
diff --git a/utils/ssh.py b/utils/ssh.py
index cde86bd..cb0a258 100644
--- a/utils/ssh.py
+++ b/utils/ssh.py
@@ -14,18 +14,25 @@
logging.getLogger("paramiko").setLevel(logging.WARNING)
-def install_iperf_at_vms_and_get_mtu(vm_info):
+def install_iperf_at_vm(vm_info):
+ try:
+ IperfAtVM(vm_info['fip'], private_key=vm_info['private_key'])
+ except Exception as e:
+ print(f"Error on VM {vm_info['fip']}: {e}")
+ return None
+
+
+def get_mtu_at_vm(vm_info):
transport1 = SSHTransport(vm_info['fip'], 'ubuntu', password='dd',
private_key=vm_info['private_key'])
try:
- IperfAtVM(vm_info['fip'], private_key=vm_info['private_key'])
logger.info("Getting MTU values from VMs...")
mtu = transport1.get_mtu_from_vm(
vm_info['fip'], private_key=vm_info['private_key'])
logger.info(f"MTU at VM {vm_info['fip']} is {mtu}")
return mtu
except Exception as e:
- print(f"Error on VM {vm_info['fip']}: {e}")
+ print(f"Error while getting MTU at VM {vm_info['fip']}: {e}")
return None