From a6ed21e3579ea9c085c72777c82693a2e6b9078f Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Thu, 7 Oct 2021 16:39:53 -0400 Subject: [PATCH] ovn-tester: Allow tests to manually end iterations. Until this point, when running a qps_test, the ovn_context code would automatically take care of marking an iteration as started or ended. This is a problem, though, for tests that wait until all iterations have completed to determine if ports came up within the configured time limit. The issue is that the ovn_context will mark the iteration as completed, potentially logging the iteration as successful. However, after this has been logged, the test could mark the iteration as failed if it turns out the port did not come up within the configured time limit. The solution here is to allow for tests to override the default behavior by letting them mark the iteration as completed. To do this, the qps_test() function now accepts a kwargs parameter, and setting end_iteration=False will allow for the individual test to mark iterations as complete instead of having it done automatically by the ovn_context code. Signed-off-by: Mark Michelson --- ovn-tester/ovn_context.py | 9 +++++---- ovn-tester/ovn_tester.py | 5 ++++- ovn-tester/tests/cluster_density.py | 2 +- ovn-tester/tests/density_heavy.py | 5 ++++- ovn-tester/tests/density_light.py | 5 ++++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ovn-tester/ovn_context.py b/ovn-tester/ovn_context.py index 55c08c95..51701495 100644 --- a/ovn-tester/ovn_context.py +++ b/ovn-tester/ovn_context.py @@ -66,12 +66,12 @@ def create_task(self, coro, iteration=None): self.iterations[task.get_name()] = iteration return task - async def qps_test(self, qps, coro, *args): + async def qps_test(self, qps, coro, *args, **kwargs): tasks = [] for i in range(self.max_iterations): iteration = ContextIteration(i, self) tasks.append(self.create_task( - self.qps_task(iteration, coro, *args), iteration) + self.qps_task(iteration, coro, *args, **kwargs), iteration) ) # Use i+1 so that we don't sleep on task 0 and so that # we sleep after 20 iterations instead of 21. @@ -79,10 +79,11 @@ async def qps_test(self, qps, coro, *args): await asyncio.sleep(1) await asyncio.gather(*tasks) - async def qps_task(self, iteration, coro, *args): + async def qps_task(self, iteration, coro, *args, **kwargs): await self.iteration_started(iteration) await coro(*args) - self.iteration_completed(iteration) + if kwargs.get('end_iteration', True): + self.iteration_completed(iteration) def get_current_iteration(): diff --git a/ovn-tester/ovn_tester.py b/ovn-tester/ovn_tester.py index 7af0803f..e5a216e5 100644 --- a/ovn-tester/ovn_tester.py +++ b/ovn-tester/ovn_tester.py @@ -242,8 +242,11 @@ async def run(self, ovn, bringup_cfg): await ovn.create_cluster_join_switch("ls-join") await ovn.create_cluster_load_balancer("lb-cluster") await ctx.qps_test(bringup_cfg.queries_per_second, - self.provisioner, ovn, bringup_cfg) + self.provisioner, ovn, bringup_cfg, + end_iteration=False) await ovn.wait_for_ports_up(self.port_iters) + for _, iteration in self.port_iters: + ctx.iteration_completed(iteration) async def main(global_cfg, cluster_cfg, brex_cfg, bringup_cfg): diff --git a/ovn-tester/tests/cluster_density.py b/ovn-tester/tests/cluster_density.py index 042cefb1..dc5f8e7b 100644 --- a/ovn-tester/tests/cluster_density.py +++ b/ovn-tester/tests/cluster_density.py @@ -58,7 +58,7 @@ async def run(self, ovn, global_cfg): (self.config.n_runs - self.config.n_startup) // self.batch_ratio, test=self) as ctx: await ctx.qps_test(self.config.queries_per_second, - self.tester, ovn, all_ns) + self.tester, ovn, all_ns, end_iteration=False) await ovn.wait_for_ports_up(self.test_port_iters) if not global_cfg.cleanup: diff --git a/ovn-tester/tests/density_heavy.py b/ovn-tester/tests/density_heavy.py index ae3b2290..86430184 100644 --- a/ovn-tester/tests/density_heavy.py +++ b/ovn-tester/tests/density_heavy.py @@ -80,8 +80,11 @@ async def run(self, ovn, global_cfg): (self.config.n_pods - self.config.n_startup) // self.config.batch, test=self) as ctx: await ctx.qps_test(self.config.queries_per_second, - self.provisioner, ns, ovn) + self.provisioner, ns, ovn, + end_iteration=False) await ovn.wait_for_ports_up(self.test_port_iters) + for _, iteration in self.test_port_iters: + ctx.iteration_completed(iteration) if not global_cfg.cleanup: return diff --git a/ovn-tester/tests/density_light.py b/ovn-tester/tests/density_light.py index d757658b..a660c2ea 100644 --- a/ovn-tester/tests/density_light.py +++ b/ovn-tester/tests/density_light.py @@ -34,8 +34,11 @@ async def run(self, ovn, global_cfg): n_iterations = self.config.n_pods - self.config.n_startup with Context('density_light', n_iterations, test=self) as ctx: await ctx.qps_test(self.config.queries_per_second, - self.provisioner, ns, ovn) + self.provisioner, ns, ovn, + end_iteration=False) await ovn.wait_for_ports_up(self.test_port_iters) + for _, iteration in self.test_port_iters: + ctx.iteration_completed(iteration) if not global_cfg.cleanup: return