Implemented parallel iperf preparation at VMs
To reduce the time of runs, implemented parallel
iperf/iperf3 installation at VMs.
Related-PROD: PROD-36943
Change-Id: Ia789c874ae55c757ffbe8e07511433d2f694708e
diff --git a/tests/test_vm2vm_different_routers.py b/tests/test_vm2vm_different_routers.py
index 612e5be..8b38a4b 100644
--- a/tests/test_vm2vm_different_routers.py
+++ b/tests/test_vm2vm_different_routers.py
@@ -1,3 +1,4 @@
+from concurrent.futures import ThreadPoolExecutor
import logging
import sys
import time
@@ -107,7 +108,8 @@
vms[2].add_floating_ip(fip2['floating_ip_address'])
for i in range(len(vms)):
vm_info.append({'vm': vms[i],
- 'fip': fips[i]['floating_ip_address']})
+ 'fip': fips[i]['floating_ip_address'],
+ 'private_key': private_key})
# Set custom MTU if required
if os_actions.is_cloud_tf() and (custom_mtu != "default"):
@@ -117,24 +119,21 @@
custom_mtu)
# Check VMs are reachable and prepare iperf3
- logger.info("Checking VMs are reachable via SSH, getting MTU...")
- mtus = []
+ logger.info("Checking VMs are reachable via SSH...")
transport1 = ssh.SSHTransport(vm_info[0]['fip'], 'ubuntu',
password='dd', private_key=private_key)
- logger.info("Checking VMs are reachable via SSH...")
for i in range(len(vms)):
- if transport1.check_vm_is_reachable_ssh(
- floating_ip=vm_info[i]['fip'], timeout=ssh_timeout):
- ssh.IperfAtVM(
- vm_info[i]['fip'], private_key=private_key)
- mtus.append(transport1.get_mtu_from_vm(
- vm_info[i]['fip'], private_key=private_key))
+ transport1.check_vm_is_reachable_ssh(
+ 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)
+ for vm_info in vm_info]
+ mtus = [future.result() for future in futures]
logger.info(
"MTU at networks: {}, {}".format(
os_resources['net1']['mtu'],
os_resources_alt_project['net1']['mtu']))
- logger.info("MTU at VMs: {}".format(", ".join(mtus)))
-
# Prepare the result table and run iperf3
table_rows = []
table_rows.append(['Test Case', 'Host 1', 'Host 2',