github.com/osrg/gobgp/v3@v3.30.0/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  - [Scenario Test](#scenario-test)
     8    - [Contents](#contents)
     9    - [Prerequisites](#prerequisites)
    10    - [Set up dependencies](#set-up-dependencies)
    11    - [Build GoBGP docker image form your source code](#build-gobgp-docker-image-form-your-source-code)
    12    - [Run tests](#run-tests)
    13    - [Clean up](#clean-up)
    14  
    15  ## Prerequisites
    16  
    17  Go, Docker, and Python3 need to be set up.
    18  
    19  ```shell
    20  $ python --version
    21  Python 3.9.7
    22  
    23  $ go version
    24  go version go1.17 linux/arm64
    25  
    26  $ docker version
    27  Client:
    28   Version:           20.10.7
    29   API version:       1.41
    30   Go version:        go1.13.8
    31   Git commit:        20.10.7-0ubuntu5.1
    32   Built:             Mon Nov  1 00:34:28 2021
    33   OS/Arch:           linux/arm64
    34   Context:           default
    35   Experimental:      true
    36  
    37  Server:
    38   Engine:
    39    Version:          20.10.7
    40    API version:      1.41 (minimum version 1.12)
    41    Go version:       go1.13.8
    42    Git commit:       20.10.7-0ubuntu5.1
    43    Built:            Thu Oct 21 23:58:58 2021
    44    OS/Arch:          linux/arm64
    45    Experimental:     false
    46   containerd:
    47    Version:          1.5.5-0ubuntu3
    48    GitCommit:
    49   runc:
    50    Version:          1.0.1-0ubuntu2
    51    GitCommit:
    52   docker-init:
    53    Version:          0.19.0
    54    GitCommit:
    55  ```
    56  
    57  ## Set up dependencies
    58  
    59  Execute the following commands to install the dependencies:
    60  
    61  ```shell
    62  $ git clone https://github.com/osrg/gobgp
    63  $ cd ./gobgp
    64  $ python3 -m venv .test
    65  $ source .test/bin/activate
    66  $ pip install -r test/pip-requires.txt
    67  ```
    68  
    69  ## Build GoBGP docker image form your source code
    70  
    71  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.
    72  
    73  ```shell
    74  $ fab -r ./test/lib make-gobgp-ctn
    75  ```
    76  
    77  ## Run tests
    78  
    79  There are two ways to run tests
    80  
    81  1. Run all tests
    82  
    83      You can run all scenario tests with run_all_tests.sh.
    84      If all tests passed, you can see "all tests passed successfully" at the end of the test.
    85  
    86      ```shell
    87      $ ./test/scenario_test/run_all_tests.sh
    88      ...
    89      OK
    90      all tests passed successfully
    91      ```
    92  
    93  1. Run each test
    94  
    95      You can run scenario tests individually with each test file.
    96      See `test/scenario_test/*.py`, for the individual test files.
    97  
    98      ```shell
    99      $ PYTHONPATH=./test python3 test/scenario_test/<scenario test name>.py --gobgp-image=gobgp
   100      ...
   101      OK
   102      ```
   103  
   104  ## Clean up
   105  
   106  A lot of containers, networks temporary files are created during the test.
   107  Let's clean up.
   108  
   109  ```shell
   110  $ docker rm -f $(sudo docker ps -a -q -f "label=gobgp-test")
   111  $ docker network prune -f --filter "label=gobgp-test"
   112  $ rm -rf /tmp/gobgp
   113  ```