summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/topotest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/lib/topotest.py')
-rw-r--r--tests/topotests/lib/topotest.py95
1 files changed, 62 insertions, 33 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py
index 20d60ebbef..1e6ef1b2b3 100644
--- a/tests/topotests/lib/topotest.py
+++ b/tests/topotests/lib/topotest.py
@@ -609,8 +609,10 @@ def interface_set_status(node, ifacename, ifaceaction=False, vrf_name=None):
ifacename, str_ifaceaction
)
else:
- cmd = 'vtysh -c "configure terminal" -c "interface {0} vrf {1}" -c "{2}"'.format(
- ifacename, vrf_name, str_ifaceaction
+ cmd = (
+ 'vtysh -c "configure terminal" -c "interface {0} vrf {1}" -c "{2}"'.format(
+ ifacename, vrf_name, str_ifaceaction
+ )
)
node.run(cmd)
@@ -924,40 +926,44 @@ def checkAddressSanitizerError(output, router, component, logdir=""):
)
if addressSanitizerLog:
# Find Calling Test. Could be multiple steps back
- testframe=sys._current_frames().values()[0]
- level=0
+ testframe = sys._current_frames().values()[0]
+ level = 0
while level < 10:
- test=os.path.splitext(os.path.basename(testframe.f_globals["__file__"]))[0]
+ test = os.path.splitext(
+ os.path.basename(testframe.f_globals["__file__"])
+ )[0]
if (test != "topotest") and (test != "topogen"):
# Found the calling test
- callingTest=os.path.basename(testframe.f_globals["__file__"])
+ callingTest = os.path.basename(testframe.f_globals["__file__"])
break
- level=level+1
- testframe=testframe.f_back
- if (level >= 10):
+ level = level + 1
+ testframe = testframe.f_back
+ if level >= 10:
# somehow couldn't find the test script.
- callingTest="unknownTest"
+ callingTest = "unknownTest"
#
# Now finding Calling Procedure
- level=0
+ level = 0
while level < 20:
- callingProc=sys._getframe(level).f_code.co_name
- if ((callingProc != "processAddressSanitizerError") and
- (callingProc != "checkAddressSanitizerError") and
- (callingProc != "checkRouterCores") and
- (callingProc != "stopRouter") and
- (callingProc != "__stop_internal") and
- (callingProc != "stop") and
- (callingProc != "stop_topology") and
- (callingProc != "checkRouterRunning") and
- (callingProc != "check_router_running") and
- (callingProc != "routers_have_failure")):
+ callingProc = sys._getframe(level).f_code.co_name
+ if (
+ (callingProc != "processAddressSanitizerError")
+ and (callingProc != "checkAddressSanitizerError")
+ and (callingProc != "checkRouterCores")
+ and (callingProc != "stopRouter")
+ and (callingProc != "__stop_internal")
+ and (callingProc != "stop")
+ and (callingProc != "stop_topology")
+ and (callingProc != "checkRouterRunning")
+ and (callingProc != "check_router_running")
+ and (callingProc != "routers_have_failure")
+ ):
# Found the calling test
break
- level=level+1
- if (level >= 20):
+ level = level + 1
+ if level >= 20:
# something wrong - couldn't found the calling test function
- callingProc="unknownProc"
+ callingProc = "unknownProc"
with open("/tmp/AddressSanitzer.txt", "a") as addrSanFile:
sys.stderr.write(
"AddressSanitizer error in topotest `%s`, test `%s`, router `%s`\n\n"
@@ -979,7 +985,6 @@ def checkAddressSanitizerError(output, router, component, logdir=""):
addrSanFile.write("\n---------------\n")
return
-
addressSanitizerError = re.search(
"(==[0-9]+==)ERROR: AddressSanitizer: ([^\s]*) ", output
)
@@ -989,16 +994,20 @@ def checkAddressSanitizerError(output, router, component, logdir=""):
# No Address Sanitizer Error in Output. Now check for AddressSanitizer daemon file
if logdir:
- filepattern=logdir+"/"+router+"/"+component+".asan.*"
- logger.debug("Log check for %s on %s, pattern %s\n" % (component, router, filepattern))
+ filepattern = logdir + "/" + router + "/" + component + ".asan.*"
+ logger.debug(
+ "Log check for %s on %s, pattern %s\n" % (component, router, filepattern)
+ )
for file in glob.glob(filepattern):
with open(file, "r") as asanErrorFile:
- asanError=asanErrorFile.read()
+ asanError = asanErrorFile.read()
addressSanitizerError = re.search(
"(==[0-9]+==)ERROR: AddressSanitizer: ([^\s]*) ", asanError
- )
+ )
if addressSanitizerError:
- processAddressSanitizerError(addressSanitizerError, asanError, router, component)
+ processAddressSanitizerError(
+ addressSanitizerError, asanError, router, component
+ )
return True
return False
@@ -1065,7 +1074,7 @@ class Router(Node):
if self.logdir is None:
cur_test = os.environ["PYTEST_CURRENT_TEST"]
self.logdir = "/tmp/topotests/" + cur_test[
- cur_test.find("/")+1 : cur_test.find(".py")
+ cur_test.find("/") + 1 : cur_test.find(".py")
].replace("/", ".")
# If the logdir is not created, then create it and set the
@@ -1073,7 +1082,7 @@ class Router(Node):
if not os.path.isdir(self.logdir):
os.system("mkdir -p " + self.logdir + "/" + name)
os.system("chmod -R go+rw /tmp/topotests")
- # Erase logs of previous run
+ # Erase logs of previous run
os.system("rm -rf " + self.logdir + "/" + name)
self.daemondir = None
@@ -1096,6 +1105,8 @@ class Router(Node):
"sharpd": 0,
"babeld": 0,
"pbrd": 0,
+ "pathd": 0,
+ "snmpd": 0,
}
self.daemons_options = {"zebra": ""}
self.reportCores = True
@@ -1279,6 +1290,8 @@ class Router(Node):
% (self.routertype, self.routertype, self.routertype, daemon)
)
self.waitOutput()
+ if (daemon == "snmpd") and (self.routertype == "frr"):
+ self.cmd('echo "agentXSocket /etc/frr/agentx" > /etc/snmp/frr.conf')
if (daemon == "zebra") and (self.daemons["staticd"] == 0):
# Add staticd with zebra - if it exists
staticd_path = os.path.join(self.daemondir, "staticd")
@@ -1435,6 +1448,20 @@ class Router(Node):
while "staticd" in daemons_list:
daemons_list.remove("staticd")
+ if "snmpd" in daemons_list:
+ snmpd_path = "/usr/sbin/snmpd"
+ snmpd_option = self.daemons_options["snmpd"]
+ self.cmd(
+ "{0} {1} -C -c /etc/frr/snmpd.conf -p /var/run/{2}/snmpd.pid -x /etc/frr/agentx > snmpd.out 2> snmpd.err".format(
+ snmpd_path, snmpd_option, self.routertype
+ )
+ )
+ logger.info("{}: {} snmpd started".format(self, self.routertype))
+
+ # Remove `snmpd` so we don't attempt to start it again.
+ while "snmpd" in daemons_list:
+ daemons_list.remove("snmpd")
+
# Fix Link-Local Addresses
# Somehow (on Mininet only), Zebra removes the IPv6 Link-Local addresses on start. Fix this
self.cmd(
@@ -1598,6 +1625,8 @@ class Router(Node):
return "%s: vtysh killed by AddressSanitizer" % (self.name)
for daemon in self.daemons:
+ if daemon == "snmpd":
+ continue
if (self.daemons[daemon] == 1) and not (daemon in daemonsRunning):
sys.stderr.write("%s: Daemon %s not running\n" % (self.name, daemon))
if daemon == "staticd":