Skip to content
Merged
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
8 changes: 2 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,8 @@ override_dh_auto_install:
cp -r smoketest/scripts/* $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/smoke

# Install smoke test configs
mkdir -p $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/config/
cp -r smoketest/configs/* $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/config

# Install smoke test config tests
mkdir -p $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/config-tests/
cp -r smoketest/config-tests/* $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/config-tests
mkdir -p $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/configs/
cp -r smoketest/configs/* $(DIR)/$(VYOS_LIBEXEC_DIR)/tests/configs

# Install system programs
mkdir -p $(DIR)/$(VYOS_BIN_DIR)
Expand Down
3 changes: 1 addition & 2 deletions debian/vyos-1x-smoketest.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ usr/bin/vyos-smoketest
usr/bin/vyos-configtest
usr/bin/vyos-configtest-pki
usr/libexec/vyos/tests/smoke
usr/libexec/vyos/tests/config
usr/libexec/vyos/tests/config-tests
usr/libexec/vyos/tests/configs
80 changes: 80 additions & 0 deletions smoketest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# VyOS Smoketests

A brief overview of the smoketesting platform

## CLI set/delete and validation

Smoketests execute predefined VyOS CLI commands and verify that the
corresponding daemon is running and/or service configuration is correctly
rendered.

Smoketests are available for the system (e.g. Kernel) and the CLI. They can
be run manually by simply executing the Python script on a live VyOS system.

```
vyos@vyos:~$ /usr/libexec/vyos/tests/smoke/cli/test_protocols_bgp.py
test_bgp_01_simple (__main__.TestProtocolsBGP) ... ok
test_bgp_02_neighbors (__main__.TestProtocolsBGP) ... ok
...
test_bgp_13_solo (__main__.TestProtocolsBGP) ... ok

----------------------------------------------------------------------
Ran 13 tests in 348.191s

OK
```

It is possible to only execute a single testcase

```
vyos@vyos:~$ /usr/libexec/vyos/tests/smoke/cli/test_protocols_bgp.py -k test_bgp_02_neighbors
test_bgp_02_neighbors (__main__.TestProtocolsBGP) ... ok

----------------------------------------------------------------------
Ran 1 test in 6.872s

OK
```

## Configuration Migration

The files in `smoketests/configs/` are real VyOS configurations taken from
production or lab systems. They provide realistic inputs to test configuration
migration and ensure that existing configs still load correctly after code
changes.

Example:

After assembling a VyOS ISO image from vyos-build repository, a `make testc`
loads the configuration files and its associated CLI commands that are asserted.
After loading the configuration and executing any necessary migration scripts,
we then check whether the resulting `show configuration commands` output
contains all commands listed in `smoketests/configs/assert`. If all listed
commands are present, the test passes.

Each config file has exactly one matching expected-set file inside the
`smoketests/configs/assert` folder.

When modifying or adding a migration script, update the matching file in
`smoketests/configs/assert` to reflect any new or changed CLI commands.

**NOTE:** The migrated output does not need to match exactly. Missing lines in
the assert file are not treated as failures. A test only fails when a listed
line differs from the actual migrated output.

```
smoketests/
├── configs/ # Input configuration files
│ ├── assert/ # Expected CLI commands after migration
│ │ ├── example1
│ │ ├── example2
│ │ └── ...
│ ├── no-load/ # Large configurations we do not automatically test
│ │ └── ...
│ ├── example1
│ ├── example2
│ └── ...
└── README.md # Documentation for adding and running tests
```


4 changes: 2 additions & 2 deletions smoketest/bin/vyos-configtest
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import unittest
from vyos.configsession import ConfigSession, ConfigSessionError
from vyos import ConfigError

config_dir = '/usr/libexec/vyos/tests/config'
config_test_dir = '/usr/libexec/vyos/tests/config-tests'
config_dir = '/usr/libexec/vyos/tests/configs'
config_test_dir = f'{config_dir}/assert'
save_config = '/tmp/vyos-configtest-save'

class DynamicClassBase(unittest.TestCase):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading