This section covers development and test environment setup and configuration.

IDE Setup

We don't enforce the use of a specific IDE, but rather, a set of guidelines that can be configured in an IDE.

Code Formatting

The formatting followed by the project are:

The whitespace formatting, among other code styling, is enforced via Checkstyle, which is run against the code during each Maven build. The build will fail if formatting violations are found.

Copyright

Prior to contributing code to ONOS, all developers should set-up their IDE to appropriately tag the code with the Apache 2 license header text. The bare text is checked in under tools/dev/header.txt, and the orginal can be found at: 

http://www.apache.org/licenses/LICENSE-2.0.html

Example: Copyright setup on IntelliJ

First make sure that you have the Copyright plugin enabled. Then, under Preferences, select Copyright section and create a new Copyright profile, call it something like Apache 2, and prime it with the text above, without any decorations. Then configure your copyright formatting options as shown:

Testing

Testing a distributed platform like ONOS can become a cumbersome task. ONOS, being an SDN controller authored in Java, can run on a variety of platforms. However, in the interest of focus, the project engages primarily in testing on Ubuntu server distributions, specifically Ubuntu Server 14.04* LTS 64-bit, using the Oracle Java 8 JRE.

Additionally, in order to simplify testing and to make it more repeatable, a number of assets have been developed to make the developer’s  and tester’s lives easier. These are located under the ONOS_ROOT/tools/test/.

Overview

An ONOS developer's environment may include the following:

Test Cells

The notion of a test cell refers to a specific controller cluster environment designated for testing. This can mean a set of bare-metal servers, or a set of virtual machines running on developer’s laptop. Cell definition files are bash snippets that export a few environment variables into the developer’s (or tester’s) shell. These variables are then used by a number of the ONOS test and utility scripts. This allows the scripts and test scenarios to be independent to a specific test bench setup.

Using cells

Cell definitions are loaded into the shell environment with the cell utility. This utility takes the name of a cell definition file as the argument. For example:

$ cell local                                              
ONOS_CELL=local
OCI=192.168.56.101
OC1=192.168.56.101
OC2=192.168.56.102
OCN=192.168.56.103
ONOS_FEATURES=webconsole,onos-api,onos-core,onos-cli,onos-openflow,onos-gui,onos-rest,onos-app-fwd,onos-app-proxyarp,onos-app-tvue
ONOS_NIC=192.168.56.*

Now, utilities such as onos will fall back to using the value set in OCI (192.168.56.101 for above) if not given any parameters. 

The utility script cells can be used to view all available cell definitions. Without parameters, cell will list the values associated with the current cell in use.

Cell Definition Files

A cell definition file defines values for a set of environment variables understood by the ONOS scripts. A cell definition file may look like the following:

# Default ONOS Controller VM instances 1,2,3 and a Mininet VM
export OC1="192.168.56.101"
export OC2="192.168.56.102"
export OC3="192.168.56.104"
export OCN="192.168.56.103"  # Mininet VM
       
# for node clustering
export ONOS_NIC=”192.168.56.*”    

# ONOS features to load
export ONOS_FEATURES="webconsole,onos-api,onos-core-trivial,onos-cli"

These files are located in ONOS_ROOT/tools/test/cells/. Custom cell definition files may be added to this directory and loaded as needed with cell.