From ab2bbedc4a8cbaa289a3ff39655edf5e3bcd19d9 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Tue, 31 Aug 2021 14:07:33 -0400 Subject: [PATCH] ovn-tester: Provision ports simultaneously. If we need to provision ports on multiple workers, we may as well do it all at once. Suggested-by: Mohammad Heib Signed-off-by: Mark Michelson --- ovn-tester/ovn_workload.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ovn-tester/ovn_workload.py b/ovn-tester/ovn_workload.py index 2a2f988e..7cafd159 100644 --- a/ovn-tester/ovn_workload.py +++ b/ovn-tester/ovn_workload.py @@ -640,12 +640,14 @@ async def create_cluster_join_switch(self, sw_name): ) async def provision_ports(self, n_ports, passive=False): - ret_list = [] + tasks = [] + ctx = ovn_context.active_context for _ in range(n_ports): worker = self.select_worker_for_port() - ports = await worker.provision_ports(self, 1, passive) - ret_list.append(ports[0]) - return ret_list + tasks.append(ctx.create_task(worker.provision_ports(self, 1, + passive))) + results = await asyncio.gather(*tasks) + return [ports[0] for ports in results] async def unprovision_ports(self, ports): for port in ports: