summaryrefslogtreecommitdiffstats
path: root/tests/topotests/lib/bgp.py
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2021-07-27 01:23:20 +0200
committerChristian Hopps <chopps@labn.net>2021-09-04 15:04:46 +0200
commit4958158787ce9179020d024c14416a23e82713b1 (patch)
tree8fb926ae2c5d3e267b332464c3e8345fc2ab4e87 /tests/topotests/lib/bgp.py
parenttests: NEW micronet replacement for mininet (diff)
downloadfrr-4958158787ce9179020d024c14416a23e82713b1.tar.xz
frr-4958158787ce9179020d024c14416a23e82713b1.zip
tests: micronet: update infra
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'tests/topotests/lib/bgp.py')
-rw-r--r--tests/topotests/lib/bgp.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py
index 519cd6735..051b2eb97 100644
--- a/tests/topotests/lib/bgp.py
+++ b/tests/topotests/lib/bgp.py
@@ -18,40 +18,39 @@
# OF THIS SOFTWARE.
#
-from copy import deepcopy
-from time import sleep
-import traceback
-import ipaddr
import ipaddress
import os
import sys
-from lib import topotest
-from lib.topolog import logger
+import traceback
+from copy import deepcopy
+from time import sleep
-from lib.topogen import TopoRouter, get_topogen
-from lib.topotest import frr_unicode
+import ipaddr
# Import common_config to use commomnly used APIs
from lib.common_config import (
create_common_configurations,
+ FRRCFG_FILE,
InvalidCLIError,
- load_config_to_router,
check_address_types,
- generate_ips,
- validate_ip_address,
+ create_common_configuration,
find_interface_with_greater_ip,
- run_frr_cmd,
- FRRCFG_FILE,
- retry,
+ generate_ips,
+ get_frr_ipv6_linklocal,
get_ipv6_linklocal_address,
- get_frr_ipv6_linklocal
+ load_config_to_router,
+ retry,
+ run_frr_cmd,
+ validate_ip_address,
)
+from lib.topogen import TopoRouter, get_topogen
+from lib.topolog import logger
+from lib.topotest import frr_unicode
-LOGDIR = "/tmp/topotests/"
-TMPDIR = None
+from lib import topotest
-def create_router_bgp(tgen, topo, input_dict=None, build=False, load_config=True):
+def create_router_bgp(tgen, topo=None, input_dict=None, build=False, load_config=True):
"""
API to configure bgp on router
@@ -139,6 +138,9 @@ def create_router_bgp(tgen, topo, input_dict=None, build=False, load_config=True
logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
result = False
+ if topo is None:
+ topo = tgen.json_topo
+
# Flag is used when testing ipv6 over ipv4 or vice-versa
afi_test = False
@@ -1096,9 +1098,6 @@ def modify_bgp_config_when_bgpd_down(tgen, topo, input_dict):
logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
try:
-
- global LOGDIR
-
result = create_router_bgp(
tgen, topo, input_dict, build=False, load_config=False
)
@@ -1112,13 +1111,10 @@ def modify_bgp_config_when_bgpd_down(tgen, topo, input_dict):
if router != dut:
continue
- TMPDIR = os.path.join(LOGDIR, tgen.modname)
-
logger.info("Delete BGP config when BGPd is down in {}".format(router))
- # Reading the config from /tmp/topotests and
- # copy to /etc/frr/bgpd.conf
+ # Reading the config from "rundir" and copy to /etc/frr/bgpd.conf
cmd = "cat {}/{}/{} >> /etc/frr/bgpd.conf".format(
- TMPDIR, router, FRRCFG_FILE
+ tgen.logdir, router, FRRCFG_FILE
)
router_list[router].run(cmd)
@@ -1207,7 +1203,7 @@ def verify_router_id(tgen, topo, input_dict, expected=True):
@retry(retry_timeout=150)
-def verify_bgp_convergence(tgen, topo, dut=None, expected=True):
+def verify_bgp_convergence(tgen, topo=None, dut=None, expected=True):
"""
API will verify if BGP is converged with in the given time frame.
Running "show bgp summary json" command and verify bgp neighbor
@@ -1230,6 +1226,9 @@ def verify_bgp_convergence(tgen, topo, dut=None, expected=True):
errormsg(str) or True
"""
+ if topo is None:
+ topo = tgen.json_topo
+
result = False
logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
tgen = get_topogen()