mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 11:18:43 +00:00
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:
parent
22e60ca210
commit
dc4c450fc2
@ -76,15 +76,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
|
|||||||
|
|
||||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
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
|
# Global variables
|
||||||
BGP_CONVERGENCE = False
|
BGP_CONVERGENCE = False
|
||||||
ADDR_TYPES = check_address_types()
|
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"}
|
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):
|
def setup_module(mod):
|
||||||
"""
|
"""
|
||||||
Sets up the pytest environment
|
Sets up the pytest environment
|
||||||
@ -118,7 +102,11 @@ def setup_module(mod):
|
|||||||
logger.info("Running setup_module to create topology")
|
logger.info("Running setup_module to create topology")
|
||||||
|
|
||||||
# This function initiates the topology build with Topogen...
|
# 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.
|
# ... and here it calls Mininet initialization functions.
|
||||||
|
|
||||||
# Starting topology, create tmp files which are loaded to routers
|
# Starting topology, create tmp files which are loaded to routers
|
||||||
|
@ -75,15 +75,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
|
|||||||
|
|
||||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
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
|
# Global variables
|
||||||
NETWORK1_1 = {"ipv4": "11.11.11.1/32", "ipv6": "11:11::1/128"}
|
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"}
|
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"
|
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):
|
def setup_module(mod):
|
||||||
"""
|
"""
|
||||||
Sets up the pytest environment
|
Sets up the pytest environment
|
||||||
@ -114,7 +98,9 @@ def setup_module(mod):
|
|||||||
logger.info("Running setup_module to create topology")
|
logger.info("Running setup_module to create topology")
|
||||||
|
|
||||||
# This function initiates the topology build with Topogen...
|
# 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.
|
# ... and here it calls Mininet initialization functions.
|
||||||
|
|
||||||
# Starting topology, create tmp files which are loaded to routers
|
# Starting topology, create tmp files which are loaded to routers
|
||||||
|
@ -86,15 +86,6 @@ from lib.topojson import build_topo_from_json, build_config_from_json
|
|||||||
|
|
||||||
pytestmark = [pytest.mark.bgpd, pytest.mark.staticd]
|
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
|
# Global variables
|
||||||
NETWORK1_1 = {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
|
NETWORK1_1 = {"ipv4": "10.1.1.1/32", "ipv6": "10::1/128"}
|
||||||
NETWORK1_2 = {"ipv4": "40.1.1.1/32", "ipv6": "40::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):
|
def setup_module(mod):
|
||||||
"""
|
"""
|
||||||
Sets up the pytest environment
|
Sets up the pytest environment
|
||||||
@ -154,7 +141,10 @@ def setup_module(mod):
|
|||||||
logger.info("Running setup_module to create topology")
|
logger.info("Running setup_module to create topology")
|
||||||
|
|
||||||
# This function initiates the topology build with Topogen...
|
# 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.
|
# ... and here it calls Mininet initialization functions.
|
||||||
|
|
||||||
# Starting topology, create tmp files which are loaded to routers
|
# Starting topology, create tmp files which are loaded to routers
|
||||||
|
@ -1009,40 +1009,72 @@ def start_topology(tgen, daemon=None):
|
|||||||
except IOError as err:
|
except IOError as err:
|
||||||
logger.error("I/O error({0}): {1}".format(err.errno, err.strerror))
|
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(
|
router.load_config(
|
||||||
TopoRouter.RD_ZEBRA, "{}/{}/zebra.conf".format(tgen.logdir, rname)
|
TopoRouter.RD_ZEBRA, "{}/{}/zebra.conf".format(tgen.logdir, rname)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Loading empty bgpd.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(
|
router.load_config(
|
||||||
TopoRouter.RD_BGP, "{}/{}/bgpd.conf".format(tgen.logdir, rname)
|
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
|
|
||||||
router.load_config(
|
|
||||||
TopoRouter.RD_OSPF, "{}/{}/ospfd.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(
|
router.load_config(
|
||||||
TopoRouter.RD_PIM, "{}/{}/pimd.conf".format(tgen.logdir, rname)
|
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 pim deamon
|
||||||
# Loading empty pimd.conf file to router, to start the pim6d deamon
|
if "pim6" in feature:
|
||||||
router.load_config(
|
router.load_config(
|
||||||
TopoRouter.RD_PIM6, "{}/{}/pim6d.conf".format(tgen.logdir, rname)
|
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
|
# Starting routers
|
||||||
logger.info("Starting all routers once topology is created")
|
logger.info("Starting all routers once topology is created")
|
||||||
tgen.start_router()
|
tgen.start_router()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"feature": ["bgp"],
|
||||||
"ipv4base": "10.0.0.0",
|
"ipv4base": "10.0.0.0",
|
||||||
"ipv4mask": 24,
|
"ipv4mask": 24,
|
||||||
"link_ip_start": {
|
"link_ip_start": {
|
||||||
|
Loading…
Reference in New Issue
Block a user