tests: Topotests daemon start as per feature test

Currently topotests starts all daemons by default,
made changes to f/w so only needed daemons can
be started, daemons which are needed to tests
particular test suite.

Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
This commit is contained in:
Kuldeep Kashyap 2022-12-09 07:21:29 -08:00
parent 22e60ca210
commit dc4c450fc2
5 changed files with 64 additions and 68 deletions

View File

@ -76,15 +76,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_as_allow_in.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables
BGP_CONVERGENCE = False
ADDR_TYPES = check_address_types()
@ -92,13 +83,6 @@ NETWORK = {"ipv4": "2.2.2.2/32", "ipv6": "22:22::2/128"}
NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
def build_topo(tgen):
"""Build function"""
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod):
"""
Sets up the pytest environment
@ -118,7 +102,11 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
tgen = Topogen(build_topo, mod.__name__)
json_file = "{}/bgp_as_allow_in.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
global topo
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers

View File

@ -75,15 +75,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/bgp_vrf_dynamic_route_leak_topo2.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK1_1 = {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"}
NETWORK3_3 = {"ipv4": "50.50.50.5/32", "ipv6": "50:50::5/128"}
@ -92,13 +83,6 @@ NETWORK3_4 = {"ipv4": "50.50.50.50/32", "ipv6": "50:50::50/128"}
PREFERRED_NEXT_HOP = "global"
def build_topo(tgen):
"""Build function"""
# Building topology from json file
build_topo_from_json(tgen, topo)
def setup_module(mod):
"""
Sets up the pytest environment
@ -114,7 +98,9 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
tgen = Topogen(build_topo, mod.__name__)
json_file = "{}/bgp_vrf_dynamic_route_leak_topo2.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers

View File

@ -86,15 +86,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
# Reading the data from JSON File for topology creation
jsonFile = "{}/evpn_type5_topo1.json".format(CWD)
try:
with open(jsonFile, "r") as topoJson:
topo = json.load(topoJson)
except IOError:
assert False, "Could not read file {}".format(jsonFile)
# Global variables
NETWORK1_1 = {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
NETWORK1_2 = {"ipv4": "40.1.1.1/32", "ipv6": "40::1/128"}
@ -135,10 +126,6 @@ BRCTL = {
}
def build_topo(tgen):
build_topo_from_json(tgen, topo)
def setup_module(mod):
"""
Sets up the pytest environment
@ -154,7 +141,10 @@ def setup_module(mod):
logger.info("Running setup_module to create topology")
# This function initiates the topology build with Topogen...
tgen = Topogen(build_topo, mod.__name__)
json_file = "{}/evpn_type5_topo1.json".format(CWD)
tgen = Topogen(json_file, mod.__name__)
topo = tgen.json_topo
# ... and here it calls Mininet initialization functions.
# Starting topology, create tmp files which are loaded to routers

View File

@ -1009,40 +1009,72 @@ def start_topology(tgen, daemon=None):
except IOError as err:
logger.error("I/O error({0}): {1}".format(err.errno, err.strerror))
# Loading empty zebra.conf file to router, to start the zebra daemon
topo = tgen.json_topo
feature = set()
if "feature" in topo:
feature.update(topo["feature"])
if rname in topo["routers"]:
for key in topo["routers"][rname].keys():
feature.add(key)
for val in topo["routers"][rname]["links"].values():
if "pim" in val:
feature.add("pim")
break
for val in topo["routers"][rname]["links"].values():
if "pim6" in val:
feature.add("pim6")
break
for val in topo["routers"][rname]["links"].values():
if "ospf6" in val:
feature.add("ospf6")
break
if "switches" in topo and rname in topo["switches"]:
for val in topo["switches"][rname]["links"].values():
if "ospf" in val:
feature.add("ospf")
break
if "ospf6" in val:
feature.add("ospf6")
break
# Loading empty zebra.conf file to router, to start the zebra deamon
router.load_config(
TopoRouter.RD_ZEBRA, "{}/{}/zebra.conf".format(tgen.logdir, rname)
)
# Loading empty bgpd.conf file to router, to start the bgp daemon
router.load_config(
TopoRouter.RD_BGP, "{}/{}/bgpd.conf".format(tgen.logdir, rname)
)
if daemon and "ospfd" in daemon:
# Loading empty ospf.conf file to router, to start the bgp daemon
# Loading empty bgpd.conf file to router, to start the bgp deamon
if "bgp" in feature:
router.load_config(
TopoRouter.RD_OSPF, "{}/{}/ospfd.conf".format(tgen.logdir, rname)
TopoRouter.RD_BGP, "{}/{}/bgpd.conf".format(tgen.logdir, rname)
)
if daemon and "ospf6d" in daemon:
# Loading empty ospf.conf file to router, to start the bgp daemon
router.load_config(
TopoRouter.RD_OSPF6, "{}/{}/ospf6d.conf".format(tgen.logdir, rname)
)
if daemon and "pimd" in daemon:
# Loading empty pimd.conf file to router, to start the pim deamon
# Loading empty pimd.conf file to router, to start the pim deamon
if "pim" in feature:
router.load_config(
TopoRouter.RD_PIM, "{}/{}/pimd.conf".format(tgen.logdir, rname)
)
if daemon and "pim6d" in daemon:
# Loading empty pimd.conf file to router, to start the pim6d deamon
# Loading empty pimd.conf file to router, to start the pim deamon
if "pim6" in feature:
router.load_config(
TopoRouter.RD_PIM6, "{}/{}/pim6d.conf".format(tgen.logdir, rname)
)
if "ospf" in feature:
# Loading empty ospf.conf file to router, to start the ospf deamon
router.load_config(
TopoRouter.RD_OSPF, "{}/{}/ospfd.conf".format(tgen.logdir, rname)
)
if "ospf6" in feature:
# Loading empty ospf.conf file to router, to start the ospf deamon
router.load_config(
TopoRouter.RD_OSPF6, "{}/{}/ospf6d.conf".format(tgen.logdir, rname)
)
# Starting routers
logger.info("Starting all routers once topology is created")
tgen.start_router()

View File

@ -1,5 +1,5 @@
{
"feature": ["bgp"],
"ipv4base": "10.0.0.0",
"ipv4mask": 24,
"link_ip_start": {