Skip to content

Commit

Permalink
ovn-tester: Allow tests to manually end iterations.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
putnopvut committed Oct 7, 2021
1 parent 6e700dd commit a6ed21e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
9 changes: 5 additions & 4 deletions ovn-tester/ovn_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,24 @@ 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.
if (i + 1) % qps == 0:
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():
Expand Down
5 changes: 4 additions & 1 deletion ovn-tester/ovn_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion ovn-tester/tests/cluster_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion ovn-tester/tests/density_heavy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion ovn-tester/tests/density_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6ed21e

Please sign in to comment.