Skip to content

Commit

Permalink
adding travis test
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninbas committed Jul 20, 2016
1 parent f7376df commit c529efc
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 4 deletions.
41 changes: 41 additions & 0 deletions .travis.yml
@@ -0,0 +1,41 @@
# Config file for automatic testing at travis-ci.org

sudo: required

# workaround for a travis Python issue
# see https://github.com/travis-ci/travis-ci/issues/4948
language: generic

dist: trusty

# My very smart trick to force inclusion of the veth kernel module
# (even though we do not use docker at all her)
services:
- docker

addons:
apt:
packages:
- python-dev
- python-pip
- cmake
- libffi-dev

before_install:
- sudo apt-get install ethtool
- sudo pip install --upgrade pip
- sudo apt-get remove python-scapy
- git clone https://github.com/p4lang/scapy-vxlan.git && cd scapy-vxlan && sudo python setup.py install && cd ..
- bash CI/travis/install-nanomsg.sh
- sudo ldconfig
- bash CI/travis/install-nnpy.sh

install:
- sudo python setup.py install

before_script:
- cd ptf_nn/; sudo ./veth_setup.sh; cd ..

script:
- python CI/travis/check-nnpy.py
- ./CI/travis/run_tests.sh
File renamed without changes.
34 changes: 34 additions & 0 deletions CI/travis/common.sh
@@ -0,0 +1,34 @@
force=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-f|--force)
force=1
;;
*)
# unknown option
;;
esac
shift # past argument or value
done

function quit {
if [ $force == 0 ]; then
echo "skipping installation, you can force installation with '-f'"
exit 0
fi
}

function check_lib {
ldconfig -p | grep $2 &> /dev/null
if [ $? == 0 ]; then
echo "$2 found"
quit
fi
ldconfig -p | grep $1 &> /dev/null
if [ $? == 0 ]; then
echo "a version of $1 was found, but not $2"
echo "you may experience issues when using a different version"
quit
fi
}
22 changes: 22 additions & 0 deletions CI/travis/install-nanomsg.sh
@@ -0,0 +1,22 @@
#!/bin/sh

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $THIS_DIR/common.sh

# nanomsg is very confusing in how it manages SOVERSION vs VERSION, but this
# should be okay... (5.0.0 is the SOVERSION)
check_lib libnanomsg libnanomsg.so.5.0.0

set -e
wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz -O nanomsg-1.0.0.tar.gz
tar -xzvf nanomsg-1.0.0.tar.gz
cd nanomsg-1.0.0
mkdir build
cd build
# I added -DCMAKE_INSTALL_PREFIX=/usr because on my Ubuntu 14.04 machine, the
# library is installed in /usr/local/lib/x86_64-linux-gnu/ by default, and for
# some reason ldconfig cannot find it
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
cmake --build .
sudo cmake --build . --target install
cd ..
File renamed without changes.
23 changes: 23 additions & 0 deletions CI/travis/run_tests.sh
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

sudo python ptf_nn/ptf_nn_agent.py \
--device-socket 0@tcp://127.0.0.1:10001 -i 0-1@veth0 \
&>/dev/null &

sleep 5

sudo python ptf_nn/ptf_nn_agent.py \
--device-socket 1@tcp://127.0.0.1:10002 -i 1-1@veth3 \
&>/dev/null &

sleep 5

sudo python ptf_nn/ptf_nn_test_bridge.py -ifrom veth1 -ito veth2 \
&>/dev/null &

sleep 5

sudo ptf --test-dir ptf_nn/ptf_nn_test \
--device-socket 0-{0-64}@tcp://127.0.0.1:10001 \
--device-socket 1-{0-64}@tcp://127.0.0.1:10002 \
--platform nn
8 changes: 4 additions & 4 deletions ptf_nn/README.md
Expand Up @@ -17,10 +17,10 @@ to install the following:
- [nanomsg](https://github.com/nanomsg/nanomsg/releases): we recommend
installing the `1.0.0` production release.
- [nnpy](https://github.com/nanomsg/nnpy): these are the Python bindings for
nanomsg. You may use the provided [install_nnpy.sh](install_nnpy.sh) script
nanomsg. You may use the provided (install-nnpy.sh)[install-nnpy.sh] script
to install nnpy. It will install a version of nnpy that we have tested.

We provide a [check_deps.py](check_deps.py) script that you can run to check
We provide a [check-nnpy.py](check-nnpy.py) script that you can run to check
that nanomsg and nnpy are running properly.

## Overview
Expand All @@ -33,8 +33,8 @@ between a set of interfaces (connected to the switch) and the PTF
tester. Packets received on an interface (from the switch) will be tagged with
the port number and forwarded to the PTF tester. Packets received from the PTF
tester will be forwarded to the switch using the appropriate
interface. Communications between the PTF tester and each agent is done over TCP
using the nanomsg messaging library.
interface. Communications between the PTF tester and each agent are done over
TCP using the nanomsg messaging library.

## Demo

Expand Down
1 change: 1 addition & 0 deletions ptf_nn/check-nnpy.py
1 change: 1 addition & 0 deletions ptf_nn/install-nnpy.py
2 changes: 2 additions & 0 deletions ptf_nn/veth_setup.sh
Expand Up @@ -7,4 +7,6 @@ for idx in 0 1; do
ip link set dev $intf0 up
ip link set dev $intf1 up
fi
sysctl net.ipv6.conf.$intf0.disable_ipv6=1
sysctl net.ipv6.conf.$intf1.disable_ipv6=1
done

0 comments on commit c529efc

Please sign in to comment.