Running ONOS example system test

Posted on Categories software testing

ONOS is SDN network controller, much like the opendaylight, but more widely adopted in the operator industry, and it is chosen as the Stratum OS component. I have been a software test engineer for more than 5 years, so i take the interest to run the system test, here we go.

Notes:This test is run on a Ubuntu 18 LTS server with docker installed

to be able to run the example as in stated here, we will need simple network topology:

you will need three user environment:

  • a user on the ubuntu server for starting the test, acting as the management machine
  • a user(sdn) on the same Ubuntu server for communicating with the ONOS instance running in the docker container
  • a docker container for running the onos server software
  • we will use local mininet installation on the server to simulate the network devices

Environment setup

download the ONOS source code

git clone

we will add some ONOS project utilities to the environment to make following config more easy, add the following line to .profile

export ONOS_ROOT=~/onos
source $ONOS_ROOT/tools/dev/bash_profile

open a new terminal and test the utilities are working:

danny@danny-xps:~$ cell

we also need to download the ONOS System Test code :

git clone

Create the environment components

create sdn user

create a sdn user on the ubuntu server:

sudo useradd -m -d /home/sdn/ sdn # create user and home dir
sudo passwd sdn                   #set user password
sudo usermod -aG sudo sdn         #add user to sudo group
sudo visudo 

the last command is to modify the sudo config file, we will enable sdn user to do sudo without type in password, add the following line in the popped file


because the ONOS test will switch to sdn user by ssh sdn@localhost, we also need to setup passwordless login with ssh keys:

first generate an ssh key if you don’t have one for your current account

ssh-keygen -t rsa 
onos-push-keys localhost # this is one of the ONOS utilities, and will add the default sdn user name when connecting to the localhost, type in the password you configured before

after you should be able to do ssh sdn@localhost without typing in any password

the sdn user have to have access to the ONOS source code(it need to push this to the onos container and sometimes test compiling the source code), we will not copy all the source from our default user directory(that will take too much space), instead we create a shared folder:

sudo groupadd onos   # create a group to add your default user(for me it is danny) and sdn 
sudo usermod -a -G onos danny
sudo usermod -a -G onos sdn
sudo chgrp -R onos /your_path_to_onos_source_code
sudo chmod -R 2775 /your_path_to_onos_source_code

switch user sdn and create an onos soft link in the home dir

ln -s /your_path_to_onos_source_code onos

create onos container

create an Ubuntu container, and add an sdn user as described before so that

  • you can ssh into the container without type in password
  • the sdn user can do sudo without type in password

Install software

for the default user and sdn user, install the following software:

  • bazel # for build the onos
  • curl
  • jdk 1.8 # for building the onos source code

for the ONOS container:

  • jdk1.8
  • curl

for how to install JDK1.8, please check this page

build the ONOS source code

when using bazel to build the onos source code, it will download a lot of packages, if you have a slow internet, it will timeout a lot, so it is recommended to build beforehand

cd /onos_source_path
bazel build onos

if it fails with timeout error, just restart until it succeeds

Run the test

before we are able to run the test, we need to set the cell, a cell is a test environment description file, it is located in $ONOS_ROOT/toos/test/cells

for this single test case, we will use the cell named demo and we only need to update the ONOS container ip address:

export OC1=""   # change this one to your container ip

export OC2=""

export OC3=""

export OCN=""
export ONOS_APPS=gui,drivers,openflow,proxyarp
alias sshnet="ssh onos@$OCN"

load the cell to your environment by running cell demo, after check the current cell is demo by running cell

danny@danny-xps:~$ cell

now you think you have finished preparing the environment and you can start running the test, but not quit yet. somehow there is still a environment description file for every testcase, we also need to configure that one.

our example testcase is SAMPstartTemplate_1node, you can find it under the OnosSystemTest source dir in OnosSystemTest/TestON/tests/SAMP/SAMPstartTemplate_1node, under it there is a file called SAMPstartTemplate_1node.topo, since we are using local Ubuntu server as mininet host machine, change the mininet host to localhost


now we finally can start running the test

cd OnosSystemTest/TestON/bin
./ run SAMPstartTemplate_1node

the test will first switch to sdn user by ssh sdn@localhost, from there it will use the ONOS utilizes to build and push the compiled software to the ONOS container, so be sure to add the ONOS utilities to the sdn user .profile file

Leave a Reply

Your email address will not be published. Required fields are marked *