Skip to content

Commit 10d2e73

Browse files
authored
[dvs] Update instructions for running dvs tests locally (sonic-net#1196)
Signed-off-by: Danny Allen <[email protected]>
1 parent 853d822 commit 10d2e73

2 files changed

Lines changed: 84 additions & 38 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ orchagent/orchagent_restart_check
6464
swssconfig/swssconfig
6565
swssconfig/swssplayer
6666
tests/tests
67+
68+
# Test Files #
69+
##############
70+
tests/log

tests/README.md

Lines changed: 80 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,109 @@
1-
SWSS Integration Tests
1+
# Docker Virtual Switch (DVS) Tests
22

3-
# Introduction
3+
## Introduction
4+
The Docker Virtual Switch tests allow developers to validate the control plane behavior of new SWSS features without needing an actual network device or switching ASIC.
45

5-
SWSS Integration tests runs on docker-sonic-vs which runs on top of SAI virtual switch. The tests can be run on any Linux machine without real switch ASIC. It is used to test SwSS (Switch State Service) by setting AppDB or ConfigDB and checking corresponding AsicDB entries.
6+
The DVS tests work by publishing configuration updates to redis (typically Config DB or App DB) and checking that the state of the system is correctly updated by SWSS (typically by checking ASIC DB).
67

7-
# How to run the tests
8+
SWSS, Redis, and all the other required components run inside a virtual switch Docker container, meaning that these test cases can be run on any Linux machine - no special hardware required!
89

9-
- Install docker and pytest on your dev machine
10-
```
11-
sudo pip install docker==3.5.0
12-
sudo pip install pytest==3.3.0
13-
sudo pip install flaky docker redis
14-
```
15-
- Compile and install swss common library. Follow instructions [here](https://github.com/Azure/sonic-swss-common/blob/master/README.md) to first install prerequisites to build swss common library.
16-
```
17-
cd sonic-swss-common
18-
./autogen.sh
19-
dpkg-buildpackage -us -uc -b
20-
dpkg -i ../libswsscommon_1.0.0_amd64.deb
21-
dpkg -i ../python-swsscommon_1.0.0_amd64.deb
22-
```
23-
- Build and load docker-sonic-vs
10+
## Setting up your test environment
11+
1. [Install Docker CE](https://docs.docker.com/install/linux/docker-ce/ubuntu/). Be sure to follow the [post-install instructions](https://docs.docker.com/install/linux/linux-postinstall/) so that you don't need sudo privileges to run docker commands.
12+
2. Install the external dependencies needed to run the tests:
2413

2514
```
26-
cd sonic-buildimage
27-
make configure PLATFORM=vs
28-
make all
29-
docker load < target/docker-sonic-vs.gz
15+
sudo modprobe team
16+
sudo apt install net-tools ethtool
17+
sudo pip install docker pytest flaky redis
3018
```
19+
3. Install `python-swsscommon_1.0.0_amd64.deb`. You will need to install all the dependencies as well in the following order:
3120
32-
- Run tests
33-
3421
```
35-
cd sonic-swss/tests
36-
sudo pytest -v
22+
sudo dpkg -i libnl-3-200_3.5.0-1_amd64.deb
23+
sudo dpkg -i libnl-genl-3-200_3.5.0-1_amd64.deb
24+
sudo dpkg -i libnl-route-3-200_3.5.0-1_amd64.deb
25+
sudo dpkg -i libnl-nf-3-200_3.5.0-1_amd64.deb
26+
sudo dpkg -i libhiredis0.14_0.14.0-3~bpo9+1_amd64.deb
27+
sudo dpkg -i libswsscommon_1.0.0_amd64.deb
28+
sudo dpkg -i python-swsscommon_1.0.0_amd64.deb
3729
```
3830
39-
\* If you meet the error: client is newer than server, please edit the file `/usr/local/lib/python2.7/dist-packages/docker/constants.py` to update the `DEFAULT_DOCKER_API_VERSION` to mitigate this issue.
31+
You can find the dependencies [here](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-all/lastSuccessfulBuild/artifact/target/debs/stretch/), and get this package by:
32+
- [Building it from scratch](https://github.com/Azure/sonic-swss-common)
33+
- [Downloading the latest build from Jenkins](https://sonic-jenkins.westus2.cloudapp.azure.com/job/common/job/sonic-swss-common-build/lastSuccessfulBuild/artifact/target/)
34+
4. Load the `docker-sonic-vs.gz` file into docker. You can get the image by:
35+
- [Building it from scratch](https://github.com/Azure/sonic-buildimage)
36+
- [Downloading the latest build from Jenkins](https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-all/lastSuccessfulBuild/artifact/target/)
37+
38+
Once you have the file, you can load it into docker by running `docker load < docker-sonic-vs.gz`.
4039
41-
# How to setup test development env
40+
## Running the tests
41+
```
42+
cd sonic-swss/tests
43+
sudo pytest
44+
```
4245
43-
To develop new swss features or swss integration tests, you need to setup a virtual switch docker container which
44-
persists.
46+
## Setting up a persistent test environment
47+
For those developing new features for SWSS or the DVS framework, you might find it helpful to setup a persistent DVS container that you can inspect and make modifications to (e.g. using `dpkg -i` to install a new version of SWSS to test a new feature).
4548
46-
- Create virtual switch container (name:vs). ```create_vnet.sh``` can be found at [here](https://github.com/Azure/sonic-buildimage/blob/master/platform/vs/create_vnet.sh).
49+
1. [Download `create_vnet.sh`](https://github.com/Azure/sonic-buildimage/blob/master/platform/vs/create_vnet.sh).
50+
2. Setup a virtual server and network:
4751
4852
```
4953
docker run --privileged -id --name sw debian bash
5054
sudo ./create_vnet.sh sw
55+
```
56+
3. Start the DVS container:
57+
58+
```
5159
docker run --privileged -v /var/run/redis-vs/sw:/var/run/redis --network container:sw -d --name vs docker-sonic-vs
5260
```
61+
62+
4. You can specify your persistent DVS container when running the tests as follows:
5363
54-
- If you need to simulate other platforms, e.g. Broadcom or Mellanox, you will need to add the environment variable while starting the docker.
64+
```
65+
sudo pytest --dvsname=vs
66+
```
67+
68+
5. Additionally, if you need to simulate a specific hardware platform (e.g. Broadcom or Mellanox), you can add this environment variable when starting the DVS container:
69+
5570
```
5671
-e "fake_platform=mellanox"
5772
```
58-
59-
- Run full test using the existing vs container
73+
74+
## Other useful test parameters
75+
- You can see the output of all test cases that have been run by adding the verbose flag:
76+
77+
```
78+
sudo pytest -v
79+
```
80+
81+
This works for persistent DVS containers as well.
82+
83+
- You can specify a specific test file, class, or even individual test case when you run the tests:
84+
85+
```
86+
sudo pytest <test_file_name>::<test_class_name>::<test_name>
6087
```
61-
sudo pytest -s -v --dvsname=vs
88+
89+
This works for persistent DVS containers as well.
90+
91+
- You can specify a specific image:tag to use when running the tests *without a persistent DVS container*:
92+
93+
```
94+
sudo pytest --imgname=docker-sonic-vs:my-changes.333
6295
```
6396
64-
- Run specific test using the existing vs container
97+
- You can automatically retry failed test cases **once**:
98+
99+
```
100+
sudo pytest --force-flaky
65101
```
66-
sudo pytest -s -v --dvsname=vs <test_file_name>::<test_class_name>::<test_name>
102+
103+
## Known Issues
104+
- ```
105+
ERROR: Error response from daemon: client is newer than server (client API version: x.xx, server API version: x.xx)
67106
```
107+
108+
You can mitigate this by editing the `DEFAULT_DOCKER_API_VERSION` in `/usr/local/lib/python2.7/dist-packages/docker/constants.py`, or by upgrading to a newer version of Docker CE. See [relevant GitHub discussion](https://github.com/drone/drone/issues/2048).
109+

0 commit comments

Comments
 (0)