-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspect: fixes all, by name and topology file (#1984)
* inspect: fixes all, by name and topology file * use topology file if provided not just the label * added integration tests for basic inspect command * wrongly added topo * more accidentally not ignored stuff * added a test for the inspect command with ext containers * remove grepping for the lab node to make sure the tables doesn't have extra lines * address linter complaints --------- Co-authored-by: Roman Dodin <dodin.roman@gmail.com>
- Loading branch information
Showing
10 changed files
with
153 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ tests/out | |
# ignore backup clab topo files | ||
**/.*clab.y*ml.bak | ||
**/*.y*ml.bak | ||
|
||
.python-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Developers Guide | ||
|
||
This is a start of the developers documentation. Stay tuned for more content! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Testing Containerlab | ||
|
||
Containerlab's test program largely consists of: | ||
|
||
- Go-based unit tests | ||
- RobotFramework-based integration tests | ||
|
||
## Integration Tests | ||
|
||
The integration tests are written in RobotFramework and are located in the [`tests`][tests-dir] directory. The tests are run using the [`rf-run`][rf-run] command that wraps `robot` command. The tests are run in a Docker container, so you don't need to install RobotFramework on your local machine. | ||
|
||
### Local execution | ||
|
||
To execute the integration tests locally you have to install the python environment with the required dependencies. If you're using `pyenv` you can use the following commands: | ||
|
||
1. Create a venv and activate it | ||
|
||
```bash | ||
pyenv virtualenv 3.11 clab-rf | ||
pyenv shell clab-rf | ||
``` | ||
|
||
2. Install the dependencies | ||
|
||
```bash | ||
pip install -r tests/requirements.txt | ||
``` | ||
|
||
Usually you would run the tests using the locally built containerlab binary that contains the unreleased changes. The typical workflow then starts with building the containerlab binary: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
The newly built binary is located in the `bin` directory. In order to let the test runner script know where to find the binary, you have to set the `CLAB_BIN` environment variable before calling the `rf-run` script: | ||
|
||
```bash | ||
CLAB_BIN=$(pwd)/bin/containerlab ./tests/rf-run.sh <runtime> <test suite> | ||
``` | ||
|
||
/// note | ||
The test runner script requires you to specify the runtime as its first argument. The runtime can be either `docker` or `podman`. Containerlab primarily uses Docker as the default runtime, hence the number of tests written for docker outnumber the podman tests. | ||
/// | ||
|
||
#### Selecting the test suite | ||
|
||
Containerlab's integration tests are grouped by a topic, and each topic is mapped to a directory under the [`tests`][tests-dir] directory and RobotFramework allows for a flexible selection of tests/test suites to run. For example, to run all the smoke test cases, you can use the following command: | ||
|
||
```bash | ||
CLAB_BIN=$(pwd)/bin/containerlab ./tests/rf-run.sh docker tests/01-smoke | ||
``` | ||
|
||
since [`01-smoke`][01-smoke-dir] is a directory containing all the smoke test suites. | ||
|
||
Consequently, in order to run a specific test suite you just need to provide a path to it. E.g. running the `01-basic-flow.robot` test suite from the `01-smoke` directory: | ||
|
||
```bash | ||
CLAB_BIN=$(pwd)/bin/containerlab ./tests/rf-run.sh docker tests/01-smoke/01-basic-flow.robot | ||
``` | ||
|
||
/// note | ||
Selecting a specific test case in a test suite is not supported, since test suites are written in a way that test cases depend on previous ones. | ||
/// | ||
|
||
#### Inspecting the test results | ||
|
||
RobotFramework generates a detailed report in HTML and XML formats that can be found in the `tests/out` directory. The exact paths to the reports are printed to the console after the test run. | ||
|
||
[tests-dir]: https://github.com/srl-labs/containerlab/tree/main/tests | ||
[rf-run]: https://github.com/srl-labs/containerlab/blob/main/tests/rf-run.sh | ||
[01-smoke-dir]: https://github.com/srl-labs/containerlab/tree/main/tests/01-smoke |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters