From: Rafael Zalamena Date: Mon, 24 Jul 2017 14:53:19 +0000 (-0300) Subject: topotest: log sleep function X-Git-Tag: frr-7.1-dev~151^2~249 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=570f25d80a93bce89e2167d5eb8d2e668aa5ba3e;p=matthieu%2Ffrr.git topotest: log sleep function Added a wrapper for the sleep function that should be used to register in the log files the amount of time spent sleeping. --- diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 1b5f7eed49..61f46097e1 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -32,6 +32,7 @@ import subprocess import tempfile import platform import difflib +import time from lib.topolog import logger @@ -42,8 +43,6 @@ from mininet.log import setLogLevel, info from mininet.cli import CLI from mininet.link import Intf -from time import sleep - class json_cmp_result(object): "json_cmp result class for better assertion messages" @@ -159,7 +158,7 @@ def run_and_expect(func, what, count=20, wait=3): while count > 0: result = func() if result != what: - sleep(wait) + time.sleep(wait) count -= 1 continue return (True, result) @@ -364,6 +363,17 @@ def ip6_route(node): return result +def sleep(amount, reason=None): + """ + Sleep wrapper that registers in the log the amount of sleep + """ + if reason is None: + logger.info('Sleeping for {} seconds'.format(amount)) + else: + logger.info(reason + ' ({} seconds)'.format(amount)) + + time.sleep(amount) + def checkAddressSanitizerError(output, router, component): "Checks for AddressSanitizer in output. If found, then logs it and returns true, false otherwise" @@ -576,7 +586,7 @@ class Router(Node): )) self.waitOutput() logger.debug('{}: {} zebra started'.format(self, self.routertype)) - sleep(1) + time.sleep(1) # Fix Link-Local Addresses # Somehow (on Mininet only), Zebra removes the IPv6 Link-Local addresses on start. Fix this self.cmd('for i in `ls /sys/class/net/` ; do mac=`cat /sys/class/net/$i/address`; IFS=\':\'; set $mac; unset IFS; ip address add dev $i scope link fe80::$(printf %02x $((0x$1 ^ 2)))$2:${3}ff:fe$4:$5$6/64; done')