[ONOS-6593]Review and Refactor ONOS startup procedures in TestON
Change-Id: I509a8ee7a26c198957bebf59da5c85a0edb8b995
diff --git a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.params b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.params
index a50d461..2d46894 100644
--- a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.params
+++ b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.params
@@ -14,8 +14,8 @@
</CTRL>
<GIT>
- <autoPull>on</autoPull>
- <branch1>master</branch1>
+ <pull>False</pull>
+ <branch>master</branch>
<branch2>onos-1.2</branch2>
</GIT>
diff --git a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
index b3d34de..5c1244e 100644
--- a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
+++ b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.py
@@ -19,58 +19,24 @@
onos-install -f
onos-wait-for-start
"""
- main.case( "Setting up test environment" )
+ try:
+ from tests.dependencies.ONOSSetup import ONOSSetup
+ main.testSetUp = ONOSSetup()
+ except ImportError:
+ main.log.error( "ONOSSetup not found. exiting the test" )
+ main.exit()
+ main.testSetUp.envSetupDescription()
+ stepResult = main.FALSE
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ try:
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params['CTRL']['ip1']
+ stepResult = main.testSetUp.envSetup( specificIp=ONOS1Ip )
+ except Exception as e:
+ main.testSetUp.envSetupException( e )
+ main.testSetUp.evnSetupConclusion( stepResult )
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- branchName = main.ONOSbench.getBranchName()
- main.log.info( "ONOS is on branch: " + branchName )
-
- main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
-
- # gitPullResult = main.TRUE
-
- main.step( "Git pull" )
- gitPullResult = main.ONOSbench.gitPull()
-
-
- main.ONOSbench.getVersion( report = True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
- node = ONOS1Ip )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-
- main.step( "Checking if ONOS is up yet" )
- for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
- if onos1Isup:
- break
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
-
- cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
- commandlineTimeout = 100, onosStartTimeout = 600 )
-
- case1Result = ( packageResult and cellResult and
- verifyResult and onos1InstallResult and
- onos1Isup and secureSshResult and
- cliResult )
-
- utilities.assert_equals( expect = main.TRUE, actual = case1Result,
- onpass = "ONOS startup successful",
- onfail = "ONOS startup NOT successful" )
+ case1Result = main.testSetUp.ONOSSetUp( "", newCell=False, cellname=cellName )
if case1Result == main.FALSE:
main.cleanup()
@@ -136,10 +102,10 @@
routeIntentsExpectedHost4 + routeIntentsExpectedHost5
main.step( "Get links in the network" )
- listResult = main.ONOScli.links( jsonFormat = False )
+ listResult = main.ONOScli1.links( jsonFormat = False )
main.log.info( listResult )
main.log.info( "Activate sdn-ip application" )
- main.ONOScli.activateApp( "org.onosproject.sdnip" )
+ main.ONOScli1.activateApp( "org.onosproject.sdnip" )
# wait sdn-ip to finish installing connectivity intents, and the BGP
# paths in data plane are ready.
time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
@@ -194,7 +160,7 @@
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
# get routes inside SDN-IP
- getRoutesResult = main.ONOScli.routes( jsonFormat = True )
+ getRoutesResult = main.ONOScli1.routes( jsonFormat = True )
allRoutesActual = \
main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
@@ -211,7 +177,7 @@
onpass = "***Routes in SDN-IP are correct!***",
onfail = "***Routes in SDN-IP are wrong!***" )
- getIntentsResult = main.ONOScli.intents( jsonFormat = True )
+ getIntentsResult = main.ONOScli1.intents( jsonFormat = True )
main.step( "Check MultiPointToSinglePointIntent intents installed" )
# routeIntentsExpected are generated when generating routes
@@ -273,7 +239,7 @@
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
- getRoutesResult = main.ONOScli.routes( jsonFormat = True )
+ getRoutesResult = main.ONOScli1.routes( jsonFormat = True )
allRoutesActual = \
main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
main.log.info( "allRoutes_actual = " )
@@ -285,7 +251,7 @@
onfail = "***Routes number in SDN-IP is not 0, wrong!***" )
main.step( "Check intents after deleting routes" )
- getIntentsResult = main.ONOScli.intents( jsonFormat = True )
+ getIntentsResult = main.ONOScli1.intents( jsonFormat = True )
routeIntentsActualNum = \
main.QuaggaCliHost3.extractActualRouteIntentNum(
getIntentsResult )
diff --git a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.topo b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.topo
index 21cbfb4..226fa9a 100644
--- a/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.topo
+++ b/TestON/tests/USECASE/SDNIPfunction/SDNIPfunction.topo
@@ -12,7 +12,7 @@
</COMPONENTS>
</ONOSbench>
- <ONOScli>
+ <ONOScli1>
<host>127.0.0.1</host>
<user>sdn</user>
<password>rocks</password>
@@ -23,7 +23,7 @@
<karaf_password></karaf_password>
<prompt></prompt>
</COMPONENTS>
- </ONOScli>
+ </ONOScli1>
<ONOS1>
<host>10.128.4.52</host>
diff --git a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.params b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.params
index a7c774d..5c1ed8f 100644
--- a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.params
+++ b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.params
@@ -13,8 +13,8 @@
</CTRL>
<GIT>
- <autoPull>off</autoPull>
- <branch1>master</branch1>
+ <autoPull>False</autoPull>
+ <branch>master</branch>
<branch2>onos-1.3</branch2>
</GIT>
<timers>
diff --git a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
index 0134e42..772dad8 100644
--- a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
+++ b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.py
@@ -17,57 +17,24 @@
onos-install -f
onos-wait-for-start
"""
- main.case( "Setting up test environment" )
+ try:
+ from tests.dependencies.ONOSSetup import ONOSSetup
+ main.testSetUp = ONOSSetup()
+ except ImportError:
+ main.log.error( "ONOSSetup not found. exiting the test" )
+ main.exit()
+ main.testSetUp.envSetupDescription()
+ stepResult = main.FALSE
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
+ try:
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+ ONOS1Ip = main.params['CTRL']['ip1']
+ stepResult = main.testSetUp.envSetup( specificIp=ONOS1Ip )
+ except Exception as e:
+ main.testSetUp.envSetupException( e )
+ main.testSetUp.evnSetupConclusion( stepResult )
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- branchName = main.ONOSbench.getBranchName()
- main.log.info( "ONOS is on branch: " + branchName )
-
- main.log.report( "Uninstalling ONOS" )
- main.ONOSbench.onosUninstall( ONOS1Ip )
-
- main.step( "Git pull" )
- gitPullResult = main.FALSE
- #Need to push some new code to ONOS before using the git pull
- #gitPullResult = main.ONOSbench.gitPull()
-
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
-
- main.step( "Checking if ONOS is up yet" )
- for i in range( 2 ):
- onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
- if onos1Isup:
- break
- if not onos1Isup:
- main.log.report( "ONOS1 didn't start!" )
-
- cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
- commandlineTimeout=100, onosStartTimeout=600)
-
- case1Result = ( packageResult and cellResult and
- verifyResult and onos1InstallResult and
- onos1Isup and secureSshResult and
- cliResult )
-
- utilities.assert_equals( expect=main.TRUE, actual=case1Result,
- onpass="ONOS startup successful",
- onfail="ONOS startup NOT successful" )
+ case1Result = main.testSetUp.ONOSSetUp( "", newCell=False, cellname=cellName )
if case1Result == main.FALSE:
main.cleanup()
@@ -97,15 +64,15 @@
time.sleep( 10 )
main.step( "Get devices in the network" )
- listResult = main.ONOScli.devices( jsonFormat=False )
+ listResult = main.ONOScli1.devices( jsonFormat=False )
main.log.info( listResult )
main.step( "Get links in the network" )
- listResult = main.ONOScli.links ( jsonFormat=False )
+ listResult = main.ONOScli1.links ( jsonFormat=False )
main.log.info( listResult )
main.log.info( "Activate sdn-ip application" )
- main.ONOScli.activateApp( "org.onosproject.sdnip" )
+ main.ONOScli1.activateApp( "org.onosproject.sdnip" )
main.step("Sleep 1200 seconds")
# wait until SDN-IP receives all routes and ONOS installs all intents
@@ -116,7 +83,7 @@
main.log.info( "Total route number expected is:" )
main.log.info( routeNumberExpected )
- routeNumberActual = main.ONOScli.ipv4RouteNumber()
+ routeNumberActual = main.ONOScli1.ipv4RouteNumber()
main.log.info("Total route number actual is: ")
main.log.info(routeNumberActual)
@@ -131,7 +98,7 @@
main.log.info( "MultiPointToSinglePoint intent number expected is:" )
main.log.info( m2SIntentsNumberExpected )
- m2SIntentsNumberActual = main.ONOScli.m2SIntentInstalledNumber()
+ m2SIntentsNumberActual = main.ONOScli1.m2SIntentInstalledNumber()
main.log.info( "MultiPointToSinglePoint intent number actual is:" )
main.log.info(m2SIntentsNumberActual)
diff --git a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.topo b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.topo
index 8706d85..e5f3087 100644
--- a/TestON/tests/USECASE/SDNIPperf/SDNIPperf.topo
+++ b/TestON/tests/USECASE/SDNIPperf/SDNIPperf.topo
@@ -12,7 +12,7 @@
</COMPONENTS>
</ONOSbench>
- <ONOScli>
+ <ONOScli1>
<host>10.128.4.53</host>
<user>sdn</user>
<password>rocks</password>
@@ -23,7 +23,7 @@
<karaf_password></karaf_password>
<prompt></prompt>
</COMPONENTS>
- </ONOScli>
+ </ONOScli1>
<ONOS1>
<host>10.254.1.201</host>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRClusterRestart/SRClusterRestart.topo b/TestON/tests/USECASE/SegmentRouting/SRClusterRestart/SRClusterRestart.topo
index 5ad1b13..4d4ce2d 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRClusterRestart/SRClusterRestart.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRClusterRestart/SRClusterRestart.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo
index 5ad1b13..4d4ce2d 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamic/SRDynamic.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.topo b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.topo
index e0328c2..6c83bb2 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRHighAvailability/SRHighAvailability.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
index f63a8c2..28c6820 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SROnosFailure/SROnosFailure.topo b/TestON/tests/USECASE/SegmentRouting/SROnosFailure/SROnosFailure.topo
index 5ad1b13..4d4ce2d 100755
--- a/TestON/tests/USECASE/SegmentRouting/SROnosFailure/SROnosFailure.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SROnosFailure/SROnosFailure.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
index 5ad1b13..4d4ce2d 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSwitchFailure/SRSwitchFailure.topo b/TestON/tests/USECASE/SegmentRouting/SRSwitchFailure/SRSwitchFailure.topo
index 04f480a..b4b41ee 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRSwitchFailure/SRSwitchFailure.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRSwitchFailure/SRSwitchFailure.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 08eb9c9..1bdaea2 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -21,52 +21,41 @@
- Install ONOS package
- Build ONOS package
"""
- main.step( "Constructing test variables" )
- # Test variables
- main.cellName = main.params[ 'ENV' ][ 'cellName' ]
- main.apps = main.params[ 'ENV' ][ 'cellApps' ]
- main.diff = main.params[ 'ENV' ][ 'diffApps' ]
- gitBranch = main.params[ 'GIT' ][ 'branch' ]
- main.path = os.path.dirname( main.testFile )
- main.dependencyPath = main.path + "/../dependencies/"
- main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
- wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
- main.scale = (main.params[ 'SCALE' ][ 'size' ]).split( "," )
- main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
- # main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
- main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
- main.cellData = { } # for creating cell file
- main.CLIs = [ ]
- main.ONOSip = [ ]
- main.RESTs = [ ]
+ try:
+ from tests.dependencies.ONOSSetup import ONOSSetup
+ main.testSetUp = ONOSSetup()
+ except ImportError:
+ main.log.error( "ONOSSetup not found. exiting the test" )
+ main.exit()
+ main.testSetUp.envSetupDescription()
+ stepResult = main.FALSE
+ try:
+ main.step( "Constructing test variables" )
+ # Test variables
+ main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ main.diff = main.params[ 'ENV' ][ 'diffApps' ]
+ main.path = os.path.dirname( main.testFile )
+ main.dependencyPath = main.path + "/../dependencies/"
+ main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ main.scale = (main.params[ 'SCALE' ][ 'size' ]).split( "," )
+ main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
+ # main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ # -- INIT SECTION, ONLY RUNS ONCE -- #
- # Assigning ONOS cli handles to a list
- for i in range( 1, main.maxNodes + 1 ):
- main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
- main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
- main.ONOSip.append( main.CLIs[ i - 1 ].ip_address )
- # -- INIT SECTION, ONLY RUNS ONCE -- #
- main.startUp = imp.load_source( wrapperFile1,
- main.dependencyPath +
- wrapperFile1 +
- ".py" )
+ copyResult1 = main.ONOSbench.scp( main.Mininet1,
+ main.dependencyPath +
+ main.topology,
+ main.Mininet1.home,
+ direction="to" )
+ stepResult = main.testSetUp.envSetup( hasRest=True )
+ except Exception as e:
+ main.testSetUp.envSetupException( e )
+ main.testSetUp.evnSetupConclusion( stepResult )
- copyResult1 = main.ONOSbench.scp( main.Mininet1,
- main.dependencyPath +
- main.topology,
- main.Mininet1.home,
- direction="to" )
- if main.CLIs:
- stepResult = main.TRUE
- else:
- main.log.error( "Did not properly created list of ONOS CLI handle" )
- stepResult = main.FALSE
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully construct " +
- "test variables ",
- onfail="Failed to construct test variables" )
@staticmethod
def installOnos( main, vlanCfg=True ):
@@ -82,83 +71,29 @@
- Connect to cli
"""
# main.scale[ 0 ] determines the current number of ONOS controller
- apps = main.apps
if main.diff:
- apps = main.apps + "," + main.diff
+ main.apps = main.apps + "," + main.diff
else:
main.log.error( "App list is empty" )
print "NODE COUNT = ", main.numCtrls
print main.ONOSip
- tempOnosIp = [ ]
main.dynamicHosts = [ 'in1', 'out1' ]
- for i in range( main.numCtrls ):
- tempOnosIp.append( main.ONOSip[ i ] )
- onosUser = main.params[ 'ENV' ][ 'cellUser' ]
- main.step( "Create and Apply cell file" )
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
- "temp",
- main.Mininet1.ip_address,
- apps,
- tempOnosIp,
- onosUser,
- useSSH=Testcaselib.useSSH )
- cellResult = main.ONOSbench.setCell( "temp" )
- verifyResult = main.ONOSbench.verifyCell( )
- stepResult = cellResult and verifyResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully applied cell to " + \
- "environment",
- onfail="Failed to apply cell to environment " )
+ main.testSetUp.createApplyCell( newCell=True, cellName=main.cellName,
+ Mininet=main.Mininet1, useSSH=Testcaselib.useSSH )
# kill off all onos processes
main.log.info( "Safety check, killing all ONOS processes" +
" before initiating environment setup" )
for i in range( main.maxNodes ):
main.ONOSbench.onosDie( main.ONOSip[ i ] )
- main.step( "Create and Install ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- onosInstallResult = main.TRUE
- for i in range( main.numCtrls ):
- onosInstallResult = onosInstallResult and \
- main.ONOSbench.onosInstall(
- node=main.ONOSip[ i ] )
- stepResult = onosInstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully installed ONOS package",
- onfail="Failed to install ONOS package" )
- if Testcaselib.useSSH:
- for i in range( main.numCtrls ):
- onosInstallResult = onosInstallResult and \
- main.ONOSbench.onosSecureSSH(
- node=main.ONOSip[ i ] )
- stepResult = onosInstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully secure SSH",
- onfail="Failed to secure SSH" )
- main.step( "Starting ONOS service" )
- stopResult, startResult, onosIsUp = main.TRUE, main.TRUE, main.TRUE,
- for i in range( main.numCtrls ):
- onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
- if onosIsUp == main.TRUE:
- main.log.report( "ONOS instance is up and ready" )
- else:
- main.log.report( "ONOS instance may not be up, stop and " +
- "start ONOS again " )
- for i in range( main.numCtrls ):
- stopResult = stopResult and \
- main.ONOSbench.onosStop( main.ONOSip[ i ] )
- for i in range( main.numCtrls ):
- startResult = startResult and \
- main.ONOSbench.onosStart( main.ONOSip[ i ] )
- stepResult = onosIsUp and stopResult and startResult
+ main.testSetUp.buildOnos()
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="ONOS service is ready",
- onfail="ONOS service did not start properly" )
+ main.testSetUp.installOnos( False )
+
+ main.testSetUp.setupSsh()
+
+ main.testSetUp.checkOnosService()
+
main.step( "Checking if ONOS CLI is ready" )
for i in range( main.numCtrls ):
main.CLIs[ i ].startCellCli( )
@@ -172,7 +107,7 @@
main.active = 0
for i in range( 10 ):
ready = True
- output = main.CLIs[ main.active ].summary( )
+ output = main.CLIs[ main.active ].summary()
if not output:
ready = False
if ready:
@@ -437,11 +372,20 @@
Stops Mininet
Copies ONOS log
"""
- main.Mininet1.stopNet( )
- main.ONOSbench.scp( main.ONOScli1, "/opt/onos/log/karaf.log",
- "/tmp/karaf.log", direction="from" )
- main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
- copyFileName="karaf.log." + main.cfgName )
+ try:
+ from tests.dependencies.utils import Utils
+ except ImportError:
+ main.log.error( "Utils not found exiting the test" )
+ main.exit()
+ try:
+ main.Utils
+ except ( NameError, AttributeError ):
+ main.Utils = Utils()
+
+ main.utils.mininetCleanup( main.Mininet1 )
+
+ main.utils.copyKarafLog()
+
for i in range( main.numCtrls ):
main.ONOSbench.onosStop( main.ONOSip[ i ] )
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/startUp.py b/TestON/tests/USECASE/SegmentRouting/dependencies/startUp.py
deleted file mode 100755
index 501cbb3..0000000
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/startUp.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
- This wrapper function is use for starting up onos instance
-"""
-
-import time
-import os
-import json
-
-def onosBuild( main, gitBranch ):
- """
- This includes pulling ONOS and building it using maven install
- """
-
- buildResult = main.FALSE
-
- # Git checkout a branch of ONOS
- checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
- # Does the git pull on the branch that was checked out
- if not checkOutResult:
- main.log.warn( "Failed to checked out " + gitBranch +
- " branch")
- else:
- main.log.info( "Successfully checked out " + gitBranch +
- " branch")
- gitPullResult = main.ONOSbench.gitPull()
- if gitPullResult == main.ERROR:
- main.log.error( "Error pulling git branch" )
- else:
- main.log.info( "Successfully pulled " + gitBranch + " branch" )
-
- # buck build
- buildResult = main.ONOSbench.buckBuild()
-
- return buildResult
-
-
-
-
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.params b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.params
index 104fe3f..8b401d6 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.params
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.params
@@ -14,7 +14,10 @@
<ip1>OC1</ip1>
<port1>6653</port1>
</CTRL>
-
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
<DEPENDENCY>
<path>/USECASE/USECASE_SdnipFunction/dependencies/</path>
<topology>USECASE_SdnipI2MN.py</topology>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index fbbdee8..f8c8185 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -28,13 +28,11 @@
main.exit()
main.step( "Connect switches to controller" )
- global ONOS1Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
# connect all switches to controller
swResult = main.TRUE
for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
sw = "sw%s" % ( i )
- swResult = swResult and main.Mininet.assignSwController( sw, ONOS1Ip )
+ swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip[ 0 ] )
utilities.assert_equals( expect=main.TRUE,
actual=swResult,
onpass="Successfully connect all switches to ONOS",
@@ -44,9 +42,9 @@
main.exit()
main.step( "Set up tunnel from Mininet node to onos node" )
- forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
+ forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.ONOSip[ 0 ] )
command = 'ssh -nNT -o "PasswordAuthentication no" \
- -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, ONOS1Ip )
+ -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, main.ONOSip[ 0 ] )
tunnelResult = main.TRUE
tunnelResult = main.Mininet.node( "root", command )
@@ -70,119 +68,17 @@
"""
import time
import os
-
- main.case( "Setting up ONOS environment" )
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- global ONOS1Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
- ipList = [ ONOS1Ip ]
-
- main.step( "Copying config files" )
- src = os.path.dirname( main.testFile ) + "/network-cfg.json"
- dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
- status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
- utilities.assert_equals( expect=main.TRUE,
- actual=status,
- onpass="Copy config file succeeded",
- onfail="Copy config file failed" )
-
- main.step( "Create cell file" )
- cellAppString = main.params[ 'ENV' ][ 'appString' ]
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- main.Mininet.ip_address,
- cellAppString, ipList, main.ONOScli1.karafUser )
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- utilities.assert_equals( expect=main.TRUE,
- actual=cellResult,
- onpass="Set cell succeeded",
- onfail="Set cell failed" )
-
- main.step( "Verify cell connectivity" )
- verifyResult = main.ONOSbench.verifyCell()
- utilities.assert_equals( expect=main.TRUE,
- actual=verifyResult,
- onpass="Verify cell succeeded",
- onfail="Verify cell failed" )
-
- branchName = main.ONOSbench.getBranchName()
- main.log.report( "ONOS is on branch: " + branchName )
-
- main.step( "Uninstalling ONOS" )
- uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=uninstallResult,
- onpass="Uninstall ONOS succeeded",
- onfail="Uninstall ONOS failed" )
- '''
- main.step( "Git pull" )
- gitPullResult = main.ONOSbench.gitPull()
- main.log.info( "gitPullResult" )
- main.log.info( gitPullResult )
- gitPullResult2 = ( gitPullResult == main.TRUE ) or ( gitPullResult == 3 )
- utilities.assert_equals( expect=True,
- actual=gitPullResult2,
- onpass="Git pull ONOS succeeded",
- onfail="Git pull ONOS failed" )
- '''
-
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- utilities.assert_equals( expect=main.TRUE,
- actual=packageResult,
- onpass="Package ONOS succeeded",
- onfail="Package ONOS failed" )
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=onos1InstallResult,
- onpass="Install ONOS succeeded",
- onfail="Install ONOS failed" )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=secureSshResult,
- onpass="Set up ONOS secure SSH succeeded",
- onfail="Set up ONOS secure SSH failed " )
-
- main.step( "Checking if ONOS is up yet" )
- onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
- utilities.assert_equals( expect=main.TRUE,
- actual=onos1UpResult,
- onpass="ONOS is up",
- onfail="ONOS is NOT up" )
-
- main.step( "Checking if ONOS CLI is ready" )
- cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- utilities.assert_equals( expect=main.TRUE,
- actual=cliResult,
- onpass="ONOS CLI is ready",
- onfail="ONOS CLI is not ready" )
-
- for i in range( 10 ):
- ready = True
- output = main.ONOScli.summary()
- if not output:
- ready = False
- if ready:
- break
- time.sleep( 30 )
- utilities.assert_equals( expect=True, actual=ready,
- onpass="ONOS summary command succeded",
- onfail="ONOS summary command failed" )
-
- if not ready:
- main.log.error( "ONOS startup failed!" )
- main.cleanup()
+ try:
+ from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
+ except ImportError:
+ main.log.error( "sdnBase not found. exiting the test" )
main.exit()
+ try:
+ main.sdnBase
+ except ( NameError, AttributeError ):
+ main.sdnBase = SdnBase()
+
+ main.sdnBase.initSetup()
def CASE200( self, main ):
import json
@@ -193,20 +89,20 @@
time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
main.log.info( "Get links in the network" )
- summaryResult = main.ONOScli.summary()
+ summaryResult = main.ONOScli1.summary()
linkNum = json.loads( summaryResult )[ "links" ]
- listResult = main.ONOScli.links( jsonFormat=False )
+ listResult = main.ONOScli1.links( jsonFormat=False )
main.log.info( listResult )
if linkNum < 100:
main.log.error( "Link number is wrong!" )
time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
- listResult = main.ONOScli.links( jsonFormat=False )
+ listResult = main.ONOScli1.links( jsonFormat=False )
main.log.info( listResult )
main.cleanup()
main.exit()
main.step( "Activate sdn-ip application" )
- activeSDNIPresult = main.ONOScli.activateApp( "org.onosproject.sdnip" )
+ activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
utilities.assert_equals( expect=main.TRUE,
actual=activeSDNIPresult,
onpass="Activate SDN-IP succeeded",
@@ -263,104 +159,25 @@
'''
point-to-point intents test for each BGP peer and BGP speaker pair
'''
- import time
- from operator import eq
-
- main.case( "Check point-to-point intents" )
- main.log.info( "There are %s BGP peers in total "
- % main.params[ 'config' ][ 'peerNum' ] )
- main.step( "Check P2P intents number from ONOS CLI" )
-
- getIntentsResult = main.ONOScli.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
- if bgpIntentsActualNum != bgpIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- main.log.info( "bgpIntentsExpected num is:" )
- main.log.info( bgpIntentsExpectedNum )
- main.log.info( "bgpIntentsActual num is:" )
- main.log.info( bgpIntentsActualNum )
- utilities.assertEquals( \
- expect=True,
- actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
- onpass="PointToPointIntent Intent Num is correct!",
- onfail="PointToPointIntent Intent Num is wrong!" )
+ main.sdnBase.pToPIntentTest( 6 )
def CASE3( self, main ):
'''
routes and intents check to all BGP peers
'''
- import time
main.case( "Check routes and M2S intents to all BGP peers" )
allRoutesExpected = []
allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" )
allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
-
allRoutesExpected.append( "7.0.0.0/24" + "/" + "10.0.7.1" )
allRoutesExpected.append( "8.0.0.0/24" + "/" + "10.0.8.1" )
allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
- getRoutesResult = main.ONOScli.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrExpected = str( sorted( allRoutesExpected ) )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
- if allRoutesStrActual != allRoutesStrExpected:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getRoutesResult = main.ONOScli.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
-
- main.step( "Check routes installed" )
- main.log.info( "Routes expected:" )
- main.log.info( allRoutesStrExpected )
- main.log.info( "Routes get from ONOS CLI:" )
- main.log.info( allRoutesStrActual )
- utilities.assertEquals( \
- expect=allRoutesStrExpected, actual=allRoutesStrActual,
- onpass="Routes are correct!",
- onfail="Routes are wrong!" )
-
- main.step( "Check M2S intents installed" )
- getIntentsResult = main.ONOScli.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
- routeIntentsExpectedNum = 7
- if routeIntentsActualNum != routeIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
-
- main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
- main.log.info( routeIntentsExpectedNum )
- main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
- main.log.info( routeIntentsActualNum )
- utilities.assertEquals( \
- expect=routeIntentsExpectedNum,
- actual=routeIntentsActualNum,
- onpass="MultiPointToSinglePoint Intent Num is correct!",
- onfail="MultiPointToSinglePoint Intent Num is wrong!" )
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
+ main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
def CASE4( self, main ):
@@ -386,151 +203,20 @@
'''
Cut links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring down links and check routes/intents" )
- main.step( "Bring down the link between sw32 and p64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
-
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 6 ) #We have 7 links between peers and sw. After one link down, 7-1=6.
- main.Functions.checkM2SintentNum( main, 6 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw8 and p64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 5 ) #2 links down, 7-2=5.
- main.Functions.checkM2SintentNum( main, 5 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw28 and p64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 4 ) #3 links downs 7-3=4
- main.Functions.checkM2SintentNum( main, 4 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
- peers=["p64514", "p64515", "p64516"],
- expectAllSuccess=False )
-
- main.Functions.pingHostToHost( main,
- hosts=["h64514", "h64515", "h64516"],
- expectAllSuccess=False )
+ main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
+ 6, 6, 5, 5, 4, 4,
+ "spk1", [ "h64514", "h64515", "h64516" ],
+ "down" )
def CASE6( self, main ):
'''
Recover links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring up links and check routes/intents" )
- main.step( "Bring up the link between sw32 and p64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 5 ) #one links up, 4+1=5
- main.Functions.checkM2SintentNum( main, 5 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw8 and p64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 6 )
- main.Functions.checkM2SintentNum( main, 6 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw28 and p64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 7 )
- main.Functions.checkM2SintentNum( main, 7 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
- peers=["p64514", "p64515", "p64516"],
- expectAllSuccess=True )
- main.Functions.pingHostToHost( main,
- hosts=["h64514", "h64515", "h64516"],
- expectAllSuccess=True )
-
+ main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
+ 5, 5, 6, 6, 7, 7,
+ "spk1", [ "h64514", "h64515", "h64516" ],
+ "up" )
def CASE7( self, main ):
'''
@@ -585,7 +271,7 @@
main.exit()
main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
main.FALSE,
kwargs={'isPENDING':False},
attempts=10 )
@@ -611,7 +297,7 @@
onpass="Starting switch succeeded!",
onfail="Starting switch failed!" )
- result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
+ result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
utilities.assertEquals( \
expect=main.TRUE,
actual=result2,
@@ -629,7 +315,7 @@
main.exit()
main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
main.FALSE,
kwargs={'isPENDING':False},
attempts=10 )
@@ -681,7 +367,7 @@
main.exit()
main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
main.FALSE,
kwargs={'isPENDING':False},
attempts=10 )
@@ -718,7 +404,7 @@
utilities.assertEquals( expect=main.TRUE, actual=result1,
onpass="Starting switch succeeded!",
onfail="Starting switch failed!" )
- result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
+ result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
utilities.assertEquals( expect=main.TRUE, actual=result2,
onpass="Connect switch to ONOS succeeded!",
onfail="Connect switch to ONOS failed!" )
@@ -737,7 +423,7 @@
main.exit()
main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli.checkFlowsState,
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
main.FALSE,
kwargs={'isPENDING':False},
attempts=10 )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
index b0f884b..9f2ed34 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
@@ -12,7 +12,7 @@
</COMPONENTS>
</ONOSbench>
- <ONOScli>
+ <ONOScli1>
<host>127.0.0.1</host>
<user>sdn</user>
<password>rocks</password>
@@ -23,7 +23,7 @@
<karaf_password></karaf_password>
<prompt></prompt>
</COMPONENTS>
- </ONOScli>
+ </ONOScli1>
<ONOS1>
<host>OC1</host>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
index 10c3675..a86bb39 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
@@ -7,10 +7,10 @@
main.log.info( routeNumExpected )
main.log.info( "Route number from ONOS CLI:" )
- routeNumActual = main.ONOScli.ipv4RouteNumber()
+ routeNumActual = main.ONOScli1.ipv4RouteNumber()
if routeNumActual != routeNumExpected:
time.sleep( wait )
- routeNumActual = main.ONOScli.ipv4RouteNumber()
+ routeNumActual = main.ONOScli1.ipv4RouteNumber()
main.log.info( routeNumActual )
utilities.assertEquals( \
expect = routeNumExpected, actual = routeNumActual,
@@ -21,7 +21,7 @@
import time
main.step( "Check M2S intents installed" )
wait = int( main.params['timers']['PathAvailable'] )
- jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
TYPE = "multiPointToSinglePoint" )
try:
intentNumActual = jsonResult['installed']
@@ -30,7 +30,7 @@
main.log.error( e )
if intentNumActual != intentNumExpected:
time.sleep( wait )
- jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
TYPE = "multiPointToSinglePoint" )
try:
intentNumActual = jsonResult['installed']
@@ -48,7 +48,7 @@
import time
main.step( "Check P2P intents installed" )
wait = int( main.params['timers']['PathAvailable'] )
- jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
TYPE = "pointToPoint" )
try:
intentNumActual = jsonResult['installed']
@@ -58,7 +58,7 @@
if intentNumActual != intentNumExpected:
time.sleep( wait )
- jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
TYPE = "pointToPoint" )
try:
intentNumActual = jsonResult['installed']
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.params b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.params
index 0d6014f..e25086a 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.params
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.params
@@ -14,7 +14,10 @@
<ip3>OC3</ip3>
<port1>6653</port1>
</CTRL>
-
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
<DEPENDENCY>
<path>/USECASE/USECASE_SdnipFunctionCluster/dependencies/</path>
<topology>USECASE_SdnipI2MN_Cluster.py</topology>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
index c96fa40..a1fb405 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
@@ -32,8 +32,7 @@
swResult = main.TRUE
for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
sw = "sw%s" % ( i )
- swResult = swResult and main.Mininet.assignSwController( sw,
- [ONOS1Ip, ONOS2Ip, ONOS3Ip] )
+ swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip )
utilities.assert_equals( expect=main.TRUE,
actual=swResult,
onpass="Successfully connect all switches to ONOS",
@@ -57,143 +56,24 @@
import time
import os
from operator import eq
-
- main.case( "Setting up ONOS environment" )
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- global ONOS1Ip
- global ONOS2Ip
- global ONOS3Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
- ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
- ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
- ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
-
global p64514
global p64515
global p64516
- p64514 = main.params['config']['p64514']
- p64515 = main.params['config']['p64515']
- p64516 = main.params['config']['p64516']
+ p64514 = main.params[ 'config' ][ 'p64514' ]
+ p64515 = main.params[ 'config' ][ 'p64515' ]
+ p64516 = main.params[ 'config' ][ 'p64516' ]
- main.step( "Copying config files" )
- src = os.path.dirname( main.testFile ) + "/network-cfg.json"
- dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
- status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
- utilities.assert_equals( expect=main.TRUE,
- actual=status,
- onpass="Copy config file succeeded",
- onfail="Copy config file failed" )
-
- main.step( "Create cell file" )
- cellAppString = main.params[ 'ENV' ][ 'appString' ]
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- main.Mininet.ip_address,
- cellAppString, ipList, main.ONOScli1.karafUser )
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- utilities.assert_equals( expect=main.TRUE,
- actual=cellResult,
- onpass="Set cell succeeded",
- onfail="Set cell failed" )
-
- main.step( "Verify cell connectivity" )
- verifyResult = main.ONOSbench.verifyCell()
- utilities.assert_equals( expect=main.TRUE,
- actual=verifyResult,
- onpass="Verify cell succeeded",
- onfail="Verify cell failed" )
-
- branchName = main.ONOSbench.getBranchName()
- main.log.report( "ONOS is on branch: " + branchName )
-
- main.step( "Uninstalling ONOS" )
- uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
- and main.ONOSbench.onosUninstall( ONOS2Ip ) \
- and main.ONOSbench.onosUninstall( ONOS3Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=uninstallResult,
- onpass="Uninstall ONOS from nodes succeeded",
- onfail="Uninstall ONOS form nodes failed" )
-
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- utilities.assert_equals( expect=main.TRUE,
- actual=packageResult,
- onpass="Package ONOS succeeded",
- onfail="Package ONOS failed" )
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS2Ip )
- onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS3Ip )
- onosInstallResult = onos1InstallResult and onos2InstallResult \
- and onos3InstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=onosInstallResult,
- onpass="Install ONOS to nodes succeeded",
- onfail="Install ONOS to nodes failed" )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=secureSshResult,
- onpass="Set up ONOS secure SSH succeeded",
- onfail="Set up ONOS secure SSH failed " )
-
- main.step( "Checking if ONOS is up yet" )
- onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
- onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
- onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
- onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
- utilities.assert_equals( expect=main.TRUE,
- actual=onosUpResult,
- onpass="ONOS nodes are up",
- onfail="ONOS nodes are NOT up" )
-
- main.step( "Checking if ONOS CLI is ready" )
- main.CLIs = []
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli1 )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli2 )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli3 )
- cliResult = cliResult1 and cliResult2 and cliResult3
- utilities.assert_equals( expect=main.TRUE,
- actual=cliResult,
- onpass="ONOS CLIs are ready",
- onfail="ONOS CLIs are not ready" )
-
- main.step( "Checking if ONOS CLI is ready for issuing commands" )
- for i in range( 10 ):
- ready = True
- for cli in main.CLIs:
- output = cli.summary()
- if not output:
- ready = False
- if ready:
- break
- time.sleep( 30 )
- utilities.assert_equals( expect=True, actual=ready,
- onpass="ONOS summary command succeded",
- onfail="ONOS summary command failed" )
-
- if not ready:
- main.log.error( "ONOS startup failed!" )
- main.cleanup()
+ try:
+ from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
+ except ImportError:
+ main.log.error( "sdnBase not found. exiting the test" )
main.exit()
+ try:
+ main.sdnBase
+ except ( NameError, AttributeError ):
+ main.sdnBase = SdnBase()
+
+ main.sdnBase.initSetup()
def CASE200( self, main ):
main.case( "Activate sdn-ip application" )
@@ -229,7 +109,6 @@
main.cleanup()
main.exit()
-
def CASE102( self, main ):
'''
This test case is to load the methods from other Python files, and create
@@ -244,9 +123,8 @@
wrapperFile1 +
".py" )
# Create tunnels
- main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
- main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
- main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
+ for i in range ( len( main.ONOSip ) ):
+ main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
main.log.info( "Wait SDN-IP to finish installing connectivity intents \
and the BGP paths in data plane are ready..." )
@@ -282,29 +160,7 @@
'''
point-to-point intents test for each BGP peer and BGP speaker pair
'''
- import time
- main.case( "Check point-to-point intents" )
- main.log.info( "There are %s BGP peers in total "
- % main.params[ 'config' ][ 'peerNum' ] )
- main.step( "Check P2P intents number from ONOS CLI" )
-
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
- if bgpIntentsActualNum != bgpIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- main.log.info( "bgpIntentsExpected num is:" )
- main.log.info( bgpIntentsExpectedNum )
- main.log.info( "bgpIntentsActual num is:" )
- main.log.info( bgpIntentsActualNum )
- utilities.assert_equals( expect=bgpIntentsExpectedNum,
- actual=bgpIntentsActualNum,
- onpass="PointToPointIntent Intent Num is correct!",
- onfail="PointToPointIntent Intent Num is wrong!" )
+ main.sdnBase.pToPIntentTest( 12 )
def CASE3( self, main ):
'''
@@ -323,56 +179,7 @@
allRoutesExpected.append( "9.0.0.0/24" + "/" + "10.0.9.1" )
allRoutesExpected.append( "20.0.0.0/24" + "/" + "10.0.20.1" )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrExpected = str( sorted( allRoutesExpected ) )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
- if allRoutesStrActual != allRoutesStrExpected:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
-
- main.log.info( "Routes expected:" )
- main.log.info( allRoutesStrExpected )
- main.log.info( "Routes get from ONOS CLI:" )
- main.log.info( allRoutesStrActual )
- utilities.assert_equals( expect=allRoutesStrExpected,
- actual=allRoutesStrActual,
- onpass="Routes are correct!",
- onfail="Routes are wrong!" )
-
- main.step( "Check M2S intents installed" )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
- routeIntentsExpectedNum = 7
- if routeIntentsActualNum != routeIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
-
- main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
- main.log.info( routeIntentsExpectedNum )
- main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
- main.log.info( routeIntentsActualNum )
- utilities.assert_equals( expect=routeIntentsExpectedNum,
- actual=routeIntentsActualNum,
- onpass="MultiPointToSinglePoint Intent Num is correct!",
- onfail="MultiPointToSinglePoint Intent Num is wrong!" )
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assert_equals( expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
+ main.sdnBase.routeAndIntentCheck( allRoutesExpected, 7 )
def CASE4( self, main ):
@@ -386,154 +193,27 @@
main.Functions.pingHostToHost(main,
hosts=["h64517", "h64518"],
expectAllSuccess=True)
- main.Functions.pingHostToHost(main,
- hosts=["h64519", "h64520"],
- expectAllSuccess=True)
+ main.Functions.pingHostToHost( main,
+ hosts=[ "h64519", "h64520" ],
+ expectAllSuccess=True )
def CASE5( self, main ):
'''
Cut links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring down links and check routes/intents" )
- main.step( "Bring down the link between sw32 and p64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
- OPTION="down" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
-
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 6 )
- main.Functions.checkM2SintentNum( main, 6 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw8 and p64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
- OPTION="down" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 5 )
- main.Functions.checkM2SintentNum( main, 5 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw28 and p64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
- OPTION="down" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 4 )
- main.Functions.checkM2SintentNum( main, 4 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assert_equals( expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
- peers=["p64514", "p64515", "p64516"],
- expectAllSuccess=False )
- main.Functions.pingHostToHost( main,
- hosts=["h64514", "h64515", "h64516"],
- expectAllSuccess=False )
+ main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
+ 6, 6, 5, 5, 4, 4,
+ "spk1", [ "h64514", "h64515", "h64516" ],
+ "down" )
def CASE6( self, main ):
'''
Recover links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring up links and check routes/intents" )
- main.step( "Bring up the link between sw32 and p64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="p64514",
- OPTION="up" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 5 )
- main.Functions.checkM2SintentNum( main, 5 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw8 and p64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="p64515",
- OPTION="up" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 6 )
- main.Functions.checkM2SintentNum( main, 6 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw28 and p64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="p64516",
- OPTION="up" )
- utilities.assert_equals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 7 )
- main.Functions.checkM2SintentNum( main, 7 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assert_equals( expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["spk1"],
- peers=["p64514", "p64515", "p64516"],
- expectAllSuccess=True )
- main.Functions.pingHostToHost( main,
- hosts=["h64514", "h64515", "h64516"],
- expectAllSuccess=True )
+ main.sdnBase.linkUpDownCheck( "p64514", "p64515", "p64516",
+ 5, 5, 6, 6, 7, 7,
+ "spk1", [ "h64514", "h64515", "h64516" ],
+ "up" )
def CASE7( self, main ):
'''
@@ -627,7 +307,7 @@
onpass="Starting switch succeeded!",
onfail="Starting switch failed!" )
- result2 = main.Mininet.assignSwController( "sw32", ONOS1Ip )
+ result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
utilities.assert_equals( expect=main.TRUE,
actual=result2,
onpass="Connect switch to ONOS succeeded!",
@@ -738,7 +418,7 @@
utilities.assert_equals( expect=main.TRUE, actual=result1,
onpass="Starting switch succeeded!",
onfail="Starting switch failed!" )
- result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
+ result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
utilities.assert_equals( expect=main.TRUE, actual=result2,
onpass="Connect switch to ONOS succeeded!",
onfail="Connect switch to ONOS failed!" )
@@ -874,12 +554,9 @@
main.log.info( leaderIP )
main.step( "Uninstall ONOS/SDN-IP leader node" )
- if leaderIP == ONOS1Ip:
- uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
- elif leaderIP == ONOS2Ip:
- uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
- else:
- uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
+ for ip in main.ONOSip:
+ if leaderIP == ip:
+ uninstallResult = main.ONOSbench.onosStop( ip )
utilities.assert_equals( expect=main.TRUE,
actual=uninstallResult,
@@ -890,7 +567,7 @@
main.exit()
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- if leaderIP == ONOS1Ip:
+ if leaderIP == main.ONOSip[ 0 ]:
main.Functions.checkRouteNum( main, 7, ONOScli="ONOScli2" )
main.Functions.checkM2SintentNum( main, 7, ONOScli="ONOScli2" )
main.Functions.checkP2PintentNum( main, 30 * 2, ONOScli="ONOScli2" )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.params b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.params
index 54c42be..4cea2c8 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.params
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.params
@@ -19,7 +19,10 @@
<fsfwPort>6633</fsfwPort>
<port1>6653</port1>
</CTRL>
-
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
<DEPENDENCY>
<path>/USECASE/USECASE_SdnipFunctionCluster_fsfw/dependencies/</path>
<topology>USECASE_SdnipI2MN_Cluster.py</topology>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
index 5197ba6..1508a7e 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster_fsfw/USECASE_SdnipFunctionCluster_fsfw.py
@@ -57,18 +57,6 @@
import time
import os
from operator import eq
-
- main.case( "Setting up ONOS environment" )
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- global ONOS1Ip
- global ONOS2Ip
- global ONOS3Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
- ONOS2Ip = os.getenv( main.params[ 'CTRL' ][ 'ip2' ] )
- ONOS3Ip = os.getenv( main.params[ 'CTRL' ][ 'ip3' ] )
- ipList = [ ONOS1Ip, ONOS2Ip, ONOS3Ip ]
-
global pr64514
global pr64515
global pr64516
@@ -81,123 +69,18 @@
fsfwIp = main.params[ 'CTRL' ][ 'fsfwIp' ]
fsfwPort = main.params[ 'CTRL' ][ 'fsfwPort' ]
- main.step( "Copying config files" )
- src = os.path.dirname( main.testFile ) + "/network-cfg.json"
- dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
- status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
- utilities.assert_equals( expect=main.TRUE,
- actual=status,
- onpass="Copy config file succeeded",
- onfail="Copy config file failed" )
-
- main.step( "Create cell file" )
- cellAppString = main.params[ 'ENV' ][ 'appString' ]
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- main.Mininet.ip_address,
- cellAppString, ipList, main.ONOScli1.karafUser )
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- utilities.assert_equals( expect=main.TRUE,
- actual=cellResult,
- onpass="Set cell succeeded",
- onfail="Set cell failed" )
-
- main.step( "Verify cell connectivity" )
- verifyResult = main.ONOSbench.verifyCell()
- utilities.assert_equals( expect=main.TRUE,
- actual=verifyResult,
- onpass="Verify cell succeeded",
- onfail="Verify cell failed" )
-
- branchName = main.ONOSbench.getBranchName()
- main.log.report( "ONOS is on branch: " + branchName )
-
- main.step( "Uninstalling ONOS" )
- uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip ) \
- and main.ONOSbench.onosUninstall( ONOS2Ip ) \
- and main.ONOSbench.onosUninstall( ONOS3Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=uninstallResult,
- onpass="Uninstall ONOS from nodes succeeded",
- onfail="Uninstall ONOS form nodes failed" )
-
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- utilities.assert_equals( expect=main.TRUE,
- actual=packageResult,
- onpass="Package ONOS succeeded",
- onfail="Package ONOS failed" )
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- onos2InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS2Ip )
- onos3InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS3Ip )
- onosInstallResult = onos1InstallResult and onos2InstallResult \
- and onos3InstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=onosInstallResult,
- onpass="Install ONOS to nodes succeeded",
- onfail="Install ONOS to nodes failed" )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS2Ip )
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=ONOS3Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=secureSshResult,
- onpass="Set up ONOS secure SSH succeeded",
- onfail="Set up ONOS secure SSH failed " )
-
- main.step( "Checking if ONOS is up yet" )
- onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
- onos2UpResult = main.ONOSbench.isup( ONOS2Ip, timeout=420 )
- onos3UpResult = main.ONOSbench.isup( ONOS3Ip, timeout=420 )
- onosUpResult = onos1UpResult and onos2UpResult and onos3UpResult
- utilities.assert_equals( expect=main.TRUE,
- actual=onosUpResult,
- onpass="ONOS nodes are up",
- onfail="ONOS nodes are NOT up" )
-
- main.step( "Checking if ONOS CLI is ready" )
- main.CLIs = []
- cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli1 )
- cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli2 )
- cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip,
- commandlineTimeout=100, onosStartTimeout=600 )
- main.CLIs.append( main.ONOScli3 )
- cliResult = cliResult1 and cliResult2 and cliResult3
- utilities.assert_equals( expect=main.TRUE,
- actual=cliResult,
- onpass="ONOS CLIs are ready",
- onfail="ONOS CLIs are not ready" )
-
- for i in range( 10 ):
- ready = True
- for cli in main.CLIs:
- output = cli.summary()
- if not output:
- ready = False
- if ready:
- break
- time.sleep( 30 )
- utilities.assert_equals( expect=True, actual=ready,
- onpass="ONOS summary command succeded",
- onfail="ONOS summary command failed" )
-
- if not ready:
- main.log.error( "ONOS startup failed!" )
- main.cleanup()
+ try:
+ from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
+ except ImportError:
+ main.log.error( "sdnBase not found. exiting the test" )
main.exit()
+ try:
+ main.sdnBase
+ except ( NameError, AttributeError ):
+ main.sdnBase = SdnBase()
+
+ main.sdnBase.initSetup()
+
def CASE200( self, main ):
main.case( "Activate sdn-ip application" )
@@ -243,9 +126,8 @@
wrapperFile1 +
".py" )
# Create tunnels
- main.Functions.setupTunnel( main, '1.1.1.2', 2000, ONOS1Ip, 2000 )
- main.Functions.setupTunnel( main, '1.1.1.4', 2000, ONOS2Ip, 2000 )
- main.Functions.setupTunnel( main, '1.1.1.6', 2000, ONOS3Ip, 2000 )
+ for i in range ( len( main.ONOSip ) ):
+ main.Functions.setupTunnel( main, '1.1.1.' + str( ( i + 1 ) * 2 ), 2000, main.ONOSip[ i ], 2000 )
main.log.info( "Wait SDN-IP to finish installing connectivity intents \
and the BGP paths in data plane are ready..." )
@@ -272,30 +154,7 @@
'''
point-to-point intents test for each BGP peer and BGP speaker pair
'''
- import time
- main.case( "Check point-to-point intents" )
- main.log.info( "There are %s BGP peers in total "
- % main.params[ 'config' ][ 'peerNum' ] )
- main.step( "Check P2P intents number from ONOS CLI" )
-
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 * 2
- if bgpIntentsActualNum != bgpIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- main.log.info( "bgpIntentsExpected num is:" )
- main.log.info( bgpIntentsExpectedNum )
- main.log.info( "bgpIntentsActual num is:" )
- main.log.info( bgpIntentsActualNum )
- utilities.assertEquals( \
- expect=True,
- actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
- onpass="PointToPointIntent Intent Num is correct!",
- onfail="PointToPointIntent Intent Num is wrong!" )
+ main.sdnBase.pToPIntentTest( 12 )
def CASE3( self, main ):
@@ -310,59 +169,7 @@
allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrExpected = str( sorted( allRoutesExpected ) )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
- if allRoutesStrActual != allRoutesStrExpected:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
-
- main.step( "Check routes installed" )
- main.log.info( "Routes expected:" )
- main.log.info( allRoutesStrExpected )
- main.log.info( "Routes get from ONOS CLI:" )
- main.log.info( allRoutesStrActual )
- utilities.assertEquals( \
- expect=allRoutesStrExpected, actual=allRoutesStrActual,
- onpass="Routes are correct!",
- onfail="Routes are wrong!" )
-
- main.step( "Check M2S intents installed" )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
- routeIntentsExpectedNum = 3
- if routeIntentsActualNum != routeIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
-
- main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
- main.log.info( routeIntentsExpectedNum )
- main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
- main.log.info( routeIntentsActualNum )
- utilities.assertEquals( \
- expect=routeIntentsExpectedNum,
- actual=routeIntentsActualNum,
- onpass="MultiPointToSinglePoint Intent Num is correct!",
- onfail="MultiPointToSinglePoint Intent Num is wrong!" )
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
+ main.sdnBase.routeAndIntentCheck( allRoutesExpected, 3 )
def CASE4( self, main ):
@@ -374,159 +181,23 @@
hosts=["host64514", "host64515", "host64516"],
expectAllSuccess=True )
-
def CASE5( self, main ):
'''
Cut links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring down links and check routes/intents" )
- main.step( "Bring down the link between sw32 and peer64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
- OPTION="down" )
- # When bring down a link, Mininet will bring down both the interfaces
- # at the two sides of the link. Here we do not want to bring down the
- # host side interface, since I noticed when bring up in CASE6, some of
- # the configuration information will lost.
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
-
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 2 )
- main.Functions.checkM2SintentNum( main, 2 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw8 and peer64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 1 )
- main.Functions.checkM2SintentNum( main, 1 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw28 and peer64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 0 )
- main.Functions.checkM2SintentNum( main, 0 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
- peers=["pr64514", "pr64515", "pr64516"],
- expectAllSuccess=False )
- main.Functions.pingHostToHost( main,
- hosts=["host64514", "host64515", "host64516"],
- expectAllSuccess=False )
-
+ main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
+ 2, 2, 1, 1, 0, 0,
+ "speaker1", [ "host64514", "host64515", "host64516" ],
+ "down" )
def CASE6( self, main ):
'''
Recover links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring up links and check routes/intents" )
- main.step( "Bring up the link between sw32 and peer64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 1 )
- main.Functions.checkM2SintentNum( main, 1 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw8 and peer64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 2 )
- main.Functions.checkM2SintentNum( main, 2 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw28 and peer64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 3 )
- main.Functions.checkM2SintentNum( main, 3 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
- peers=["pr64514", "pr64515", "pr64516"],
- expectAllSuccess=True )
- main.Functions.pingHostToHost( main,
- hosts=["host64514", "host64515", "host64516"],
- expectAllSuccess=True )
-
+ main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
+ 1, 1, 2, 2, 3, 3,
+ "speaker1", [ "host64514", "host64515", "host64516" ],
+ "up" )
def CASE7( self, main ):
'''
@@ -876,13 +547,10 @@
main.log.info( "leaderIP is: " )
main.log.info( leaderIP )
- main.step( "Uninstall ONOS/SDN-IP leader node" )
- if leaderIP == ONOS1Ip:
- uninstallResult = main.ONOSbench.onosStop( ONOS1Ip )
- elif leaderIP == ONOS2Ip:
- uninstallResult = main.ONOSbench.onosStop( ONOS2Ip )
- else:
- uninstallResult = main.ONOSbench.onosStop( ONOS3Ip )
+ main.step( "Uninstall ONOS/SDN-IP leader node" )
+ for ip in main.ONOSip:
+ if leaderIP == ip:
+ uninstallResult = main.ONOSbench.onosStop( ip )
utilities.assert_equals( expect=main.TRUE,
actual=uninstallResult,
@@ -893,7 +561,7 @@
main.exit()
time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- if leaderIP == ONOS1Ip:
+ if leaderIP == main.ONOSip[ 0 ]:
main.Functions.checkRouteNum( main, 3, ONOScli="ONOScli2" )
main.Functions.checkM2SintentNum( main, 3, ONOScli="ONOScli2" )
main.Functions.checkP2PintentNum( main, 18 * 2, ONOScli="ONOScli2" )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.params b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.params
index b1c2f8f..7fc2d27 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.params
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.params
@@ -17,7 +17,10 @@
<fsfwPort>6633</fsfwPort>
<port1>6653</port1>
</CTRL>
-
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
<DEPENDENCY>
<path>/USECASE/USECASE_SdnipFunction_fsfw/dependencies/</path>
<topology>USECASE_SdnipI2MN.py</topology>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
index da38107..505a602 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/USECASE_SdnipFunction_fsfw.py
@@ -29,8 +29,6 @@
main.exit()
main.step( "Connect switches to FSFW" )
- global ONOS1Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
global fsfwIp
# TDOO: there is some setup sequence issue, will fix it later
# fsfwIp = os.getenv( main.params[ 'CTRL' ][ 'ipN' ] )
@@ -53,10 +51,10 @@
main.exit()
main.step( "Set up tunnel from Mininet node to onos node" )
- forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', ONOS1Ip )
+ forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.ONOSip[ 0 ] )
command = 'ssh -nNT -o "PasswordAuthentication no"'
command += ' -o "StrictHostKeyChecking no" -l sdn'
- command += ' -L %s %s & ' % ( forwarding1, ONOS1Ip )
+ command += ' -L %s %s & ' % ( forwarding1, main.ONOSip[ 0 ] )
tunnelResult = main.TRUE
tunnelResult = main.Mininet.node( "root", command )
@@ -83,108 +81,17 @@
import os
from operator import eq
- main.case( "Setting up ONOS environment" )
-
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- global ONOS1Ip
- ONOS1Ip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
- ipList = [ ONOS1Ip ]
-
- main.step( "Copying config files" )
- src = os.path.dirname( main.testFile ) + "/network-cfg.json"
- dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
- status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
- utilities.assert_equals( expect=main.TRUE,
- actual=status,
- onpass="Copy config file succeeded",
- onfail="Copy config file failed" )
-
- main.step( "Create cell file" )
- cellAppString = main.params[ 'ENV' ][ 'appString' ]
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- main.Mininet.ip_address,
- cellAppString, ipList, main.ONOScli1.karafUser )
-
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- utilities.assert_equals( expect=main.TRUE,
- actual=cellResult,
- onpass="Set cell succeeded",
- onfail="Set cell failed" )
-
- main.step( "Verify cell connectivity" )
- verifyResult = main.ONOSbench.verifyCell()
- utilities.assert_equals( expect=main.TRUE,
- actual=verifyResult,
- onpass="Verify cell succeeded",
- onfail="Verify cell failed" )
-
- branchName = main.ONOSbench.getBranchName()
- main.log.report( "ONOS is on branch: " + branchName )
-
- main.step( "Uninstalling ONOS" )
- uninstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=uninstallResult,
- onpass="Uninstall ONOS succeeded",
- onfail="Uninstall ONOS failed" )
-
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- utilities.assert_equals( expect=main.TRUE,
- actual=packageResult,
- onpass="Package ONOS succeeded",
- onfail="Package ONOS failed" )
-
- main.step( "Installing ONOS package" )
- onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
- node=ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=onos1InstallResult,
- onpass="Install ONOS succeeded",
- onfail="Install ONOS failed" )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
- utilities.assert_equals( expect=main.TRUE,
- actual=secureSshResult,
- onpass="Set up ONOS secure SSH succeeded",
- onfail="Set up ONOS secure SSH failed " )
-
- main.step( "Checking if ONOS is up yet" )
- onos1UpResult = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
- utilities.assert_equals( expect=main.TRUE,
- actual=onos1UpResult,
- onpass="ONOS is up",
- onfail="ONOS is NOT up" )
-
- main.step( "Checking if ONOS CLI is ready" )
- cliResult = main.ONOScli1.startOnosCli( ONOS1Ip,
- commandlineTimeout=100,
- onosStartTimeout=600 )
- utilities.assert_equals( expect=main.TRUE,
- actual=cliResult,
- onpass="ONOS CLI is ready",
- onfail="ONOS CLI is not ready" )
-
- for i in range( 10 ):
- ready = True
- output = main.ONOScli1.summary()
- if not output:
- ready = False
- if ready:
- break
- time.sleep( 30 )
- utilities.assert_equals( expect=True, actual=ready,
- onpass="ONOS summary command succeded",
- onfail="ONOS summary command failed" )
-
- if not ready:
- main.log.error( "ONOS startup failed!" )
- main.cleanup()
+ try:
+ from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
+ except ImportError:
+ main.log.error( "sdnBase not found. exiting the test" )
main.exit()
+ try:
+ main.sdnBase
+ except ( NameError, AttributeError ):
+ main.sdnBase = SdnBase()
+
+ main.sdnBase.initSetup()
main.log.info( "Get links in the network" )
time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
@@ -249,30 +156,7 @@
'''
point-to-point intents test for each BGP peer and BGP speaker pair
'''
- import time
- main.case( "Check point-to-point intents" )
- main.log.info( "There are %s BGP peers in total "
- % main.params[ 'config' ][ 'peerNum' ] )
- main.step( "Check P2P intents number from ONOS CLI" )
-
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6
- if bgpIntentsActualNum != bgpIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- bgpIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
- main.log.info( "bgpIntentsExpected num is:" )
- main.log.info( bgpIntentsExpectedNum )
- main.log.info( "bgpIntentsActual num is:" )
- main.log.info( bgpIntentsActualNum )
- utilities.assertEquals( \
- expect=True,
- actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
- onpass="PointToPointIntent Intent Num is correct!",
- onfail="PointToPointIntent Intent Num is wrong!" )
+ main.sdnBase.pToPIntentTest( 6 )
def CASE3( self, main ):
@@ -287,60 +171,7 @@
allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" )
allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrExpected = str( sorted( allRoutesExpected ) )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
- if allRoutesStrActual != allRoutesStrExpected:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
- allRoutesActual = \
- main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
- allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
-
- main.step( "Check routes installed" )
- main.log.info( "Routes expected:" )
- main.log.info( allRoutesStrExpected )
- main.log.info( "Routes get from ONOS CLI:" )
- main.log.info( allRoutesStrActual )
- utilities.assertEquals( \
- expect=allRoutesStrExpected, actual=allRoutesStrActual,
- onpass="Routes are correct!",
- onfail="Routes are wrong!" )
-
- main.step( "Check M2S intents installed" )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
- routeIntentsExpectedNum = 3
- if routeIntentsActualNum != routeIntentsExpectedNum:
- time.sleep( int( main.params['timers']['RouteDelivery'] ) )
- getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
- routeIntentsActualNum = \
- main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
-
- main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
- main.log.info( routeIntentsExpectedNum )
- main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
- main.log.info( routeIntentsActualNum )
- utilities.assertEquals( \
- expect=routeIntentsExpectedNum,
- actual=routeIntentsActualNum,
- onpass="MultiPointToSinglePoint Intent Num is correct!",
- onfail="MultiPointToSinglePoint Intent Num is wrong!" )
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
+ main.sdnBase.routeAndIntentCheck( allRoutesExpected, 3 )
def CASE4( self, main ):
'''
@@ -356,150 +187,19 @@
'''
Cut links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring down links and check routes/intents" )
- main.step( "Bring down the link between sw32 and peer64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
-
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 2 )
- main.Functions.checkM2SintentNum( main, 2 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw8 and peer64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 1 )
- main.Functions.checkM2SintentNum( main, 1 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring down the link between sw28 and peer64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
- OPTION="down" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring down link succeeded!",
- onfail="Bring down link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 0 )
- main.Functions.checkM2SintentNum( main, 0 )
- else:
- main.log.error( "Bring down link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
- peers=["pr64514", "pr64515", "pr64516"],
- expectAllSuccess=False )
- main.Functions.pingHostToHost( main,
- hosts=["host64514", "host64515", "host64516"],
- expectAllSuccess=False )
-
+ main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
+ 2, 2, 1, 1, 0, 0,
+ "speaker1", [ "host64514", "host64515", "host64516" ],
+ "down" )
def CASE6( self, main ):
'''
Recover links to peers one by one, check routes/intents
'''
- import time
- main.case( "Bring up links and check routes/intents" )
- main.step( "Bring up the link between sw32 and peer64514" )
- linkResult1 = main.Mininet.link( END1="sw32", END2="pr64514",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult1,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult1 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 1 )
- main.Functions.checkM2SintentNum( main, 1 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw8 and peer64515" )
- linkResult2 = main.Mininet.link( END1="sw8", END2="pr64515",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult2,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult2 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 2 )
- main.Functions.checkM2SintentNum( main, 2 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Bring up the link between sw28 and peer64516" )
- linkResult3 = main.Mininet.link( END1="sw28", END2="pr64516",
- OPTION="up" )
- utilities.assertEquals( expect=main.TRUE,
- actual=linkResult3,
- onpass="Bring up link succeeded!",
- onfail="Bring up link failed!" )
- if linkResult3 == main.TRUE:
- time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
- main.Functions.checkRouteNum( main, 3 )
- main.Functions.checkM2SintentNum( main, 3 )
- else:
- main.log.error( "Bring up link failed!" )
- main.cleanup()
- main.exit()
-
- main.step( "Check whether all flow status are ADDED" )
- flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
- main.FALSE,
- kwargs={'isPENDING':False},
- attempts=10 )
- utilities.assertEquals( \
- expect=main.TRUE,
- actual=flowCheck,
- onpass="Flow status is correct!",
- onfail="Flow status is wrong!" )
-
- # Ping test
- main.Functions.pingSpeakerToPeer( main, speakers=["speaker1"],
- peers=["pr64514", "pr64515", "pr64516"],
- expectAllSuccess=True )
- main.Functions.pingHostToHost( main,
- hosts=["host64514", "host64515", "host64516"],
- expectAllSuccess=True )
-
+ main.sdnBase.linkUpDownCheck( "pr64514", "pr64515", "pr64516",
+ 1, 1, 2, 2, 3, 3,
+ "speaker1", [ "host64514", "host64515", "host64516" ],
+ "up" )
def CASE7( self, main ):
'''
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
index 62889c9..f60e004 100644
--- a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
@@ -29,50 +29,29 @@
import imp
import time
import json
- main.case( "Setting up test environment" )
- main.caseExplanation = "Setup the test environment including " +\
- "installing ONOS, starting Mininet and ONOS" +\
- "cli sessions."
- # load some variables from the params file
- cellName = main.params[ 'ENV' ][ 'cellName' ]
+ try:
+ from tests.dependencies.ONOSSetup import ONOSSetup
+ main.testSetUp = ONOSSetup()
+ except ImportError:
+ main.log.error( "ONOSSetup not found. exiting the test" )
+ main.exit()
+ main.testSetUp.envSetupDescription()
+ stepResult = main.FALSE
+ try:
+ # load some variables from the params file
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
- main.numCtrls = int( main.params[ 'num_controllers' ] )
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ main.numCtrls = int( main.params[ 'num_controllers' ] )
- ofPort = main.params[ 'CTRL' ][ 'port' ]
+ ofPort = main.params[ 'CTRL' ][ 'port' ]
+ stepResult = main.testSetUp.envSetup( hasRest=True, hasNode=True )
+ except Exception as e:
+ main.testSetUp.envSetupException( e )
+ main.testSetUp.evnSetupConclusion( stepResult )
- main.CLIs = []
- main.RESTs = []
- main.nodes = []
- ipList = []
- for i in range( 1, main.numCtrls + 1 ):
- try:
- main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
- main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) )
- main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
- ipList.append( main.nodes[ -1 ].ip_address )
- except AttributeError:
- break
-
- main.step( "Create cell file" )
- cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- main.Mininet1.ip_address,
- cellAppString, ipList, main.ONOScli1.karafUser )
- main.step( "Applying cell variable to environment" )
- cellResult = main.ONOSbench.setCell( cellName )
- verifyResult = main.ONOSbench.verifyCell()
-
- main.log.info( "Uninstalling ONOS" )
- for node in main.nodes:
- main.ONOSbench.onosUninstall( node.ip_address )
-
- # Make sure ONOS is DEAD
- main.log.info( "Killing any ONOS processes" )
- killResults = main.TRUE
- for node in main.nodes:
- killed = main.ONOSbench.onosKill( node.ip_address )
- killResults = killResults and killed
+ main.testSetUp.ONOSSetUp( main.Mininet1, cellName=cellName )
main.step( "Starting Mininet" )
# scp topo file to mininet
@@ -94,63 +73,6 @@
onpass="Mininet Started",
onfail="Error starting Mininet" )
- main.ONOSbench.getVersion( report=True )
-
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.buckBuild()
- utilities.assert_equals( expect=main.TRUE, actual=packageResult,
- onpass="ONOS package successful",
- onfail="ONOS package failed" )
-
- main.step( "Installing ONOS package" )
- onosInstallResult = main.TRUE
- for node in main.nodes:
- tmpResult = main.ONOSbench.onosInstall( options="-f",
- node=node.ip_address )
- onosInstallResult = onosInstallResult and tmpResult
- utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
- onpass="ONOS install successful",
- onfail="ONOS install failed" )
-
- main.step( "Set up ONOS secure SSH" )
- secureSshResult = main.TRUE
- for node in main.nodes:
- secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=node.ip_address )
- utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
- onpass="Test step PASS",
- onfail="Test step FAIL" )
-
- main.step( "Checking if ONOS is up yet" )
- for i in range( 2 ):
- onosIsupResult = main.TRUE
- for node in main.nodes:
- started = main.ONOSbench.isup( node.ip_address )
- if not started:
- main.log.error( node.name + " hasn't started" )
- onosIsupResult = onosIsupResult and started
- if onosIsupResult == main.TRUE:
- break
- utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult,
- onpass="ONOS startup successful",
- onfail="ONOS startup failed" )
-
- main.step( "Starting ONOS CLI sessions" )
- cliResults = main.TRUE
- threads = []
- for i in range( main.numCtrls ):
- t = main.Thread( target=main.CLIs[ i ].startOnosCli,
- name="startOnosCli-" + str( i ),
- args=[ main.nodes[ i ].ip_address ] )
- threads.append( t )
- t.start()
-
- for t in threads:
- t.join()
- cliResults = cliResults and t.result
- utilities.assert_equals( expect=main.TRUE, actual=cliResults,
- onpass="ONOS cli startup successful",
- onfail="ONOS cli startup failed" )
-
main.activeNodes = [ i for i in range( 0, len( main.CLIs ) ) ]
main.step( "Activate apps defined in the params file" )
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
index 476d986..03e451b 100755
--- a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
@@ -8,7 +8,7 @@
<type>OnosDriver</type>
<connect_order>1</connect_order>
<COMPONENTS>
- <nodes>1</nodes>
+ <nodes>3</nodes>
<prompt></prompt>
</COMPONENTS>
</ONOSbench>
diff --git a/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py b/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py
new file mode 100644
index 0000000..1dfe2e9
--- /dev/null
+++ b/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py
@@ -0,0 +1,215 @@
+class SdnBase:
+ def __init__(self):
+ self.default = ''
+ def initSetup( self ):
+ import json
+ import time
+ import os
+ from operator import eq
+ main.case( "Setting up ONOS environment" )
+ try:
+ from tests.dependencies.ONOSSetup import ONOSSetup
+ main.testSetUp = ONOSSetup()
+ except Exception:
+ main.log.error( "ONOSSetup not found. exiting the test" )
+ main.exit()
+
+ main.testSetUp.envSetup()
+ main.apps = main.params[ 'ENV' ][ 'appString' ]
+ cellName = main.params[ 'ENV' ][ 'cellName' ]
+
+
+
+
+ main.step( "Copying config files" )
+ src = os.path.dirname( main.testFile ) + "/network-cfg.json"
+ dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json"
+ status = main.ONOSbench.scp( main.ONOSbench, src, dst, direction="to" )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=status,
+ onpass="Copy config file succeeded",
+ onfail="Copy config file failed" )
+ main.testSetUp.ONOSSetUp( main.Mininet, cellName=cellName )
+
+ main.step( "Checking if ONOS CLI is ready for issuing commands" )
+ for i in range( 10 ):
+ ready = True
+ for cli in main.CLIs:
+ output = cli.summary()
+ if not output:
+ ready = False
+ if ready:
+ break
+ time.sleep( 30 )
+ utilities.assert_equals( expect=True, actual=ready,
+ onpass="ONOS summary command succeded",
+ onfail="ONOS summary command failed" )
+
+ if not ready:
+ main.log.error( "ONOS startup failed!" )
+ main.cleanup()
+ main.exit()
+
+ def pToPIntentTest( self, intentExpectedNum ):
+ '''
+ point-to-point intents test for each BGP peer and BGP speaker pair
+ '''
+ import time
+ main.case( "Check point-to-point intents" )
+ main.log.info( "There are %s BGP peers in total "
+ % main.params[ 'config' ][ 'peerNum' ] )
+ main.step( "Check P2P intents number from ONOS CLI" )
+
+ getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
+ bgpIntentsActualNum = \
+ main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
+ bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * intentExpectedNum
+ if bgpIntentsActualNum != bgpIntentsExpectedNum:
+ time.sleep( int( main.params['timers']['RouteDelivery'] ) )
+ getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
+ bgpIntentsActualNum = \
+ main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult )
+ main.log.info( "bgpIntentsExpected num is:" )
+ main.log.info( bgpIntentsExpectedNum )
+ main.log.info( "bgpIntentsActual num is:" )
+ main.log.info( bgpIntentsActualNum )
+ utilities.assert_equals( expect=bgpIntentsExpectedNum,
+ actual=bgpIntentsActualNum,
+ onpass="PointToPointIntent Intent Num is correct!",
+ onfail="PointToPointIntent Intent Num is wrong!" )
+
+ def routeAndIntentCheck( self, allRoutesExpected, routeIntentsExpectedNum ):
+ '''
+ routes and intents check to all BGP peers
+ '''
+ import time
+ getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
+ allRoutesStrExpected = str( sorted( allRoutesExpected ) )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+ if allRoutesStrActual != allRoutesStrExpected:
+ time.sleep( int( main.params['timers']['RouteDelivery'] ) )
+ getRoutesResult = main.ONOScli1.routes( jsonFormat=True )
+ allRoutesActual = \
+ main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult )
+ allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
+
+ main.step( "Check routes installed" )
+ main.log.info( "Routes expected:" )
+ main.log.info( allRoutesStrExpected )
+ main.log.info( "Routes get from ONOS CLI:" )
+ main.log.info( allRoutesStrActual )
+ utilities.assertEquals( \
+ expect=allRoutesStrExpected, actual=allRoutesStrActual,
+ onpass="Routes are correct!",
+ onfail="Routes are wrong!" )
+
+ main.step( "Check M2S intents installed" )
+ getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
+ routeIntentsActualNum = \
+ main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
+ if routeIntentsActualNum != routeIntentsExpectedNum:
+ time.sleep( int( main.params['timers']['RouteDelivery'] ) )
+ getIntentsResult = main.ONOScli1.intents( jsonFormat=True )
+ routeIntentsActualNum = \
+ main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult )
+
+ main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
+ main.log.info( routeIntentsExpectedNum )
+ main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
+ main.log.info( routeIntentsActualNum )
+ utilities.assertEquals( \
+ expect=routeIntentsExpectedNum,
+ actual=routeIntentsActualNum,
+ onpass="MultiPointToSinglePoint Intent Num is correct!",
+ onfail="MultiPointToSinglePoint Intent Num is wrong!" )
+
+ main.step( "Check whether all flow status are ADDED" )
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+ main.FALSE,
+ kwargs={'isPENDING':False},
+ attempts=10 )
+ utilities.assertEquals( \
+ expect=main.TRUE,
+ actual=flowCheck,
+ onpass="Flow status is correct!",
+ onfail="Flow status is wrong!" )
+
+ def linkUpDownCheck( self, link1Peer, link2Peer, link3Peer,
+ link1RouteNum, link1IntentNum,
+ link2RouteNum, link2IntentNum,
+ link3RouteNum, link3IntentNum,
+ speakers, hosts, upOrDown ):
+ '''
+ Cut/Recover links to peers one by one, check routes/intents
+ upOrDown - "up" or "down"
+ '''
+ import time
+ main.case( "Bring " + upOrDown + " links and check routes/intents" )
+ main.step( "Bring " + upOrDown + " the link between sw32 and " + link1Peer )
+ linkResult1 = main.Mininet.link( END1="sw32", END2=link1Peer,
+ OPTION=upOrDown )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=linkResult1,
+ onpass="Bring down link succeeded!",
+ onfail="Bring down link failed!" )
+
+ if linkResult1 == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, link1RouteNum )
+ main.Functions.checkM2SintentNum( main, link1IntentNum )
+ else:
+ main.log.error( "Bring " + upOrDown + " link failed!" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Bring " + upOrDown + " the link between sw8 and " + link2Peer )
+ linkResult2 = main.Mininet.link( END1="sw8", END2=link2Peer,
+ OPTION=upOrDown )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=linkResult2,
+ onpass="Bring " + upOrDown + " link succeeded!",
+ onfail="Bring " + upOrDown + " link failed!" )
+ if linkResult2 == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, link2RouteNum )
+ main.Functions.checkM2SintentNum( main, link2IntentNum )
+ else:
+ main.log.error( "Bring " + upOrDown + " link failed!" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Bring " + upOrDown + " the link between sw28 and "+ link3Peer )
+ linkResult3 = main.Mininet.link( END1="sw28", END2=link3Peer,
+ OPTION=upOrDown )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=linkResult3,
+ onpass="Bring " + upOrDown + " link succeeded!",
+ onfail="Bring " + upOrDown + " link failed!" )
+ if linkResult3 == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, link3RouteNum )
+ main.Functions.checkM2SintentNum( main, link3IntentNum )
+ else:
+ main.log.error( "Bring " + upOrDown + " link failed!" )
+ main.cleanup()
+ main.exit()
+
+ main.step( "Check whether all flow status are ADDED" )
+ flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+ main.FALSE,
+ kwargs={'isPENDING':False},
+ attempts=10 )
+ utilities.assert_equals( expect=main.TRUE,
+ actual=flowCheck,
+ onpass="Flow status is correct!",
+ onfail="Flow status is wrong!" )
+
+ # Ping test
+ main.Functions.pingSpeakerToPeer( main, speakers=[ speakers ],
+ peers=[ link1Peer, link2Peer, link3Peer ],
+ expectAllSuccess=False )
+ main.Functions.pingHostToHost( main,
+ hosts=hosts,
+ expectAllSuccess=False )
\ No newline at end of file