diff --git a/ovn-tester/cms/ovn_kubernetes/tests/density_heavy.py b/ovn-tester/cms/ovn_kubernetes/tests/density_heavy.py index 1c3d87f1..852cbd81 100644 --- a/ovn-tester/cms/ovn_kubernetes/tests/density_heavy.py +++ b/ovn-tester/cms/ovn_kubernetes/tests/density_heavy.py @@ -2,6 +2,7 @@ from ovn_context import Context from cms.ovn_kubernetes import Namespace from ovn_ext_cmd import ExtCmd +from ovn_utils import distribute_n_tasks_per_clusters import ovn_load_balancer as lb import ovn_exceptions import netaddr @@ -72,13 +73,20 @@ def run(self, clusters, global_cfg): return ns = Namespace(clusters, 'ns_density_heavy', global_cfg) + n_startup_per_cluster = distribute_n_tasks_per_clusters( + self.config.n_startup, len(clusters) + ) + with Context( clusters, 'density_heavy_startup', brief_report=True ) as ctx: - for i in range( - 0, self.config.n_startup, self.config.pods_vip_ratio - ): - self.run_iteration(clusters, ns, i, global_cfg, passive=True) + for i in range(len(clusters)): + for j in range( + 0, n_startup_per_cluster[i], self.config.pods_vip_ratio + ): + self.run_iteration( + clusters, ns, j, global_cfg, passive=True + ) with Context( clusters, diff --git a/ovn-tester/cms/ovn_kubernetes/tests/density_light.py b/ovn-tester/cms/ovn_kubernetes/tests/density_light.py index a0bf135d..3327f016 100644 --- a/ovn-tester/cms/ovn_kubernetes/tests/density_light.py +++ b/ovn-tester/cms/ovn_kubernetes/tests/density_light.py @@ -2,6 +2,7 @@ from ovn_context import Context from cms.ovn_kubernetes import Namespace from ovn_ext_cmd import ExtCmd +from ovn_utils import distribute_n_tasks_per_clusters DensityCfg = namedtuple( @@ -21,12 +22,16 @@ def __init__(self, config, clusters, global_cfg): def run(self, clusters, global_cfg): ns = Namespace(clusters, 'ns_density_light', global_cfg) + n_startup_per_cluster = distribute_n_tasks_per_clusters( + self.config.n_startup, len(clusters) + ) + with Context( clusters, 'density_light_startup', len(clusters), brief_report=True ) as ctx: for i in ctx: ports = clusters[i].provision_ports( - self.config.n_startup, passive=True + n_startup_per_cluster[i], passive=True ) ns.add_ports(ports, i) diff --git a/ovn-tester/ovn_utils.py b/ovn-tester/ovn_utils.py index c79c0a11..49293c94 100644 --- a/ovn-tester/ovn_utils.py +++ b/ovn-tester/ovn_utils.py @@ -912,3 +912,8 @@ def uuid_transaction(self, func): def ts_add(self): log.info('Creating transit switch') self.uuid_transaction(partial(self.idl.ts_add, 'ts')) + + +def distribute_n_tasks_per_clusters(n_tasks, n_clusters): + div, rest = divmod(n_tasks, n_clusters) + return [div + 1 if i < rest else div for i in range(n_clusters)]