]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: enable using munet native configs
authorChristian Hopps <chopps@labn.net>
Sun, 23 Apr 2023 12:25:51 +0000 (08:25 -0400)
committerChristian Hopps <chopps@labn.net>
Sun, 23 Apr 2023 13:52:39 +0000 (09:52 -0400)
Signed-off-by: Christian Hopps <chopps@labn.net>
tests/topotests/conftest.py
tests/topotests/kinds.yaml [new file with mode: 0644]
tests/topotests/pytest.ini

index 8e4d13df7d14826d2e6f71696e269474365eb670..31d796ccb8c60dbdabd7035d909c84a4172db9a0 100755 (executable)
@@ -5,6 +5,7 @@ Topotest conftest.py file.
 # pylint: disable=consider-using-f-string
 
 import glob
+import logging
 import os
 import re
 import resource
@@ -16,7 +17,7 @@ import lib.fixtures
 import pytest
 from lib.micronet_compat import ConfigOptionsProxy, Mininet
 from lib.topogen import diagnose_env, get_topogen
-from lib.topolog import logger
+from lib.topolog import get_test_logdir, logger
 from lib.topotest import json_cmp_result
 from munet import cli
 from munet.base import Commander, proc_error
@@ -25,6 +26,19 @@ from munet.testing.util import pause_test
 
 from lib import topolog, topotest
 
+try:
+    # Used by munet native tests
+    from munet.testing.fixtures import event_loop, unet  # pylint: disable=all # noqa
+
+    @pytest.fixture(scope="module")
+    def rundir_module(pytestconfig):
+        d = os.path.join(pytestconfig.option.rundir, get_test_logdir())
+        logging.debug("rundir_module: test module rundir %s", d)
+        return d
+
+except (AttributeError, ImportError):
+    pass
+
 
 def pytest_addoption(parser):
     """
diff --git a/tests/topotests/kinds.yaml b/tests/topotests/kinds.yaml
new file mode 100644 (file)
index 0000000..127790e
--- /dev/null
@@ -0,0 +1,30 @@
+version: 1
+kinds:
+  - name: frr
+    cmd: |
+      chown frr:frr -R /var/run/frr
+      chown frr:frr -R /var/log/frr
+      /usr/lib/frr/frrinit.sh start
+      tail -F /var/log/frr/frr.log
+    cleanup-cmd: |
+      /usr/lib/frr/frrinit.sh stop
+    volumes:
+      - "./%NAME%:/etc/frr"
+      - "%RUNDIR%/var.log.frr:/var/log/frr"
+      - "%RUNDIR%/var.run.frr:/var/run/frr"
+    cap-add:
+      - SYS_ADMIN
+      - AUDIT_WRITE
+    merge: ["volumes"]
+cli:
+  commands:
+    - name: ""
+      exec: "vtysh -c '{}'"
+      format: "[ROUTER ...] COMMAND"
+      help: "execute vtysh COMMAND on the router[s]"
+      kinds: ["frr"]
+    - name: "vtysh"
+      exec: "/usr/bin/vtysh"
+      format: "vtysh ROUTER [ROUTER ...]"
+      new-window: true
+      kinds: ["frr"]
index ccbc9d2a16eda5cb356337733b8e53860f583e9f..322c07025f906849aae5408c99be4accbae23e4b 100644 (file)
@@ -1,6 +1,8 @@
 # Skip pytests example directory
 [pytest]
 
+asyncio_mode = auto
+
 # We always turn this on inside conftest.py, default shown
 # addopts = --junitxml=<rundir>/topotests.xml