github.com/osrg/gobgp@v2.0.0+incompatible/test/scenario_test/README.md (about) 1 # Scenario Test 2 3 This page explains how to set up a scenario test environment and run the test. 4 5 ## Contents 6 7 - [Prerequisites](#prerequisites) 8 - [Check](#check) 9 - [Set up dependencies](#set-up-dependencies) 10 - [Install local source code](#install-local-source-code) 11 - [Run test](#run-test) 12 - [Clean up](#clean-up) 13 14 ## Prerequisites 15 16 Assume you finished setting up [Golang](https://golang.org/doc/install) and 17 [Docker](https://docs.docker.com/installation/ubuntulinux/) on Ubuntu 14.04 18 Server VM. 19 We recommend allocating memory more than 8GB to the VM. 20 Because this scenario test runs a lot of test cases concurrently. 21 22 ## Check 23 24 Please check if Golang and Docker is installed correctly and 25 make sure the $GOPATH is defined. 26 27 ```shell 28 $ go version 29 go version go1.5.1 linux/amd64 30 31 $ echo $GOPATH 32 /home/yokoi-h/work 33 34 $ sudo docker version 35 Client: 36 Version: 1.9.0 37 API version: 1.21 38 Go version: go1.4.2 39 Git commit: 76d6bc9 40 Built: Tue Nov 3 17:43:42 UTC 2015 41 OS/Arch: linux/amd64 42 43 Server: 44 Version: 1.9.0 45 API version: 1.21 46 Go version: go1.4.2 47 Git commit: 76d6bc9 48 Built: Tue Nov 3 17:43:42 UTC 2015 49 OS/Arch: linux/amd64 50 ``` 51 52 ## Set up dependencies 53 54 Execute the following commands inside the VM to install the dependencies: 55 56 1. Install pip and [pipework](https://github.com/jpetazzo/pipework). 57 58 ```shell 59 $ sudo apt-get update 60 $ sudo apt-get install git python-pip python-dev iputils-arping bridge-utils lv 61 $ sudo wget https://raw.github.com/jpetazzo/pipework/master/pipework -O /usr/local/bin/pipework 62 $ sudo chmod 755 /usr/local/bin/pipework 63 ``` 64 65 1. Get docker images. 66 67 Download docker images pertaining to GoBGP testing. 68 69 ```shell 70 $ sudo docker pull golang:1.7 71 $ sudo docker pull osrg/gobgp 72 $ sudo docker pull osrg/quagga 73 $ sudo docker pull osrg/quagga:v1.0 74 $ sudo docker pull osrg/exabgp 75 ``` 76 77 1. Clone GoBGP and install python libraries. 78 79 ```shell 80 $ mkdir -p $GOPATH/src/github.com/osrg 81 $ cd $GOPATH/src/github.com/osrg 82 $ git clone https://github.com/osrg/gobgp.git 83 $ cd ./gobgp/test 84 $ sudo pip install -r pip-requires.txt 85 ``` 86 87 ## Install local source code 88 89 You need to install local source code into GoBGP docker container. 90 You also need this operation at every modification to the source code. 91 92 ```shell 93 $ cd $GOPATH/src/github.com/osrg/gobgp 94 $ sudo fab -f ./test/lib/base.py make_gobgp_ctn --set tag=gobgp 95 ``` 96 97 ## Run test 98 99 1. Run all test. 100 101 You can run all scenario tests with run_all_tests.sh. 102 If all tests passed, you can see "all tests passed successfully" at the end of the test. 103 104 ```shell 105 $ cd $GOPATH/src/github.com/osrg/gobgp/test/scenario_test 106 $ ./run_all_tests.sh 107 ... 108 OK 109 all tests passed successfully 110 ``` 111 112 1. Run each test. 113 114 You can run scenario tests individually with each test file. 115 See `test/scenario_test/*.py`, for the individual test files. 116 117 ```shell 118 $ cd $GOPATH/src/github.com/osrg/gobgp/test/scenario_test 119 $ sudo -E PYTHONPATH=$GOBGP/test python <scenario test name>.py 120 ... 121 OK 122 ``` 123 124 ## Clean up 125 126 A lot of containers, networks temporary files are created during the test. 127 Let's clean up. 128 129 ```shell 130 $ sudo docker rm -f $(sudo docker ps -a -q -f "label=gobgp-test") 131 $ sudo docker network prune -f --filter "label=gobgp-test" 132 $ sudo rm -rf /tmp/gobgp 133 ```