Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
sudo apt-get update -y
sudo apt-get install -y cloud-utils qemu-system-x86

- name: Install tshark
run: |
uname -a
sudo apt-get update -y
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y tshark

- name: Lint the project
run: make ci-lint

Expand Down
42 changes: 42 additions & 0 deletions doc/source/mutest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ used to check that the state of the interface actually changes.
step("r1", 'vtysh -c "conf t\n interface eth0\n shut"')
match_step("r1", 'vtysh -c "show interface eth0", "DOWN", "Check for interface DOWN")


JSON Commands
~~~~~~~~~~~~~~~~~~~

Additionally, json variants of various functions are also available, namely
:py:func:`match_step_json`, :py:func:`wait_step_json`, and :py:func:`step_json`.
These json variants compare a json value ``match`` with the json result from ``cmd``.
Expand Down Expand Up @@ -212,5 +216,43 @@ When ``exact_match`` is ``True``, the comparison will only succeed when all data
in ``match`` is present in the ``cmd`` result *and* all data present in the
``cmd`` result is present in ``match``. In other words they exactly match.


Background Commands
~~~~~~~~~~~~~~~~~~~

Mutest supports running commands in the background, allowing other test steps to
execute while the command remains active. This is useful for monitoring traffic,
collecting logs, or running commands whose output depends on subsequent test
operations.

Use :py:func:`background_start()` to launch a command and obtain its host process ID
(PID). The command can later be terminated and its output evaluated using one of
the following functions:

- :py:func:`background_step()` — Terminates the command and returns its captured output.
- :py:func:`background_match_step()` — Terminates the command and matches its output against a regular expression.
- :py:func:`background_step_json()` — Terminates the command and returns its output as parsed JSON.
- :py:func:`background_match_step_json()` — Terminates the command and compares its JSON output against an expected value.

For example:

.. code-block:: python

pid = background_start("r1", "tcpdump -i eth0 -n")

step("r2", "ping -c 5 10.0.0.1")

background_match_step(
pid,
r"5 packets captured",
"Verify captured traffic",
)

**Each background command can be completed only once.** Calling any background
step terminates the command and consumes its PID, preventing further
background-step operations on that command. Background commands that are never
explicitly completed are automatically cleaned up when the owning munet topology
is deleted.

To see all the available functions and their specifications see
:ref:`mutest-api`.
Loading
Loading