-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from LorenzoBianconi/ovn-ic
ovn-tester: introduce ovn-ic
- Loading branch information
Showing
21 changed files
with
666 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 76 additions & 18 deletions
94
ovn-tester/cms/ovn_kubernetes/tests/base_cluster_bringup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,91 @@ | ||
from collections import namedtuple | ||
|
||
from randmac import RandMac | ||
from ovn_utils import LSwitch | ||
from ovn_context import Context | ||
from ovn_ext_cmd import ExtCmd | ||
|
||
ClusterBringupCfg = namedtuple('ClusterBringupCfg', ['n_pods_per_node']) | ||
|
||
|
||
class BaseClusterBringup(ExtCmd): | ||
def __init__(self, config, cluster, global_cfg): | ||
super().__init__(config, cluster) | ||
def __init__(self, config, clusters, global_cfg): | ||
super().__init__(config, clusters) | ||
test_config = config.get('base_cluster_bringup', dict()) | ||
self.config = ClusterBringupCfg( | ||
n_pods_per_node=test_config.get('n_pods_per_node', 0), | ||
) | ||
|
||
def run(self, ovn, global_cfg): | ||
# create ovn topology | ||
with Context( | ||
ovn, 'base_cluster_bringup', len(ovn.worker_nodes) | ||
) as ctx: | ||
ovn.create_cluster_router('lr-cluster') | ||
ovn.create_cluster_join_switch('ls-join') | ||
ovn.create_cluster_load_balancer('lb-cluster', global_cfg) | ||
for i in ctx: | ||
worker = ovn.worker_nodes[i] | ||
worker.provision(ovn) | ||
ports = worker.provision_ports( | ||
ovn, self.config.n_pods_per_node | ||
def create_transit_switch(self, cluster): | ||
cluster.icnbctl.ts_add() | ||
|
||
def connect_transit_switch(self, cluster): | ||
uuid = cluster.nbctl.ls_get_uuid('ts', 10) | ||
cluster.ts_switch = LSwitch( | ||
name='ts', | ||
cidr=cluster.cluster_cfg.ts_net.n4, | ||
cidr6=cluster.cluster_cfg.ts_net.n6, | ||
uuid=uuid, | ||
) | ||
rp = cluster.nbctl.lr_port_add( | ||
cluster.router, | ||
f'lr-cluster{cluster.az}-to-ts', | ||
RandMac(), | ||
cluster.cluster_cfg.ts_net.forward(cluster.az), | ||
) | ||
cluster.nbctl.ls_port_add( | ||
cluster.ts_switch, f'ts-to-lr-cluster{cluster.az}', rp | ||
) | ||
cluster.nbctl.lr_port_set_gw_chassis( | ||
rp, cluster.worker_nodes[0].container | ||
) | ||
cluster.worker_nodes[0].vsctl.set_global_external_id( | ||
'ovn-is-interconn', 'true' | ||
) | ||
|
||
def check_ic_connectivity(self, clusters): | ||
ic_cluster = clusters[0] | ||
for cluster in clusters: | ||
if ic_cluster == cluster: | ||
continue | ||
for w in cluster.worker_nodes: | ||
port = w.lports[0] | ||
if port.ip: | ||
ic_cluster.worker_nodes[0].run_ping( | ||
ic_cluster, | ||
ic_cluster.worker_nodes[0].lports[0].name, | ||
port.ip, | ||
) | ||
if port.ip6: | ||
ic_cluster.worker_nodes[0].run_ping( | ||
ic_cluster, | ||
ic_cluster.worker_nodes[0].lports[0].name, | ||
port.ip6, | ||
) | ||
|
||
def run(self, clusters, global_cfg): | ||
self.create_transit_switch(clusters[0]) | ||
|
||
for c, cluster in enumerate(clusters): | ||
# create ovn topology | ||
with Context( | ||
clusters, 'base_cluster_bringup', len(cluster.worker_nodes) | ||
) as ctx: | ||
cluster.create_cluster_router(f'lr-cluster{c+1}') | ||
cluster.create_cluster_join_switch(f'ls-join{c+1}') | ||
cluster.create_cluster_load_balancer( | ||
f'lb-cluster{c+1}', global_cfg | ||
) | ||
worker.provision_load_balancers(ovn, ports, global_cfg) | ||
worker.ping_ports(ovn, ports) | ||
ovn.provision_lb_group() | ||
self.connect_transit_switch(cluster) | ||
for i in ctx: | ||
worker = cluster.worker_nodes[i] | ||
worker.provision(cluster) | ||
ports = worker.provision_ports( | ||
cluster, self.config.n_pods_per_node | ||
) | ||
worker.provision_load_balancers(cluster, ports, global_cfg) | ||
worker.ping_ports(cluster, ports) | ||
cluster.provision_lb_group(f'cluster-lb-group{c+1}') | ||
|
||
# check ic connectivity | ||
self.check_ic_connectivity(clusters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.