Skip to content
Open
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
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: sysrepo-plugin-snabb CI

on:
push:
branches: ["devel"]
pull_request:
branches: ["devel"]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: deps-libyang
shell: bash
run: |
git clone https://github.com/cesnet/libyang
cd libyang
CC=gcc cmake -B build
cmake --build build
sudo cmake --install build
sudo ldconfig
cd ..

- name: Deps-sysrepo
shell: bash
run: |
git clone https://github.com/sysrepo/sysrepo
cd sysrepo
CC=gcc cmake -B build
cmake --build build
sudo cmake --install build
sudo ldconfig
cd ..

- name: Deps-snabb
shell: bash
run: |
git clone https://github.com/SnabbCo/snabb
cd snabb
make -j4 && sudo make install
sudo ldconfig
cd ..

- name: Snabb-plugin
shell: bash
working-directory: ${{github.workspace}}
run: |
cmake -B build -DCMAKE_BUILD_TYPE:String="Release" \
-DPLUGIN:BOOL=ON -DSR_PLUGINS_DIR=/usr/local/lib/ \
-DYANG_MODEL:String="snabb-softwire-v3"
cd build
make -j4
sudo make install
sudo ldconfig
cd ..

- name: Install-yang-model
shell: bash
working-directory: ${{github.workspace}}
run: |
sudo sysrepoctl -i snabb/src/lib/yang/snabb-softwire-v3.yang
26 changes: 26 additions & 0 deletions tests/robot-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Integration tests for sysrepo-snabb-plugin

# Requirements
* Sysrepo
* Snabb
* Libyang
* Python packages inside of "requirements.txt"
* Robot framework

# Running
Before running the tests for the first time run the as ```setup.sh``` script
as root, also make sure that you have built the the plugin and have snabb installed.
The script will fetch the configuration file for the tests and
create the virtual interfaces needed for execution of the tests.
It will also create a python virtual environment with the needed
python packages.

Activate virtual python environment with
```
source ./test-venv/bin/activate
```

After you have done all that, you may run the tests with
```
robot ./src/Main.robot
```
10 changes: 10 additions & 0 deletions tests/robot-tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build
cffi
libyang
packaging
pycparser
pyproject_hooks
robotframework
robotframework-sysrepolibrary
sysrepo
xmltodict
29 changes: 29 additions & 0 deletions tests/robot-tests/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Requirements
# Before running this script make sure these requirements are satisfied
# Compile the sysrepo-snabb-plugin in the root directory of this project
# Install snabb on your system

set -e

# Get the bare minimum config and veth setup script
if [ ! -e lwaftr-veth-env.sh ]; then
curl 'https://raw.githubusercontent.com/snabbco/snabb/master/src/program/lwaftr/doc/tutorial/lwaftr-veth-env.sh' \
> lwaftr-veth-env.sh
fi

if [ ! -e ./config/lwaftr-start.conf ]; then
mkdir config
curl 'https://raw.githubusercontent.com/snabbco/snabb/master/src/program/lwaftr/doc/tutorial/lwaftr-start.conf' \
> ./config/lwaftr-start.conf
fi


# create venv with dependencies
if [ ! -d test-venv ];then
python -m test-venv && pip install -r requirements.txt
fi

# Run the veth setup script
sh lwaftr-veth-env.sh create
49 changes: 49 additions & 0 deletions tests/robot-tests/src/Main.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
*** Settings ***
Library Collections
Library OperatingSystem
Library String
Library Process
Library BuiltIn
Library SysrepoLibrary
Library XML

Resource PluginInit.resource

Test Setup Startup
Test Teardown Cleanup

*** Test Cases ***
Test Get External Interface Name
[Documentation] Check if it's possible to get data values from the snabb config
${Interface Name}= Get Datastore Data ${Connection}
... ${Session Running} /softwire-config/instance/external-device xml
Element Text Should Be ${Interface Name} aftrv4 xpath=*/external-device

Test Add softwire
[Documentation] Creates a new softwire entry to the datastore and check if it has been added to the snabb lwaftr config
${New softwire}= catenate SEPARATOR=
... <softwire>
... <ipv4>0.0.0.0</ipv4>
... <psid>1</psid>
... <padding>0</padding>
... <br-address>1e:1:1:1:1:1:1:af</br-address>
... <b4-ipv6>127:24:35:46:57:68:79:128</b4-ipv6>
... <port-set>
... <psid-length>16</psid-length>
... <reserved-ports-bit-count>0</reserved-ports-bit-count>
... </port-set>
... </softwire>

${New softwire entry}= catenate SEPARATOR=
... <softwire-config xmlns="snabb:softwire-v3">
... <binding-table>
... ${New softwire}
... </binding-table>
... </softwire-config>
Edit Datastore Config ${Connection} ${Session Running} ${New softwire entry} xml
${Datastore state}= Get Datastore Data ${Connection} ${Session Running}
... * xml
${Softwire Elements}= Get Elements ${Datastore state} xpath=*/softwire
${tmp}= Element to String ${Softwire Elements}[1]
Elements Should Be Equal ${New softwire} ${Softwire Elements}[1]

42 changes: 42 additions & 0 deletions tests/robot-tests/src/PluginInit.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
** Settings ***
Library OperatingSystem
Library SysrepoLibrary


*** Variables ***
${CONFIG_FILE_PATH} config/lwaftr-start.conf
${SNABB_LWAFTR_INSTANCE_NAME} sysrepo-snabb-plugin-test

*** Keywords ***

Start Plugin
${Plugin}= Start Process sysrepo-snabb-plugin
Set Global Variable ${Plugin}
Wait For Process ${Plugin} timeout=0.5s on_timeout=continue

Stop Plugin
Terminate Process ${Plugin}

Connect To Softwire
${Connection}= Open Sysrepo Connection
Set Global Variable ${Connection}
${Session Running}= Open Datastore Session ${Connection} running
Set Global Variable ${Session Running}

Start Snabb
${Snabb}= Start Process snabb lwaftr run --config ${CONFIG_FILE_PATH} --name ${SNABB_LWAFTR_INSTANCE_NAME}
Set Global Variable ${Snabb}
Wait For Process ${Plugin} timeout=0.5s on_timeout=continue

Stop Snabb
Terminate Process ${Snabb}

Startup
Start Plugin
Start Snabb
Set Global Variable ${SNABB_LWAFTR_INSTANCE_NAME}
Connect To Softwire

Cleanup
Stop Plugin
Stop Snabb