This page explains how to set up a scenario test environment and run the test.
Go, Docker, and Python3 need to be set up.
$ python --version
Python 3.9.7
$ go version
go version go1.17 linux/arm64
$ docker version
Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5.1
Built: Mon Nov 1 00:34:28 2021
OS/Arch: linux/arm64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5.1
Built: Thu Oct 21 23:58:58 2021
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.5.5-0ubuntu3
GitCommit:
runc:
Version: 1.0.1-0ubuntu2
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
Execute the following commands to install the dependencies:
$ git clone https://github.com/osrg/gobgp
$ cd ./gobgp
$ python3 -m venv .test
$ source .test/bin/activate
$ pip install -r test/pip-requires.txt
You need to build GoBGP docker image to test from the source code that you modified. You need run the following command every time you modify the source code.
$ fab -r ./test/lib make-gobgp-ctn
There are two ways to run tests
-
Run all tests
You can run all scenario tests with run_all_tests.sh. If all tests passed, you can see "all tests passed successfully" at the end of the test.
$ ./test/scenario_test/run_all_tests.sh ... OK all tests passed successfully
-
Run each test
You can run scenario tests individually with each test file. See
test/scenario_test/*.py
, for the individual test files.$ PYTHONPATH=./test python3 test/scenario_test/<scenario test name>.py --gobgp-image=gobgp ... OK
A lot of containers, networks temporary files are created during the test. Let's clean up.
$ docker rm -f $(sudo docker ps -a -q -f "label=gobgp-test")
$ docker network prune -f --filter "label=gobgp-test"
$ rm -rf /tmp/gobgp