Commit Graph

22 Commits

Author SHA1 Message Date
Christian Hopps
a15e5ac082 tests: fix --valgrind-memleaks option
Previously, when a valgrind memleak was discovered, would cause a
catastrophic pytest failure. Now correctly fails the current pytest as
intended.

As a result of this fix --valgrind-memleaks now works in distributed
pytest mode as well.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-10-22 17:44:47 +00:00
Christian Hopps
1726edc301
tests: fix xterm windows for topotests, better errors
- Fix xterm support to work, previously it mostly didn't, not it should
in all cases (i.e., single or dist mode).

- Catch when the user tries to use various window requiring topotests
features (e.g., --cli-on-error) but isn't running under supported
system (e.g., byobu/tmux/xterm), and fail the run with an explanation.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-07 15:50:59 -04:00
Christian Hopps
0254774578 tests: refactor parallel reset/load config for non-json
Refactor the bgp_auth test to create common_config code to allow
non-json based tests to reset routers and load configs in parallel.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-06 11:18:48 -04:00
Christian Hopps
a53c08bc13 tests: cleanup: rerun changed files through black
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:47 -04:00
Christian Hopps
4958158787 tests: micronet: update infra
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-09-04 09:04:46 -04:00
Christian Hopps
4f99894dd0 tests: configure routers in parallel
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-08-26 20:49:27 -04:00
Christian Hopps
0ba1d257be tests: add triage features: strace, asan-abort, docker exec
TMUX and Screen support when running topotests inside docker. This
allows the gdb, shell and vtysh features to correctly work even when
running the tests inside docker.

Add options:
--asan-abort :: aborts the process on ASAN errors
--strace-daemons :: strace some or all daemons

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-07-14 15:55:40 -04:00
Christian Hopps
e58133a78e tests: add valgrind memleaks run options and detection
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-16 02:56:15 -04:00
Jafar Al-Gharaibeh
fa4154ef8b
Merge pull request #8322 from qlyoung/topotests
Assorted topotests cleanup
2021-04-28 10:40:25 -05:00
Donald Sharp
0b25370e95 tests: More black fixups
Just another round of fixups found by running black on the code

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-04-09 08:35:05 -04:00
Quentin Young
c287dfd25c tests: provide sane default for --topology-only
Fixes:

/usr/lib/python3.9/site-packages/_pytest/config/__init__.py:1463: in getoption
    val = getattr(self.option, name)
E   AttributeError: 'Namespace' object has no attribute 'topology_only'

The above exception was the direct cause of the following exception:
/usr/lib/python3.9/site-packages/pluggy/manager.py:127: in register
    hook._maybe_apply_history(hookimpl)
/usr/lib/python3.9/site-packages/pluggy/hooks.py:333: in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
/usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
tests/topotests/conftest.py:62: in pytest_configure
    if config.getoption("--topology-only"):
/usr/lib/python3.9/site-packages/_pytest/config/__init__.py:1474: in getoption
    raise ValueError(f"no option named {name!r}") from e
E   ValueError: no option named 'topology_only'

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-04-07 13:31:27 -04:00
Christian Hopps
3f950192fe tests: add options for debugging topotest failures
Signed-off-by: Christian Hopps <chopps@labn.net>
2021-03-19 12:45:37 -04:00
GalaxyGorilla
849224d4ed tests: introduce a proper JSON diff for topotests
Diff'ing JSON objects is a crucial operation in the topotests for
comparing e.g. vtysh output (formatted as JSON) with a file which
covers the expectation of the tests. The current diff functionality
is 'self-written' and intended to test a JSON object d2 on being a
subset of another JSON object d1. For mismatches a diff is generated
based on a normalized textual representation of the JSON objects.

This approach has several disadvantages:

  * the human provided JSON text might not be normalized, hence
    a diff with line numbers might be worthless since it provides
    close to zero orientation what the problem is
  * the diff contains changes like commatas which are meaningless
  * the diff might contain a lot of changes about meaningless
    content which is present in d1 but not in d2
  * there is no proper functionality to test for 'equality' of
    d1 and d2
  * it is not possible to test for order, e.g. JSON arrays are
    just tested with respect to being a subset of another array
  * it is not possible to check if a key exists without also
    checking the value of that particular key

This commit attempts to solve these issues. An error report is
generated which includes the "JSON Path" to the problematic JSON
elements and also hints on what the actual problem is (e.g. missing
key, mismatch in dict values etc.).

A special parameter 'exact' was introduced such that equality can be
tested. Also there was a convention that absence of keys can be
tested using the key in question with value 'None'. This convention
is still honored such that full backwards compatiiblity is in
place.

Further order can be tested using the new tag '__ordered__' in
lists (as first element). Example:

    d1 = [1, 2, 3]
    d2 = ['__ordered__', 1, 3, 2]

Tesing d1 and d2 this way will now result in an error.

Key existence can now be tested using an asterisk '*'. Example:

    d1 = [1, 2, 3]
    d2 = [1, '*', 3]

    d1 = {'a': 1, 'b': 2}
    d2 = {'a': '*'}

Both cases will result now in a clean diff for d1 and d2.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-04-30 09:33:32 +00:00
reformat
787e762445 tests: Run python formatter (black) for topotests
Mostly ' => ", whitespace changes.

Using https://github.com/psf/black

Signed-off-by: reformat <reformat@nobody.nobody>
2020-04-03 19:41:28 +03:00
Rafael Zalamena
c8c265f571 topotests: skip tests when any assert fails
When an `assert` fails we should skip all other tests on the file. Once
a failure is detected we can't rely on the setup anymore, since most of
the tests assume the previous worked.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-09-30 21:15:15 -03:00
Mark Stapp
80cb48d2f4 topotest: fix pytest deprecation warning
As of pytest 4.something, a pattern we were using in conftest.py
was deprecated. Also make a new-ish test script executable (all
the rest appear to be?)

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-02 14:43:18 -04:00
Rafael Zalamena
5684f8100d topotests: add topology name to assert output
Make it easy to identify which topology test we are running.
2018-11-27 20:22:12 -05:00
Rafael Zalamena
e7ba3cd11c topotests: make asserts show up in stderr
Code was based on the pytest default makereport code:
c92760dca8/_pytest/runner.py (L264)
2018-11-27 20:22:12 -05:00
Rafael Zalamena
007e731324 topotest: implement environment diagnostics
Run environment diagnostics on topotest start, report all detected
problems and abort if an error condition is met.
2018-11-27 20:22:12 -05:00
Rafael Zalamena
3668ed8dc2 topotest: improve json_cmp assert output
Create a specialized assert and json_cmp() result to improve the
comparison output. With this we also got a way to display all comparison
failures instead of just the first one.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
8833a8387f topogen: don't backtrace when topogen is not used
This allows old tests to be run with '--topology-only' without
generating tons of error messages, instead it will just stop the test
without trying anything else.
2018-11-27 20:22:11 -05:00
Rafael Zalamena
1fca63c1e4 topogen: first code import
Topogen (Topology Generator) is a helper that wraps around Topotest to
simplify some of the boilerplate code. This abstraction will help the
development of new tests and new APIs without breaking the existing
ones. It also makes the relation of objects clearer, since we no longer
touch the Mininet API directly, which in turn also makes us less
vulnerable to external API changes.
2018-11-27 20:22:11 -05:00