diff --git a/ovn-tester/ovn_tester.py b/ovn-tester/ovn_tester.py index 8c991283..552c8f18 100644 --- a/ovn-tester/ovn_tester.py +++ b/ovn-tester/ovn_tester.py @@ -343,7 +343,6 @@ def run_base_cluster_bringup(clusters, bringup_cfg, global_cfg): clusters = prepare_test(central_nodes, worker_nodes, cluster_cfg, brex_cfg) run_base_cluster_bringup(clusters, bringup_cfg, global_cfg) - # FIXME run workloads for all clusters for test in tests: - test.run(clusters[0], global_cfg) + test.run(clusters, global_cfg) sys.exit(0) diff --git a/ovn-tester/ovn_workload.py b/ovn-tester/ovn_workload.py index c91636bf..70fc6f1b 100644 --- a/ovn-tester/ovn_workload.py +++ b/ovn-tester/ovn_workload.py @@ -475,195 +475,218 @@ def get_connection_string(self, cluster_cfg, port): class Namespace(object): - def __init__(self, cluster, name, global_cfg): - self.cluster = cluster - self.nbctl = cluster.nbctl - self.ports = [] + def __init__(self, clusters, name, global_cfg): + self.clusters = clusters + self.nbctl = [cluster.nbctl for cluster in clusters] + self.ports = [[] for _ in range(len(clusters))] self.enforcing = False - self.pg_def_deny_igr = self.nbctl.port_group_create( - f'pg_deny_igr_{name}' - ) - self.pg_def_deny_egr = self.nbctl.port_group_create( - f'pg_deny_egr_{name}' - ) - self.pg = self.nbctl.port_group_create(f'pg_{name}') - self.addr_set4 = ( - self.nbctl.address_set_create(f'as_{name}') - if global_cfg.run_ipv4 - else None - ) - self.addr_set6 = ( - self.nbctl.address_set_create(f'as6_{name}') - if global_cfg.run_ipv6 - else None - ) + self.pg_def_deny_igr = [ + nbctl.port_group_create(f'pg_deny_igr_{name}') + for nbctl in self.nbctl + ] + self.pg_def_deny_egr = [ + nbctl.port_group_create(f'pg_deny_egr_{name}') + for nbctl in self.nbctl + ] + self.pg = [ + nbctl.port_group_create(f'pg_{name}') for nbctl in self.nbctl + ] + self.addr_set4 = [ + ( + nbctl.address_set_create(f'as_{name}') + if global_cfg.run_ipv4 + else None + ) + for nbctl in self.nbctl + ] + self.addr_set6 = [ + ( + nbctl.address_set_create(f'as6_{name}') + if global_cfg.run_ipv6 + else None + ) + for nbctl in self.nbctl + ] self.sub_as = [] self.sub_pg = [] self.load_balancer = None - self.cluster.n_ns += 1 + for cluster in self.clusters: + cluster.n_ns += 1 self.name = name @ovn_stats.timeit - def add_ports(self, ports): - self.ports.extend(ports) + def add_ports(self, ports, cluster_id=0): + self.ports[cluster_id].extend(ports) # Always add port IPs to the address set but not to the PGs. # Simulate what OpenShift does, which is: create the port groups # when the first network policy is applied. if self.addr_set4: - self.nbctl.address_set_add_addrs( - self.addr_set4, [str(p.ip) for p in ports] - ) + for i, nbctl in enumerate(self.nbctl): + nbctl.address_set_add_addrs( + self.addr_set4[i], [str(p.ip) for p in ports] + ) if self.addr_set6: - self.nbctl.address_set_add_addrs( - self.addr_set6, [str(p.ip6) for p in ports] - ) + for i, nbctl in enumerate(self.nbctl): + nbctl.address_set_add_addrs( + self.addr_set6[i], [str(p.ip6) for p in ports] + ) if self.enforcing: - self.nbctl.port_group_add_ports(self.pg_def_deny_igr, ports) - self.nbctl.port_group_add_ports(self.pg_def_deny_egr, ports) - self.nbctl.port_group_add_ports(self.pg, ports) + self.nbctl[cluster_id].port_group_add_ports( + self.pg_def_deny_igr[cluster_id], ports + ) + self.nbctl[cluster_id].port_group_add_ports( + self.pg_def_deny_egr[cluster_id], ports + ) + self.nbctl[cluster_id].port_group_add_ports( + self.pg[cluster_id], ports + ) def unprovision(self): # ACLs are garbage collected by OVSDB as soon as all the records # referencing them are removed. - self.cluster.unprovision_ports(self.ports) - self.nbctl.port_group_del(self.pg_def_deny_igr) - self.nbctl.port_group_del(self.pg_def_deny_egr) - self.nbctl.port_group_del(self.pg) - if self.addr_set4: - self.nbctl.address_set_del(self.addr_set4) - if self.addr_set6: - self.nbctl.address_set_del(self.addr_set6) - for pg in self.sub_pg: - self.nbctl.port_group_del(pg) - for addr_set in self.sub_as: - self.nbctl.address_set_del(addr_set) - - def unprovision_ports(self, ports): + for i, cluster in enumerate(self.clusters): + cluster.unprovision_ports(self.ports[i]) + for i, nbctl in enumerate(self.nbctl): + nbctl.port_group_del(self.pg_def_deny_igr[i]) + nbctl.port_group_del(self.pg_def_deny_egr[i]) + nbctl.port_group_del(self.pg[i]) + if self.addr_set4: + nbctl.address_set_del(self.addr_set4[i]) + if self.addr_set6: + nbctl.address_set_del(self.addr_set6[i]) + # FIXME + for pg in self.sub_pg: + nbctl.port_group_del(pg) + for addr_set in self.sub_as: + nbctl.address_set_del(addr_set) + + def unprovision_ports(self, ports, cluster_id=0): '''Unprovision a subset of ports in the namespace without having to unprovision the entire namespace or any of its network policies.''' for port in ports: - self.ports.remove(port) + self.ports[cluster_id].remove(port) - self.cluster.unprovision_ports(ports) + self.clusters[cluster_id].unprovision_ports(ports) def enforce(self): if self.enforcing: return self.enforcing = True - self.nbctl.port_group_add_ports(self.pg_def_deny_igr, self.ports) - self.nbctl.port_group_add_ports(self.pg_def_deny_egr, self.ports) - self.nbctl.port_group_add_ports(self.pg, self.ports) + for i, nbctl in enumerate(self.nbctl): + nbctl.port_group_add_ports(self.pg_def_deny_igr[i], self.ports[i]) + nbctl.port_group_add_ports(self.pg_def_deny_egr[i], self.ports[i]) + nbctl.port_group_add_ports(self.pg[i], self.ports[i]) - def create_sub_ns(self, ports, global_cfg): + def create_sub_ns(self, ports, global_cfg, cluster_id=0): n_sub_pgs = len(self.sub_pg) suffix = f'{self.name}_{n_sub_pgs}' - pg = self.nbctl.port_group_create(f'sub_pg_{suffix}') - self.nbctl.port_group_add_ports(pg, ports) + pg = self.nbctl[cluster_id].port_group_create(f'sub_pg_{suffix}') + self.nbctl[cluster_id].port_group_add_ports(pg, ports) self.sub_pg.append(pg) if global_cfg.run_ipv4: - addr_set = self.nbctl.address_set_create(f'sub_as_{suffix}') - self.nbctl.address_set_add_addrs( + addr_set = self.nbctl[cluster_id].address_set_create(f'sub_as_{suffix}') + self.nbctl[cluster_id].address_set_add_addrs( addr_set, [str(p.ip) for p in ports] ) self.sub_as.append(addr_set) if global_cfg.run_ipv6: - addr_set = self.nbctl.address_set_create(f'sub_as_{suffix}6') - self.nbctl.address_set_add_addrs( + addr_set = self.nbctl[cluster_id].address_set_create(f'sub_as_{suffix}6') + self.nbctl[cluster_id].address_set_add_addrs( addr_set, [str(p.ip6) for p in ports] ) self.sub_as.append(addr_set) return n_sub_pgs @ovn_stats.timeit - def default_deny(self, family): + def default_deny(self, family, cluster_id=0): self.enforce() addr_set = f'self.addr_set{family}.name' - self.nbctl.acl_add( - self.pg_def_deny_igr.name, + self.nbctl[cluster_id].acl_add( + self.pg_def_deny_igr[cluster_id].name, 'to-lport', ACL_DEFAULT_DENY_PRIO, 'port-group', f'ip4.src == \\${addr_set} && ' - f'outport == @{self.pg_def_deny_igr.name}', + f'outport == @{self.pg_def_deny_igr[cluster_id].name}', 'drop', ) - self.nbctl.acl_add( - self.pg_def_deny_egr.name, + self.nbctl[cluster_id].acl_add( + self.pg_def_deny_egr[cluster_id].name, 'to-lport', ACL_DEFAULT_DENY_PRIO, 'port-group', f'ip4.dst == \\${addr_set} && ' - f'inport == @{self.pg_def_deny_egr.name}', + f'inport == @{self.pg_def_deny_egr[cluster_id].name}', 'drop', ) - self.nbctl.acl_add( - self.pg_def_deny_igr.name, + self.nbctl[cluster_id].acl_add( + self.pg_def_deny_igr[cluster_id].name, 'to-lport', ACL_DEFAULT_ALLOW_ARP_PRIO, 'port-group', - f'outport == @{self.pg_def_deny_igr.name} && arp', + f'outport == @{self.pg_def_deny_igr[cluster_id].name} && arp', 'allow', ) - self.nbctl.acl_add( - self.pg_def_deny_egr.name, + self.nbctl[cluster_id].acl_add( + self.pg_def_deny_egr[cluster_id].name, 'to-lport', ACL_DEFAULT_ALLOW_ARP_PRIO, 'port-group', - f'inport == @{self.pg_def_deny_egr.name} && arp', + f'inport == @{self.pg_def_deny_egr[cluster_id].name} && arp', 'allow', ) @ovn_stats.timeit - def allow_within_namespace(self, family): + def allow_within_namespace(self, family, cluster_id=0): self.enforce() addr_set = f'self.addr_set{family}.name' - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', - f'ip4.src == \\${addr_set} && outport == @{self.pg.name}', + f'ip4.src == \\${addr_set} && outport == @{self.pg[cluster_id].name}', 'allow-related', ) - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', - f'ip4.dst == \\${addr_set} && inport == @{self.pg.name}', + f'ip4.dst == \\${addr_set} && inport == @{self.pg[cluster_id].name}', 'allow-related', ) @ovn_stats.timeit - def allow_cross_namespace(self, ns, family): + def allow_cross_namespace(self, ns, family, cluster_id=0): self.enforce() addr_set = f'self.addr_set{family}.name' - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', - f'ip4.src == \\${addr_set} && outport == @{ns.pg.name}', + f'ip4.src == \\${addr_set} && outport == @{ns.pg[cluster_id].name}', 'allow-related', ) ns_addr_set = f'ns.addr_set{family}.name' - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', - f'ip4.dst == \\${ns_addr_set} && inport == @{self.pg.name}', + f'ip4.dst == \\${ns_addr_set} && inport == @{self.pg[cluster_id].name}', 'allow-related', ) @ovn_stats.timeit - def allow_sub_namespace(self, src, dst, family): - self.nbctl.acl_add( - self.pg.name, + def allow_sub_namespace(self, src, dst, family, cluster_id=0): + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', @@ -671,8 +694,8 @@ def allow_sub_namespace(self, src, dst, family): f'outport == @{self.sub_pg[dst].name}', 'allow-related', ) - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', @@ -683,34 +706,34 @@ def allow_sub_namespace(self, src, dst, family): @ovn_stats.timeit def allow_from_external( - self, external_ips, include_ext_gw=False, family=4 + self, external_ips, include_ext_gw=False, family=4, cluster_id=0 ): self.enforce() # If requested, include the ext-gw of the first port in the namespace # so we can check that this rule is enforced. if include_ext_gw: assert len(self.ports) > 0 - if family == 4 and self.ports[0].ext_gw: - external_ips.append(self.ports[0].ext_gw) - elif family == 6 and self.ports[0].ext_gw6: - external_ips.append(self.ports[0].ext_gw6) + if family == 4 and self.ports[cluster_id][0].ext_gw: + external_ips.append(self.ports[cluster_id][0].ext_gw) + elif family == 6 and self.ports[cluster_id][0].ext_gw6: + external_ips.append(self.ports[cluster_id][0].ext_gw6) ips = [str(ip) for ip in external_ips] - self.nbctl.acl_add( - self.pg.name, + self.nbctl[cluster_id].acl_add( + self.pg[cluster_id].name, 'to-lport', ACL_NETPOL_ALLOW_PRIO, 'port-group', f'ip.{family} == {{{",".join(ips)}}} && ' - f'outport == @{self.pg.name}', + f'outport == @{self.pg[cluster_id].name}', 'allow-related', ) @ovn_stats.timeit - def check_enforcing_internal(self): + def check_enforcing_internal(self, cluster_id=0): # "Random" check that first pod can reach last pod in the namespace. if len(self.ports) > 1: - src = self.ports[0] - dst = self.ports[-1] + src = self.ports[cluster_id][0] + dst = self.ports[cluster_id][-1] worker = src.metadata if src.ip: worker.ping_port(self.cluster, src, dst.ip) @@ -718,37 +741,42 @@ def check_enforcing_internal(self): worker.ping_port(self.cluster, src, dst.ip6) @ovn_stats.timeit - def check_enforcing_external(self): + def check_enforcing_external(self, cluster_id=0): if len(self.ports) > 0: - dst = self.ports[0] + dst = self.ports[cluster_id][0] worker = dst.metadata worker.ping_external(self.cluster, dst) @ovn_stats.timeit - def check_enforcing_cross_ns(self, ns): + def check_enforcing_cross_ns(self, ns, cluster_id=0): if len(self.ports) > 0 and len(ns.ports) > 0: - dst = ns.ports[0] - src = self.ports[0] + dst = ns.ports[cluster_id][0] + src = self.ports[cluster_id][0] worker = src.metadata if src.ip and dst.ip: worker.ping_port(self.cluster, src, dst.ip) if src.ip6 and dst.ip6: worker.ping_port(self.cluster, src, dst.ip6) - def create_load_balancer(self): - self.load_balancer = lb.OvnLoadBalancer(f'lb_{self.name}', self.nbctl) + def create_load_balancer(self, cluster_id=0): + self.load_balancer = lb.OvnLoadBalancer( + f'lb_{self.name}', self.nbctl[cluster_id] + ) @ovn_stats.timeit - def provision_vips_to_load_balancers(self, backend_lists, version): + def provision_vips_to_load_balancers( + self, backend_lists, version, cluster_id=0 + ): vip_ns_subnet = DEFAULT_NS_VIP_SUBNET if version == 6: vip_ns_subnet = DEFAULT_NS_VIP_SUBNET6 - vip_net = vip_ns_subnet.next(self.cluster.n_ns) + # FIXME + vip_net = vip_ns_subnet.next(self.clusters[cluster_id].n_ns) n_vips = len(self.load_balancer.vips.keys()) vip_ip = vip_net.ip.__add__(n_vips + 1) if version == 6: - vips = { + vips = { f'[{vip_ip + i}]:{DEFAULT_VIP_PORT}': [ f'[{p.ip6}]:{DEFAULT_BACKEND_PORT}' for p in ports ] diff --git a/ovn-tester/tests/cluster_density.py b/ovn-tester/tests/cluster_density.py index 940ff468..0ffa93d2 100644 --- a/ovn-tester/tests/cluster_density.py +++ b/ovn-tester/tests/cluster_density.py @@ -30,7 +30,7 @@ def __init__(self, config, central_nodes, worker_nodes, global_cfg): raise ovn_exceptions.OvnInvalidConfigException() def run_iteration(self, ovn, index, global_cfg, passive): - ns = Namespace(ovn, f'NS_density_{index}', global_cfg) + ns = Namespace([ovn], f'NS_density_{index}', global_cfg) # Create DENSITY_N_BUILD_PODS short lived "build" pods. if not passive: build_ports = ovn.provision_ports(DENSITY_N_BUILD_PODS, passive) @@ -58,10 +58,11 @@ def run_iteration(self, ovn, index, global_cfg, passive): ns.unprovision_ports(build_ports) return ns - def run(self, ovn, global_cfg): + def run(self, clusters, global_cfg): + ovn = clusters[0] all_ns = [] with Context( - [ovn], 'cluster_density_startup', brief_report=True + clusters, 'cluster_density_startup', brief_report=True ) as ctx: for index in range(self.config.n_startup): all_ns.append( @@ -69,7 +70,7 @@ def run(self, ovn, global_cfg): ) with Context( - [ovn], + clusters, 'cluster_density', self.config.n_runs - self.config.n_startup, test=self, @@ -83,7 +84,7 @@ def run(self, ovn, global_cfg): if not global_cfg.cleanup: return with Context( - [ovn], 'cluster_density_cleanup', brief_report=True + clusters, 'cluster_density_cleanup', brief_report=True ) as ctx: for ns in all_ns: ns.unprovision() diff --git a/ovn-tester/tests/density_heavy.py b/ovn-tester/tests/density_heavy.py index 8abf38a2..e4fd8cb2 100644 --- a/ovn-tester/tests/density_heavy.py +++ b/ovn-tester/tests/density_heavy.py @@ -66,19 +66,22 @@ def run_iteration(self, ovn, ns, index, global_cfg, passive): if not passive: ovn.ping_ports(ports) - def run(self, ovn, global_cfg): + def run(self, clusters, global_cfg): + ovn = clusters[0] if self.config.pods_vip_ratio == 0: return - ns = Namespace(ovn, 'ns_density_heavy', global_cfg) - with Context([ovn], 'density_heavy_startup', brief_report=True) as ctx: + ns = Namespace([ovn], 'ns_density_heavy', global_cfg) + 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(ovn, ns, i, global_cfg, passive=True) with Context( - [ovn], + clusters, 'density_heavy', (self.config.n_pods - self.config.n_startup) / self.config.pods_vip_ratio, @@ -90,6 +93,8 @@ def run(self, ovn, global_cfg): if not global_cfg.cleanup: return - with Context([ovn], 'density_heavy_cleanup', brief_report=True) as ctx: + with Context( + clusters, 'density_heavy_cleanup', brief_report=True + ) as ctx: ovn.unprovision_vips() ns.unprovision() diff --git a/ovn-tester/tests/density_light.py b/ovn-tester/tests/density_light.py index 103cd692..648063cb 100644 --- a/ovn-tester/tests/density_light.py +++ b/ovn-tester/tests/density_light.py @@ -19,22 +19,30 @@ def __init__(self, config, central_nodes, worker_nodes, global_cfg): pods_vip_ratio=0, ) - def run(self, ovn, global_cfg): - ns = Namespace(ovn, 'ns_density_light', global_cfg) + def run(self, clusters, global_cfg): + ns = Namespace(clusters, 'ns_density_light', global_cfg) with Context( - [ovn], 'density_light_startup', 1, brief_report=True + clusters, 'density_light_startup', len(clusters), brief_report=True ) as ctx: - ports = ovn.provision_ports(self.config.n_startup, passive=True) - ns.add_ports(ports) + for i in ctx: + ports = clusters[i].provision_ports( + self.config.n_startup, passive=True + ) + ns.add_ports(ports, i) n_iterations = self.config.n_pods - self.config.n_startup - with Context([ovn], 'density_light', n_iterations, test=self) as ctx: + with Context( + clusters, 'density_light', n_iterations, test=self + ) as ctx: for i in ctx: + ovn = clusters[i % len(clusters)] ports = ovn.provision_ports(1) - ns.add_ports(ports[0:1]) + ns.add_ports(ports[0:1], i % len(clusters)) ovn.ping_ports(ports) if not global_cfg.cleanup: return - with Context([ovn], 'density_light_cleanup', brief_report=True) as ctx: + with Context( + clusters, 'density_light_cleanup', brief_report=True + ) as ctx: ns.unprovision() diff --git a/ovn-tester/tests/netpol.py b/ovn-tester/tests/netpol.py index 2c0959cc..c31f4b7f 100644 --- a/ovn-tester/tests/netpol.py +++ b/ovn-tester/tests/netpol.py @@ -25,8 +25,9 @@ def __init__(self, name, config, central_nodes, worker_nodes): self.all_ns = [] self.ports = [] - def init(self, ovn, global_cfg): - with Context([ovn], f'{self.name}_startup', brief_report=True) as _: + def init(self, clusters, global_cfg): + with Context(clusters, f'{self.name}_startup', brief_report=True) as _: + ovn = clusters[0] self.ports = ovn.provision_ports( self.config.pods_ns_ratio * self.config.n_ns ) @@ -36,7 +37,7 @@ def init(self, ovn, global_cfg): ).append(self.ports[i]) for i in range(self.config.n_ns): - ns = Namespace(ovn, f'NS_{self.name}_{i}', global_cfg) + ns = Namespace([ovn], f'NS_{self.name}_{i}', global_cfg) ns.add_ports( self.ports[ i @@ -47,8 +48,9 @@ def init(self, ovn, global_cfg): ns.default_deny(4) self.all_ns.append(ns) - def run(self, ovn, global_cfg, exclude=False): - with Context([ovn], self.name, self.config.n_ns, test=self) as ctx: + def run(self, clusters, global_cfg, exclude=False): + ovn = clusters[0] + with Context(clusters, self.name, self.config.n_ns, test=self) as ctx: for i in ctx: ns = self.all_ns[i] for lbl in range(self.config.n_labels): @@ -75,6 +77,8 @@ def run(self, ovn, global_cfg, exclude=False): if not global_cfg.cleanup: return - with Context([ovn], f'{self.name}_cleanup', brief_report=True) as ctx: + with Context( + clusters, f'{self.name}_cleanup', brief_report=True + ) as ctx: for ns in self.all_ns: ns.unprovision() diff --git a/ovn-tester/tests/netpol_cross_ns.py b/ovn-tester/tests/netpol_cross_ns.py index d1f74d33..a06a328c 100644 --- a/ovn-tester/tests/netpol_cross_ns.py +++ b/ovn-tester/tests/netpol_cross_ns.py @@ -17,18 +17,19 @@ def __init__(self, config, central_nodes, worker_nodes, global_cfg): pods_ns_ratio=test_config.get('pods_ns_ratio', 0), ) - def run(self, ovn, global_cfg): + def run(self, clusters, global_cfg): all_ns = [] with Context( - [ovn], 'netpol_cross_ns_startup', brief_report=True + clusters, 'netpol_cross_ns_startup', brief_report=True ) as ctx: + ovn = clusters[0] ports = ovn.provision_ports( self.config.pods_ns_ratio * self.config.n_ns ) for i in range(self.config.n_ns): ns = Namespace( - ovn, f'NS_netpol_cross_ns_startup_{i}', global_cfg + [ovn], f'NS_netpol_cross_ns_startup_{i}', global_cfg ) ns.add_ports( ports[ @@ -44,7 +45,7 @@ def run(self, ovn, global_cfg): all_ns.append(ns) with Context( - [ovn], 'netpol_cross_ns', self.config.n_ns, test=self + clusters, 'netpol_cross_ns', self.config.n_ns, test=self ) as ctx: for i in ctx: ns = all_ns[i] @@ -58,7 +59,7 @@ def run(self, ovn, global_cfg): if not global_cfg.cleanup: return with Context( - [ovn], 'netpol_cross_ns_cleanup', brief_report=True + clusters, 'netpol_cross_ns_cleanup', brief_report=True ) as ctx: for ns in all_ns: ns.unprovision() diff --git a/ovn-tester/tests/netpol_large.py b/ovn-tester/tests/netpol_large.py index 25e3fca8..fd4e44df 100644 --- a/ovn-tester/tests/netpol_large.py +++ b/ovn-tester/tests/netpol_large.py @@ -7,6 +7,6 @@ def __init__(self, config, central_node, worker_nodes, global_cfg): 'netpol_large', config, central_node, worker_nodes ) - def run(self, ovn, global_cfg): - self.init(ovn, global_cfg) - super(NetpolLarge, self).run(ovn, global_cfg) + def run(self, clusters, global_cfg): + self.init(clusters, global_cfg) + super(NetpolLarge, self).run(clusters, global_cfg) diff --git a/ovn-tester/tests/netpol_multitenant.py b/ovn-tester/tests/netpol_multitenant.py index 69fbe5e7..57c22714 100644 --- a/ovn-tester/tests/netpol_multitenant.py +++ b/ovn-tester/tests/netpol_multitenant.py @@ -35,7 +35,7 @@ def __init__(self, config, central_nodes, worker_nodes, global_cfg): ranges=ranges, ) - def run(self, ovn, global_cfg): + def run(self, clusters, global_cfg): """ Run a multitenant network policy test, for example: @@ -82,15 +82,16 @@ def run(self, ovn, global_cfg): ] all_ns = [] + ovn = clusters[0] with Context( - [ovn], 'netpol_multitenant', self.config.n_namespaces, test=self + clusters, 'netpol_multitenant', self.config.n_namespaces, test=self ) as ctx: for i in ctx: # Get the number of pods from the "highest" range that # includes i. ranges = self.config.ranges n_ports = next((r.n_pods for r in ranges if i >= r.start), 1) - ns = Namespace(ovn, f'ns_netpol_multitenant_{i}', global_cfg) + ns = Namespace([ovn], f'ns_netpol_multitenant_{i}', global_cfg) for _ in range(n_ports): worker = ovn.select_worker_for_port() for p in worker.provision_ports(ovn, 1): @@ -115,7 +116,7 @@ def run(self, ovn, global_cfg): if not global_cfg.cleanup: return with Context( - [ovn], 'netpol_multitenant_cleanup', brief_report=True + clusters, 'netpol_multitenant_cleanup', brief_report=True ) as ctx: for ns in all_ns: ns.unprovision() diff --git a/ovn-tester/tests/netpol_small.py b/ovn-tester/tests/netpol_small.py index 27a4bd08..f0e96e0f 100644 --- a/ovn-tester/tests/netpol_small.py +++ b/ovn-tester/tests/netpol_small.py @@ -7,6 +7,6 @@ def __init__(self, config, central_node, worker_nodes, global_cfg): 'netpol_small', config, central_node, worker_nodes ) - def run(self, ovn, global_cfg): - self.init(ovn, global_cfg) - super(NetpolSmall, self).run(ovn, global_cfg, True) + def run(self, clusters, global_cfg): + self.init(clusters, global_cfg) + super(NetpolSmall, self).run(clusters, global_cfg, True) diff --git a/ovn-tester/tests/service_route.py b/ovn-tester/tests/service_route.py index 8413bb8c..9f4925f2 100644 --- a/ovn-tester/tests/service_route.py +++ b/ovn-tester/tests/service_route.py @@ -49,10 +49,11 @@ def provide_node_load_balancer( load_balancer.add_to_routers([node.gw_router.name]) load_balancer.add_to_switches([node.switch.name]) - def run(self, ovn, global_cfg): - ns = Namespace(ovn, 'ns_service_route', global_cfg) + def run(self, clusters, global_cfg): + ovn = clusters[0] + ns = Namespace([ovn], 'ns_service_route', global_cfg) with Context( - [ovn], 'service_route', self.config.n_lb, test=self + clusters, 'service_route', self.config.n_lb, test=self ) as ctx: for i in ctx: ports = ovn.provision_ports(self.config.n_backends + 1) @@ -88,5 +89,7 @@ def run(self, ovn, global_cfg): if not global_cfg.cleanup: return - with Context([ovn], 'service_route_cleanup', brief_report=True) as ctx: + with Context( + clusters, 'service_route_cleanup', brief_report=True + ) as ctx: ns.unprovision()