Skip to content

Commit

Permalink
ovn-tester: Use QPS method for cluster_density test.
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Michelson <[email protected]>
  • Loading branch information
putnopvut committed Sep 2, 2021
1 parent 81153f4 commit 768ca72
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions ovn-tester/tests/cluster_density.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import namedtuple
from ovn_context import Context
from ovn_context import Context, get_current_iteration
from ovn_ext_cmd import ExtCmd
import ovn_exceptions
from ovn_workload import create_namespace
Expand All @@ -13,7 +13,8 @@
ClusterDensityCfg = namedtuple('ClusterDensityCfg',
['n_runs',
'batch',
'n_startup'])
'n_startup',
'queries_per_second'])


class ClusterDensity(ExtCmd):
Expand All @@ -24,7 +25,8 @@ def __init__(self, config, central_node, worker_nodes):
self.config = ClusterDensityCfg(
n_runs=test_config.get('n_runs', 0),
batch=test_config.get('batch', DENSITY_N_TOT_PODS),
n_startup=test_config.get('n_startup', 0)
n_startup=test_config.get('n_startup', 0),
queries_per_second=test_config.get('queries_per_second', 20),
)
if self.config.batch % DENSITY_N_TOT_PODS:
raise ovn_exceptions.OvnInvalidConfigException()
Expand Down Expand Up @@ -54,35 +56,38 @@ async def run(self, ovn, global_cfg):
with Context('cluster_density',
(self.config.n_runs - self.config.n_startup) //
self.batch_ratio, test=self) as ctx:
for i in ctx:
ns = await create_namespace(
ovn, f'NS_density_{self.config.n_startup + i}')
await ns.create_load_balancer()
await ovn.provision_lb(ns.load_balancer)
all_ns.append(ns)

iter_ports = await ovn.provision_ports(self.config.batch)
for j in range(self.batch_ratio):
# create 6 short lived "build" pods
build_ports = iter_ports[
j*DENSITY_N_TOT_PODS:
j*DENSITY_N_TOT_PODS+DENSITY_N_BUILD_PODS]
await ns.add_ports(build_ports)
await ovn.ping_ports(build_ports)
# create 4 legacy pods
ports = iter_ports[
j*DENSITY_N_TOT_PODS+DENSITY_N_BUILD_PODS:
(j+1)*DENSITY_N_TOT_PODS]
await ns.add_ports(ports)
# add VIPs and backends to namespace load-balancer
await ns.provision_vips_to_load_balancers(
[ports[0:2], ports[2:3], ports[3:4]])

await ovn.ping_ports(ports)
await ns.unprovision_ports(build_ports)
await ctx.qps_test(self.config.queries_per_second,
self.tester, ovn, all_ns)

if not global_cfg.cleanup:
return
with Context('cluster_density_cleanup', brief_report=True) as ctx:
for ns in all_ns:
await ns.unprovision()

async def tester(self, ovn, all_ns):
iteration = get_current_iteration()
ns_num = self.config.n_startup + iteration.num
ns = await create_namespace(ovn, f'NS_density_{ns_num}')
await ns.create_load_balancer()
await ovn.provision_lb(ns.load_balancer)
all_ns.append(ns)

iter_ports = await ovn.provision_ports(self.config.batch)
for j in range(self.batch_ratio):
# create 6 short lived "build" pods
build_ports = iter_ports[
j*DENSITY_N_TOT_PODS:
j*DENSITY_N_TOT_PODS+DENSITY_N_BUILD_PODS]
await ns.add_ports(build_ports)
await ovn.ping_ports(build_ports)
# create 4 legacy pods
ports = iter_ports[
j*DENSITY_N_TOT_PODS+DENSITY_N_BUILD_PODS:
(j+1)*DENSITY_N_TOT_PODS]
await ns.add_ports(ports)
# add VIPs and backends to cluster load-balancer
await ns.provision_vips_to_load_balancers(
[ports[0:1], ports[2:3], ports[3:4]])
await ovn.ping_ports(ports)
await ns.unprovision_ports(build_ports)

0 comments on commit 768ca72

Please sign in to comment.