Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ansible/ceos_topo_converger.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ def converge_topo(self) -> None:
vms = self.converge_vms()
new_topo[key] = vms

# Compute max_fp_num needed for the converged topology so that
# enough OVS bridges are created per prime VM.
max_vlans = max((len(v["vlans"]) for v in vms.values()), default=0)
if max_vlans > 0:
self.converged_topo["max_fp_num"] = max_vlans

# The DUT configuration and general configuration properties should be
# unchanged as well.
key = "DUT"
Expand Down
35 changes: 35 additions & 0 deletions ansible/vtestbed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t0-csonic
group-name: vms6-1
Expand All @@ -29,6 +30,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests cSONiC virtual switch VMs without PortChannels
use_converged_peers: true

- conf-name: vms-kvm-t0-64
group-name: vms6-1
Expand All @@ -44,6 +46,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t0-64-32
group-name: vms6-1
Expand All @@ -59,6 +62,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t1-lag
group-name: vms6-2
Expand All @@ -74,6 +78,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t0-2
group-name: vms6-3
Expand All @@ -89,6 +94,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-dual-t0
group-name: vms6-4
Expand All @@ -105,6 +111,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Dual-TOR testbed
use_converged_peers: true

- conf-name: vms-kvm-multi-asic-t1-lag
group-name: vms6-4
Expand All @@ -120,6 +127,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests multi-asic virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-four-asic-t1-lag
group-name: vms6-4
Expand All @@ -135,6 +143,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests multi-asic virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t2
group-name: vms6-4-m
Expand All @@ -152,6 +161,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: T2 Virtual chassis with Multi-ASIC LCs
use_converged_peers: true

- conf-name: vms-kvm-t0-3
group-name: vms6-6
Expand All @@ -167,6 +177,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-t0-4
group-name: vms6-7
Expand All @@ -182,6 +193,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-dual-mixed
group-name: vms6-8
Expand All @@ -199,6 +211,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Dual-TOR-Mixed testbed
use_converged_peers: true

- conf-name: 8000e-t0
group-name: vms8-1
Expand All @@ -214,6 +227,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests 8000e sonic device
use_converged_peers: true

- conf-name: 8000e-t1
group-name: vms8-1
Expand All @@ -229,6 +243,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests 8000e sonic device
use_converged_peers: true

- conf-name: vms-kvm-wan-pub
group-name: vms6-1
Expand All @@ -244,6 +259,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-4link
group-name: vms6-1
Expand All @@ -259,6 +275,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-pub-cisco
group-name: vms6-1
Expand All @@ -274,6 +291,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-2dut
group-name: vms6-1
Expand All @@ -290,6 +308,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-3link-tg
group-name: vms6-1
Expand All @@ -305,6 +324,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-ecmp
group-name: vms6-1
Expand All @@ -321,6 +341,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-wan-pub-isis
group-name: vms6-1
Expand All @@ -336,6 +357,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-dpu
group-name: vms6-1
Expand All @@ -351,6 +373,7 @@
inv_name: veos_vtb
auto_recover: False
comment: Tests virtual switch vm as DPU
use_converged_peers: true

- conf-name: vms-kvm-t1
group-name: vms6-2
Expand All @@ -366,6 +389,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-m1
group-name: vms6-2
Expand All @@ -381,6 +405,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-c0
group-name: vms6-2
Expand All @@ -396,6 +421,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true

- conf-name: vms-kvm-c0-lo
group-name: vms6-2
Expand All @@ -411,6 +437,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual switch vm
use_converged_peers: true


- conf-name: vms-kvm-ciscovs-7nodes
Expand All @@ -427,6 +454,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual cisco vs vm with 7 nodes
use_converged_peers: true

- conf-name: vms-kvm-ciscovs-5nodes
group-name: vms9-1
Expand All @@ -442,6 +470,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual cisco vs vm with 5 nodes
use_converged_peers: true

- conf-name: vms-kvm-t1-smartswitch
group-name: vms6-1
Expand All @@ -457,6 +486,7 @@
inv_name: veos_vtb
auto_recover: False
comment: Tests virtual switch vm with a DPU
use_converged_peers: true

- conf-name: vms-kvm-t1-smartswitch-ha
group-name: vms6-1
Expand All @@ -473,6 +503,7 @@
inv_name: veos_vtb
auto_recover: False
comment: Tests t1-smartswitch-ha topo deployment with VMs
use_converged_peers: true

- conf-name: vms-kvm-force10-7nodes
group-name: vms9-2
Expand All @@ -488,6 +519,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual force vs vm with 7 nodes
use_converged_peers: true

- conf-name: vms-kvm-vpp-t1-lag
group-name: vms6-2
Expand All @@ -503,6 +535,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual vpp switch vm
use_converged_peers: true

- conf-name: vms-kvm-vpp-t1
group-name: vms6-2
Expand All @@ -518,6 +551,7 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual vpp switch vm
use_converged_peers: true

- conf-name: vms-kvm-vpp-t0
group-name: vms6-3
Expand All @@ -533,3 +567,4 @@
inv_name: veos_vtb
auto_recover: 'False'
comment: Tests virtual vpp switch vm
use_converged_peers: true
35 changes: 34 additions & 1 deletion tests/common/testbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os
import re
import sys
import yaml
import logging

Expand Down Expand Up @@ -377,6 +378,27 @@ def calculate_ptf_dut_intf_map(self, tb):
map[str(ptf_port_index)][dut_index] = int(dut_port_index)
return map

@staticmethod
def _converge_topology(topo_definition):
"""Converge topology in-memory when use_converged_peers is enabled.

This runs the ceos_topo_converger to consolidate multiple VMs of the
same role into fewer prime devices using multi-VRF. It is needed so
that the test fixtures see the converged topology even when the
on-disk YAML file has not been pre-converged (e.g. fresh git checkout
used only for the test run).
"""
ansible_dir = os.path.normpath(
os.path.join(os.path.dirname(__file__), "../../ansible"))
if ansible_dir not in sys.path:
sys.path.insert(0, ansible_dir)
from ceos_topo_converger import SonicTopoConverger # noqa: E402

converger = SonicTopoConverger(topo_definition, os.devnull)
converger.parse_properties()
converger.converge_topo()
return converger.converged_topo

def parse_topo(self):
for tb_name, tb in list(self.testbed_topo.items()):
topo = tb.pop("topo")
Expand All @@ -393,7 +415,18 @@ def parse_topo(self):
topo_dir = os.path.join(os.path.dirname(__file__), self.TOPOLOGY_FILEPATH)
topo_file = os.path.join(topo_dir, "topo_{}.yml".format(topo))
with open(topo_file, 'r') as fh:
tb['topo']['properties'] = yaml.safe_load(fh)
topo_definition = yaml.safe_load(fh)

use_converged = tb.get('use_converged_peers', False)
already_converged = topo_definition.get('topo_is_multi_vrf', False)
if use_converged and not already_converged:
try:
topo_definition = self._converge_topology(topo_definition)
logger.info("Converged topology for testbed %s", tb_name)
except Exception as e:
logger.warning("Failed to converge topology for %s: %s", tb_name, e)

tb['topo']['properties'] = topo_definition
tb['topo']['ptf_map'] = self.calculate_ptf_index_map(tb)
tb['topo']['ptf_map_disabled'] = self.calculate_ptf_index_map_disabled(tb)
tb['topo']['ptf_dut_intf_map'] = self.calculate_ptf_dut_intf_map(tb)
Expand Down
Loading