Test files are located in the /TestON/tests/ folder. Each test contains a set of files defined below:
- .params - This file contains user defined variables, as well as specifies the order of which test cases to run.
- .topo - This file defines the components and options that TestON will use to execute the test. User name, password, IP addresses, drivers, and/or a Mininet topology are specified in this file. (Please use the exact syntax/format in the .topo file. The space character in the xml tags is important even if nothing is defined in the tag. Eg. <COMPONENTS> </COMPONENTS>)
- .py - This is where test cases are written. Test cases call upon functions implemented in their respective drivers to create a progression of events that produce a pass/fail outcome.
The test folder name is the name of the test, as well as the names of the .py, .params, and .topo files.
SAMPstartTemplate_1node and SAMPstartTemplate_3node tests:
These tests demonstrate several simple actions using TestON. The test is successful if all test cases succeed.
- CASE0: Pulls ONOS code and builds ONOS. This is usually skipped in the production environment for flexibility to handle testing different versions of ONOS
- CASE1: Sets up global test variables and removes existing instances of ONOS in the test cell
- CASE2: Reports errors, warnings, and exceptions in ONOS
- CASE10: Starts ONOS on the cell
- CASE11: Starts Mininet and assign mastership of switches to ONOS controllers
- CASE12: Tests some basic ONOS commands using the ONOS cli handle
- CASE22: Tests some basic ONOS commands using the REST API handle
- CASE32: Configures fwd app and run pingall
Below is the SAMPstartTemplate_1node.params file:
The <testcases> tag defines the order in which the test cases in the .py file are executed. <PARAMS> and <testcases> are mandatory, case sensitive tags.
Below is the SAMPstartTemplate_1node.topo file:
The .topo file includes the login info of the machine that will run ONOS and Mininet. In this example, the test runs using two virtual machines with host IP, username, password, and driver that are defined for Mininet and ONOS components. The <type> tag specifies which driver the component will use. The <connect_order> tag is the connection order that TestON will execute. In the .topo file, all tags are required, but driver specific tags may be reordered between the components tags.
NOTE: It is important to check the login info carefully for each component as incorrect information would result in a test failure.
The .py file defines the test cases. All of the TestON tests follow the PEP8 coding style. Check out our built-in PEP8 code checker at /TestON/bin/codecheck.
Test case results should be asserted at the end of the case using the TestON utilities class. There are four types of assertions: "equals", "matches", "greater", and "lesser". Below is an example of "equals" assertion in case 10:
Log and Report Files
There are two ways to specify the log directory path:
- Augmenting a command line option: --logdir "/path/to/logdirectory"
- Adding a parameter in the .params file: 'logdir' = '/path/to/logdirectory'
Note: If the log directory path is not specified, the default log path will be used: /TestON/logs/test_name_time/
After test execution, there will be three types of log files:
- test_name_time.log - Detailed verbose log of everything that the script does.
- test_name_time.rpt - Summary report of test case results.
- component_name.SESSION - Log of all commands/APIs run on this component with response.
Now that you have created your test cases, you can now run your test by following the tutorial on how to run TestON. You may also improve your test by modifying the current TestON drivers or creating your own test specific drivers. Check the TestON Drivers article for more information.