add testcase for using network-cfg.json to configure switches during
ONOS startup
Change-Id: I07cd9ac10465e6a135244f1db2edfa95ea0685ff
diff --git a/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.params b/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.params
index bf5fbac..373f007 100644
--- a/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.params
+++ b/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.params
@@ -12,8 +12,10 @@
# 22 - Add NetCfgs for discovered devices
# 23 - Check NetCfgs after all devices are connected and NetCfgs are set
# 24 - Remove NetCfgs
+ # 25 - Move network-cfg.json to onos directory for prebuild configurations
+ # 26 - Check that prebuild configurations are correct
- <testcases>1,2,20,11,21,22,23,24</testcases>
+ <testcases>1,25,2,20,11,26,21,22,23,24</testcases>
<DEPENDENCY>
<path>/tests/FUNC/FUNCnetCfg/dependencies/</path>
@@ -36,7 +38,7 @@
</SLEEP>
<MININET>
- <switch>4</switch>
+ <switch>6</switch>
</MININET>
</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.py b/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.py
index 2c3622b..0f8812a 100644
--- a/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.py
+++ b/TestON/tests/FUNC/FUNCnetCfg/FUNCnetCfg.py
@@ -87,7 +87,7 @@
main.log.error( "Did not properly created list of ONOS handle" )
stepResult = main.FALSE
except Exception as e:
- main.log.exception(e)
+ main.log.exception( e )
main.cleanup()
main.exit()
@@ -333,7 +333,7 @@
main.step( "Starting Mininet topology with OF 1.3 switches" )
args = "--controller none --switch ovs,protocols=OpenFlow13"
- switches = int( main.params['MININET']['switch'] )
+ switches = int( main.params[ 'MININET' ][ 'switch' ] )
cmd = "mn --topo linear,{} {}".format( switches, args )
topoResult = main.Mininet1.startNet( mnCmd = cmd )
stepResult = topoResult
@@ -485,13 +485,13 @@
devices = main.ONOSrest1.devices()
main.log.debug( main.ONOSrest1.pprint( devices ) )
allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2, 4 ] ]
- print allowedDevices
+ main.log.debug( allowedDevices )
onosDevices = []
try:
for sw in json.loads( devices ):
onosDevices.append( str( sw['id'] ) )
onosDevices.sort()
- print onosDevices
+ main.log.debug( onosDevices )
except( TypeError, ValueError ):
main.log.error( "Problem loading devices" )
utilities.assert_equals( expect=allowedDevices,
@@ -771,3 +771,59 @@
actual=get,
onpass="Successfully removed device config",
onfail="Failed to remove device config" )
+
+ def CASE25( self, main ):
+ """
+ Use network-cfg.json to configure devices during ONOS startup
+ """
+ main.case( "Preparing network-cfg.json to load configurations" )
+ main.step( "Moving network-cfg.json to $ONOS_ROOT/tools/package/config/" )
+ prestartResult = main.TRUE
+ srcPath = "~/OnosSystemTest/TestON/tests/FUNC/FUNCnetCfg/dependencies/network-cfg.json"
+ dstPath = "~/onos/tools/package/config/network-cfg.json"
+ prestartResult = main.ONOSbench.scp( main.ONOSbench, srcPath, dstPath, direction="to" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=prestartResult,
+ onpass="Successfully copied network-cfg.json to target directory",
+ onfail="Failed to copy network-cfg.json to target directory" )
+
+ def CASE26( self, main ):
+ """
+ Check to see that pre-startup configurations were set correctly
+ """
+ import json
+ main.case( "Check to see if the pre-startup configurations were set, then remove their allowed status" )
+ main.step( "Checking configurations for Switches 5 and 6" )
+ main.step( "ONOS should only show devices S1, S2, S4, S5, and S6" )
+ devices = main.ONOSrest1.devices()
+ main.log.debug( main.ONOSrest1.pprint( devices ) )
+ allowedDevices = [ "of:{}".format( str( i ).zfill( 16 ) ) for i in [ 1, 2, 4, 5, 6 ] ]
+ main.log.debug( allowedDevices )
+ onosDevices = []
+ try:
+ for sw in json.loads( devices ):
+ onosDevices.append( str( sw['id'] ) )
+ onosDevices.sort()
+ main.log.debug( onosDevices )
+ except( TypeError, ValueError ):
+ main.log.error( "Problem loading devices" )
+ utilities.assert_equals( expect=allowedDevices,
+ actual=onosDevices,
+ onpass="Only allowed devices are in ONOS",
+ onfail="ONOS devices doesn't match the list" +
+ " of allowed devices" )
+
+ main.step( "Removing allowed status from Switches 5 and 6" )
+ main.s5Json = { "allowed": False }
+ main.s6Json = { "allowed": False }
+ s5Json = main.s5Json
+ setS1 = main.ONOSrest1.setNetCfg( s5Json,
+ subjectClass="devices",
+ subjectKey="of:0000000000000005",
+ configKey="basic" )
+
+ s6Json = main.s6Json
+ setS1 = main.ONOSrest1.setNetCfg( s6Json,
+ subjectClass="devices",
+ subjectKey="of:0000000000000006",
+ configKey="basic" )
\ No newline at end of file
diff --git a/TestON/tests/FUNC/FUNCnetCfg/dependencies/network-cfg.json b/TestON/tests/FUNC/FUNCnetCfg/dependencies/network-cfg.json
new file mode 100644
index 0000000..92f647a
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCnetCfg/dependencies/network-cfg.json
@@ -0,0 +1,10 @@
+{
+ "devices": {
+ "of:0000000000000005": {
+ "allowed": true
+ },
+ "of:0000000000000006": {
+ "allowed": true
+ }
+ }
+ }
\ No newline at end of file