Commit Graph

31 Commits

Author SHA1 Message Date
Christian Hopps
fea00bad20 tests: fix pylint error, and update style in lib/*.py
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-17 13:42:32 -04:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
G. Paul Ziemba
25cdcf1fac topotests/lib/lutil.py: luSetWaitType("strict"|"nostrict")
This change alters the behavior of existing test code. The
    default mode (before any call to luSetWaitType()) is now
    "strict".

    The historical behavior of luCommand(op="wait) is to ignore
    failures to match the specified regexp in the specified time.
    In those cases, no result was logged and no error was signaled.

    This change introduces a new "strict" mode for luCommand(op="wait):
    in "strict" wait mode, each invocation of luCommand(op="wait)
    generates an explicit, logged failure result when it fails to match
    the specified regexp in the specified time. These failures signal
    an error for the test.

    Calling luSetWaitType("nostrict") restores the historical behavior.

    Calling luSetWaitType("strict") (re)enables the new strict behavior.

    Individual calls to luCommand() may also specify op="wait-nostrict"
    to override any default and use the historical behavior.

    Individual calls to luCommand() may also specify op="wait-strict"
    to override any default and use the new behavior.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-01-13 10:53:36 -08:00
Lou Berger
6804af739d tests: topotests/lib/lutil.py: optimize wait to not repeat command after expected result found
Signed-off-by: Lou Berger <lberger@labn.net>
2021-10-26 10:56:50 -04:00
Christian Hopps
4953ca977f tests: cleanup - remove unused imports
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
Christian Hopps
fe50239bc6 tests: remove legacy Topo class from infra
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
Christian Hopps
8db751b853 tests: micronet: adapt tests
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:46 -04:00
David Schweizer
4e3828b771
tests: JSON comparison command for LabN topotests
The changes add the "jsoncmp_pass" and the "jsoncmp_fail" commands to
compare VTY shell's JSON output to an expected JSON object during
topotests using the LabN testing framework. This helps to eliminate
false negative test results (i.e. due to routes beeing out of order
after convergence or cosmetic changes in VTY shell's text output).

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2021-02-22 10:31:57 +01:00
G. Paul Ziemba
2f17f52a02 tests: topotests/lib/lutil.py: add timestamp to log of test start
Timestamps in test logs are needed for correlation with messages in
    routing protocol log files. Vox populi indicates preference for
    timestamp at beginning of line.

    OLD:
    (#55) scripts/rip-show.py:61 COMMAND:r1:vtysh -c "show ip rip status": 00:0.* 00:0:wait:RIP Peers:

    NEW:
    Sat Dec 19 08:26:45 2020 (#55) scripts/rip-show.py:61 COMMAND:r1:vtysh -c "show ip rip status": 00:0.* 00:0:wait:RIP Peers:

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2020-12-29 05:34:46 -08:00
Philippe Guibert
10870bbc20 topotests: precise importation folder
the topolog importation folder must be precised. otherwise following
error message appears:

root@dut-vm:~/topotests/bgp_flowspec# python3 test_bgp_flowspec_topo.py
Traceback (most recent call last):
  File "test_bgp_flowspec_topo.py", line 96, in <module>
    from lib.lutil import lUtil
  File "/root/topotests/bgp_flowspec/../lib/lutil.py", line 25, in <module>
    from topolog import logger
ImportError: No module named 'topolog'
root@dut-vm:~/topotests/bgp_flowspec#

The same error occurs with lutil and bgprib which are 2 libraries
located under lib/ folder. Some precisions are added too.

PR=71290
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-11-25 16:31:45 +00:00
Philippe Guibert
0e232bb883 topotests: python3, fix error ValueError: can't have unbuffered text I/O
This error occurs when passing some 0 values to open() extra argument.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-11-25 16:31:42 +00:00
Philippe Guibert
6cb6c403f1 topotests: python3, replace execfile with exec
python3 does not support execfile implementation.
replace it with open and exec api that are available in both python 2
and 3 implementations.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-11-25 16:19:33 +00:00
whitespace
701a01920e *: reformat python files
We are now using black.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-07 17:22:26 -04:00
Mark Stapp
11761ab0f4 tests: python3 compat fixes for topotests: tabs and misc
Use only spaces in python files; no tabs; also a couple of small
api fixes.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-09-26 15:40:00 -04:00
Lou Berger
dccb75bbcf topotest: log results summary at end of lutil run
Signed-off-by: Lou Berger <lberger@labn.net>
2020-01-21 06:27:43 -05:00
Rafael Zalamena
0f94985fdd topotest: adjust luCommand to accept wait_time
Allow users of `luCommand` to specify wait time between commands
execution and simplify the `wait` method implementation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-23 10:28:20 -03:00
Rafael Zalamena
2a76b0a8e2 topotest: fix Lou's framework command wait
Fix two main issues:

  * Don't use float to figure out if we spent the time user asked;
  * Don't depend on system clock to find we reached the end of time;

The fix is basically pre caculating the amount of wait cycles we are
going to peform and use a counter.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-23 10:26:15 -03:00
Donald Sharp
44d2a6775b Test: Add back a bit more debugging to see what is going on
All debug logging has been thrown to the floor in this loop.
Add it back in and additionally add a bit more debugging to
know what is going on.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-18 07:50:10 -04:00
Lou Berger
d850e66733 topotest: reduce chattiness of lutil output
Signed-off-by: Lou Berger <lberger@labn.net>
2019-06-26 20:30:59 +00:00
Lou Berger
ffd3f54493 lib: more logging to aid in failure debugging
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:14 -05:00
Lou Berger
c941311fef lib: lutil - fix test numbering, add test number to command logging 2018-11-27 20:22:14 -05:00
Lou Berger
518874f48a lib: fix path the led to group_nl_converted being referenced when not set
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:13 -05:00
G. Paul Ziemba
c63906e8cf lib: lutil matching without changing newlines
Prior behavior of luCommand was to convert newlines to spaces in DUT
output before pattern matching. New method operating in parallel uses
re.DOTALL to mimic same behavior and allow preserving original DUT output.
The original output is needed for some scripts that parse line-by-line.

There is also some test code to compare match results using the
old way and new way and log a message if they are different. After
some short time we can develop confidence that using this new method
will not break any existing tests.

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-11-27 20:22:13 -05:00
G. Paul Ziemba
f7af60f202 lutil: expose result method
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2018-11-27 20:22:13 -05:00
Lou Berger
cc3cf6a883 lib: lutil - fix test counting, add returnJson flag
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:13 -05:00
Lou Berger
4348027f3e lib: add script name to summary output
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:13 -05:00
Lou Berger
66c5287ec0 lib: add luLast to get last found luCommand regex match
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:13 -05:00
Lou Berger
9e219b9af7 lib: scope life of Lutil and _lt to a single test run reorg to support regression environment
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:13 -05:00
Lou Berger
50b15737c9 lib: lutil - make it easier to spot command output and null output
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:12 -05:00
Lou Berger
2fdcc34250 lib: lutil - make requested error logging change
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:12 -05:00
Lou Berger
a582a8e9c5 lib: lutil cleanup move utilities/lutil.py -> lib/lutil.py add: luShowFail, CallOnFail, luStart parameter to set log dir change default wait to 10sec
Signed-off-by: Lou Berger <lberger@labn.net>
2018-11-27 20:22:12 -05:00