acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 1 | # Testing the basic intent functionality of ONOS |
| 2 | |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 3 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 4 | class FUNCoptical: |
| 5 | |
| 6 | def __init__( self ): |
| 7 | self.default = '' |
| 8 | |
| 9 | def CASE1( self, main ): |
| 10 | import time |
| 11 | import imp |
| 12 | import re |
| 13 | |
| 14 | """ |
| 15 | - Construct tests variables |
| 16 | - GIT ( optional ) |
| 17 | - Checkout ONOS master branch |
| 18 | - Pull latest ONOS code |
| 19 | - Building ONOS ( optional ) |
| 20 | - Install ONOS package |
| 21 | - Build ONOS package |
| 22 | """ |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 23 | main.case( "Constructing test variables and building ONOS package" ) |
| 24 | main.step( "Constructing test variables" ) |
| 25 | main.caseExplanation = "This test case is mainly for loading " +\ |
| 26 | "from params file, and pull and build the " +\ |
| 27 | " latest ONOS package" |
| 28 | stepResult = main.FALSE |
| 29 | |
| 30 | # Test variables |
| 31 | try: |
| 32 | main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir ) |
| 33 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 34 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 35 | main.dependencyPath = main.testOnDirectory + \ |
| 36 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 37 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 38 | if main.ONOSbench.maxNodes: |
| 39 | main.maxNodes = int( main.ONOSbench.maxNodes ) |
| 40 | else: |
| 41 | main.maxNodes = 0 |
| 42 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 43 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 44 | main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 45 | main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] ) |
| 46 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 47 | main.switches = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 48 | main.links = int( main.params[ 'MININET' ][ 'links' ] ) |
| 49 | main.hosts = int( main.params[ 'MININET' ][ 'hosts' ] ) |
| 50 | main.opticalTopo = main.params[ 'MININET' ][ 'toponame' ] |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 51 | main.cellData = {} # For creating cell file |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 52 | main.hostsData = {} |
| 53 | main.CLIs = [] |
| 54 | main.ONOSip = [] # List of IPs of active ONOS nodes. CASE 2 |
| 55 | main.activeONOSip = [] |
| 56 | main.assertReturnString = '' # Assembled assert return string |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 57 | main.cycle = 0 # How many times FUNCintent has run through its tests |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 58 | |
| 59 | main.ONOSip = main.ONOSbench.getOnosIps() |
| 60 | |
| 61 | # Assigning ONOS cli handles to a list |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 62 | for i in range( 1, main.maxNodes + 1 ): |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 63 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 64 | |
| 65 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 66 | main.topo = imp.load_source( wrapperFile1, |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 67 | main.dependencyPath + |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 68 | wrapperFile1 + |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 69 | ".py" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 70 | if main.CLIs: |
| 71 | stepResult = main.TRUE |
| 72 | else: |
| 73 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 74 | stepResult = main.FALSE |
| 75 | except Exception as e: |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 76 | main.log.exception( e ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 77 | main.cleanup() |
| 78 | main.exit() |
| 79 | |
| 80 | utilities.assert_equals( expect=main.TRUE, |
| 81 | actual=stepResult, |
| 82 | onpass="Successfully construct " + |
| 83 | "test variables ", |
| 84 | onfail="Failed to construct test variables" ) |
| 85 | |
| 86 | if gitPull == 'True': |
| 87 | main.step( "Building ONOS in " + gitBranch + " branch" ) |
| 88 | onosBuildResult = main.startUp.onosBuild( main, gitBranch ) |
| 89 | stepResult = onosBuildResult |
| 90 | utilities.assert_equals( expect=main.TRUE, |
| 91 | actual=stepResult, |
| 92 | onpass="Successfully compiled " + |
| 93 | "latest ONOS", |
| 94 | onfail="Failed to compile " + |
| 95 | "latest ONOS" ) |
| 96 | else: |
| 97 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 98 | "clean install" ) |
| 99 | main.ONOSbench.getVersion( report=True ) |
| 100 | |
| 101 | def CASE2( self, main ): |
| 102 | """ |
| 103 | - Set up cell |
| 104 | - Create cell file |
| 105 | - Set cell file |
| 106 | - Verify cell file |
| 107 | - Kill ONOS process |
| 108 | - Uninstall ONOS cluster |
| 109 | - Verify ONOS start up |
| 110 | - Install ONOS cluster |
| 111 | - Connect to cli |
| 112 | """ |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 113 | main.cycle += 1 |
| 114 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 115 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 116 | main.numCtrls = int( main.scale[ 0 ] ) |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 117 | main.flowCompiler = "Flow Rules" |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 118 | |
| 119 | main.case( "Starting up " + str( main.numCtrls ) + |
| 120 | " node(s) ONOS cluster" ) |
| 121 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 122 | " node(s) ONOS cluster" |
| 123 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 124 | #kill off all onos processes |
| 125 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 126 | " before initiating environment setup" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 127 | |
| 128 | for i in range( main.maxNodes ): |
| 129 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 130 | |
| 131 | print "NODE COUNT = ", main.numCtrls |
| 132 | |
| 133 | tempOnosIp = [] |
| 134 | for i in range( main.numCtrls ): |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 135 | tempOnosIp.append( main.ONOSip[ i ] ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 136 | |
| 137 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 138 | "temp", main.Mininet1.ip_address, |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 139 | main.apps, tempOnosIp, main.ONOScli1.user_name ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 140 | |
| 141 | main.step( "Apply cell to environment" ) |
| 142 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 143 | verifyResult = main.ONOSbench.verifyCell() |
| 144 | stepResult = cellResult and verifyResult |
| 145 | utilities.assert_equals( expect=main.TRUE, |
| 146 | actual=stepResult, |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 147 | onpass="Successfully applied cell to " + |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 148 | "environment", |
| 149 | onfail="Failed to apply cell to environment " ) |
| 150 | |
| 151 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 152 | packageResult = main.ONOSbench.buckBuild() |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 153 | stepResult = packageResult |
| 154 | utilities.assert_equals( expect=main.TRUE, |
| 155 | actual=stepResult, |
| 156 | onpass="Successfully created ONOS package", |
| 157 | onfail="Failed to create ONOS package" ) |
| 158 | |
| 159 | time.sleep( main.startUpSleep ) |
| 160 | main.step( "Uninstalling ONOS package" ) |
| 161 | onosUninstallResult = main.TRUE |
| 162 | for ip in main.ONOSip: |
| 163 | onosUninstallResult = onosUninstallResult and \ |
| 164 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 165 | stepResult = onosUninstallResult |
| 166 | utilities.assert_equals( expect=main.TRUE, |
| 167 | actual=stepResult, |
| 168 | onpass="Successfully uninstalled ONOS package", |
| 169 | onfail="Failed to uninstall ONOS package" ) |
| 170 | |
| 171 | time.sleep( main.startUpSleep ) |
| 172 | main.step( "Installing ONOS package" ) |
| 173 | onosInstallResult = main.TRUE |
| 174 | for i in range( main.numCtrls ): |
| 175 | onosInstallResult = onosInstallResult and \ |
| 176 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 177 | # Populate activeONOSip |
| 178 | main.activeONOSip.append( main.ONOSip[ i ] ) |
| 179 | stepResult = onosInstallResult |
| 180 | utilities.assert_equals( expect=main.TRUE, |
| 181 | actual=stepResult, |
| 182 | onpass="Successfully installed ONOS package", |
| 183 | onfail="Failed to install ONOS package" ) |
| 184 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 185 | main.step( "Set up ONOS secure SSH" ) |
| 186 | secureSshResult = main.TRUE |
| 187 | for i in range( int( main.numCtrls ) ): |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 188 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] ) |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 189 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 190 | onpass="Test step PASS", |
| 191 | onfail="Test step FAIL" ) |
| 192 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 193 | time.sleep( main.startUpSleep ) |
| 194 | main.step( "Starting ONOS service" ) |
| 195 | stopResult = main.TRUE |
| 196 | startResult = main.TRUE |
| 197 | onosIsUp = main.TRUE |
| 198 | |
| 199 | for i in range( main.numCtrls ): |
Jeremy Songster | 7edb663 | 2016-04-28 15:44:28 -0700 | [diff] [blame] | 200 | isUp = main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 201 | onosIsUp = onosIsUp and isUp |
| 202 | if isUp == main.TRUE: |
| 203 | main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) ) |
| 204 | else: |
| 205 | main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) + |
| 206 | "start ONOS again " ) |
| 207 | stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 208 | startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 209 | if not startResult or stopResult: |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 210 | main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 211 | stepResult = onosIsUp and stopResult and startResult |
| 212 | utilities.assert_equals( expect=main.TRUE, |
| 213 | actual=stepResult, |
Jeremy Songster | 7edb663 | 2016-04-28 15:44:28 -0700 | [diff] [blame] | 214 | onpass="ONOS service is ready on all nodes", |
| 215 | onfail="ONOS service did not start properly on all nodes" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 216 | |
| 217 | main.step( "Start ONOS cli" ) |
| 218 | cliResult = main.TRUE |
| 219 | for i in range( main.numCtrls ): |
| 220 | cliResult = cliResult and \ |
| 221 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 222 | stepResult = cliResult |
| 223 | utilities.assert_equals( expect=main.TRUE, |
| 224 | actual=stepResult, |
| 225 | onpass="Successfully start ONOS cli", |
| 226 | onfail="Failed to start ONOS cli" ) |
| 227 | |
| 228 | # Remove the first element in main.scale list |
| 229 | main.scale.remove( main.scale[ 0 ] ) |
| 230 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 231 | def CASE10( self, main ): |
| 232 | """ |
| 233 | Start Mininet opticalTest Topology |
| 234 | """ |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 235 | main.case( "Mininet with Linc-OE startup" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 236 | main.caseExplanation = "Start opticalTest.py topology included with ONOS" |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 237 | if main.opticalTopo: |
| 238 | main.step( "Copying optical topology to $ONOS_ROOT/tools/test/topos/" ) |
| 239 | main.ONOSbench.scp( main.ONOSbench, |
| 240 | "{0}{1}.py".format( main.dependencyPath, main.opticalTopo ), |
| 241 | "~/onos/tools/test/topos/{0}.py".format( main.opticalTopo ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 242 | main.step( "Starting mininet and LINC-OE" ) |
| 243 | topoResult = main.TRUE |
| 244 | time.sleep( 10 ) |
| 245 | controllerIPs = ' '.join( main.activeONOSip ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 246 | opticalMnScript = main.LincOE.runOpticalMnScript( ctrllerIP=controllerIPs, topology=main.opticalTopo ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 247 | topoResult = opticalMnScript |
| 248 | utilities.assert_equals( |
| 249 | expect=main.TRUE, |
| 250 | actual=topoResult, |
| 251 | onpass="Started the topology successfully ", |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 252 | onfail="Failed to start the topology" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 253 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 254 | main.step( "Push Topology.json to ONOS through onos-netcfg" ) |
| 255 | pushResult = main.TRUE |
| 256 | time.sleep( 20 ) |
| 257 | main.ONOSbench.onosNetCfg( controllerIps=controllerIPs, path=main.dependencyPath, fileName="Topology" ) |
| 258 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 259 | # Exit if topology did not load properly |
| 260 | if not topoResult: |
| 261 | main.cleanup() |
| 262 | main.exit() |
| 263 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 264 | def CASE14( self, main ): |
| 265 | """ |
| 266 | Stop mininet |
| 267 | """ |
| 268 | main.log.report( "Stop Mininet topology" ) |
| 269 | main.case( "Stop Mininet topology" ) |
| 270 | main.caseExplanation = "Stopping the current mininet topology " +\ |
| 271 | "to start up fresh" |
| 272 | |
| 273 | main.step( "Stopping Mininet Topology" ) |
| 274 | topoResult = main.LincOE.stopNet( timeout=180 ) |
| 275 | utilities.assert_equals( expect=main.TRUE, |
| 276 | actual=topoResult, |
| 277 | onpass="Successfully stopped mininet", |
| 278 | onfail="Failed to stopped mininet" ) |
| 279 | # Exit if topology did not load properly |
| 280 | if not topoResult: |
| 281 | main.cleanup() |
| 282 | main.exit() |
| 283 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 284 | def CASE16( self, main ): |
| 285 | """ |
| 286 | Balance Masters |
| 287 | """ |
| 288 | main.case( "Balance mastership of switches" ) |
| 289 | main.step( "Balancing mastership of switches" ) |
| 290 | |
| 291 | balanceResult = main.FALSE |
| 292 | balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] ) |
| 293 | |
| 294 | utilities.assert_equals( expect=main.TRUE, |
| 295 | actual=balanceResult, |
| 296 | onpass="Successfully balanced mastership of switches", |
| 297 | onfail="Failed to balance mastership of switches" ) |
| 298 | if not balanceResult: |
| 299 | main.initialized = main.FALSE |
| 300 | |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 301 | def CASE17( self, main ): |
| 302 | """ |
| 303 | Use Flow Objectives |
| 304 | """ |
| 305 | main.case( "Enable intent compilation using Flow Objectives" ) |
| 306 | main.step( "Enabling Flow Objectives" ) |
| 307 | |
| 308 | main.flowCompiler = "Flow Objectives" |
| 309 | |
| 310 | cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator" |
| 311 | |
| 312 | stepResult = main.CLIs[ 0 ].setCfg( component=cmd, |
| 313 | propName="useFlowObjectives", value="true" ) |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 314 | stepResult &= main.CLIs[ 0 ].setCfg( component=cmd, |
| 315 | propName="defaultFlowObjectiveCompiler", |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 316 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' ) |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 317 | |
| 318 | utilities.assert_equals( expect=main.TRUE, |
| 319 | actual=stepResult, |
| 320 | onpass="Successfully activated Flow Objectives", |
| 321 | onfail="Failed to activate Flow Objectives" ) |
| 322 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 323 | def CASE19( self, main ): |
| 324 | """ |
| 325 | Copy the karaf.log files after each testcase cycle |
| 326 | """ |
| 327 | main.log.report( "Copy karaf logs" ) |
| 328 | main.case( "Copy karaf logs" ) |
| 329 | main.caseExplanation = "Copying the karaf logs to preserve them through" +\ |
| 330 | "reinstalling ONOS" |
| 331 | main.step( "Copying karaf logs" ) |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 332 | stepResult = main.TRUE |
| 333 | scpResult = main.TRUE |
| 334 | copyResult = main.TRUE |
Jeremy Songster | cc5414b | 2016-07-11 10:59:53 -0700 | [diff] [blame] | 335 | for i in range( main.numCtrls ): |
| 336 | main.node = main.CLIs[ i ] |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 337 | ip = main.ONOSip[ i ] |
| 338 | main.node.ip_address = ip |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 339 | scpResult = scpResult and main.ONOSbench.scp( main.node, |
| 340 | "/opt/onos/log/karaf.log", |
| 341 | "/tmp/karaf.log", |
| 342 | direction="from" ) |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 343 | copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir, |
| 344 | copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) ) |
| 345 | if scpResult and copyResult: |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 346 | stepResult = main.TRUE and stepResult |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 347 | else: |
| 348 | stepResult = main.FALSE and stepResult |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 349 | utilities.assert_equals( expect=main.TRUE, |
| 350 | actual=stepResult, |
| 351 | onpass="Successfully copied remote ONOS logs", |
| 352 | onfail="Failed to copy remote ONOS logs" ) |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 353 | |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 354 | def CASE21( self, main ): |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 355 | """ |
| 356 | Run pingall to discover all hosts |
| 357 | """ |
| 358 | main.case( "Running Pingall" ) |
| 359 | main.caseExplanation = "Use pingall to discover all hosts. Pingall is expected to fail." |
| 360 | main.step( "Discover Hosts through Pingall" ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 361 | pingResult = main.LincOE.pingall( timeout=120 ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 362 | |
| 363 | utilities.assert_equals( expect=main.FALSE, |
| 364 | actual=pingResult, |
| 365 | onpass="Pingall Completed", |
| 366 | onfail="Pingall did not complete or did not return fales" ) |
| 367 | |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 368 | def CASE22( self, main ): |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 369 | """ |
| 370 | Send arpings to discover all hosts |
| 371 | """ |
| 372 | main.case( "Discover Hosts with arping" ) |
| 373 | main.caseExplanation = "Send arpings between all the hosts to discover and verify them" |
| 374 | |
| 375 | main.step( "Send arping between all hosts" ) |
| 376 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 377 | hosts = [] |
| 378 | for i in range( main.hosts ): |
| 379 | hosts.append( 'h{}'.format( i + 1 ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 380 | |
| 381 | arpingHostResults = main.TRUE |
| 382 | for host in hosts: |
| 383 | if main.LincOE.arping( host ): |
| 384 | main.log.info( "Successfully reached host {} with arping".format( host ) ) |
| 385 | else: |
| 386 | main.log.error( "Could not reach host {} with arping".format( host ) ) |
| 387 | arpingHostResults = main.FALSE |
| 388 | |
| 389 | utilities.assert_equals( expect=main.TRUE, |
| 390 | actual=arpingHostResults, |
| 391 | onpass="Successfully discovered all hosts", |
| 392 | onfail="Could not descover some hosts" ) |
| 393 | |
| 394 | def CASE23( self, main ): |
| 395 | """ |
| 396 | Compare ONOS Topology to Mininet Topology |
| 397 | """ |
| 398 | import json |
| 399 | |
| 400 | main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 401 | main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 402 | " and ONOS" |
| 403 | |
| 404 | main.log.info( "Gathering topology information from Mininet" ) |
| 405 | devicesResults = main.FALSE # Overall Boolean for device correctness |
| 406 | linksResults = main.FALSE # Overall Boolean for link correctness |
| 407 | hostsResults = main.FALSE # Overall Boolean for host correctness |
| 408 | deviceFails = [] # Nodes where devices are incorrect |
| 409 | linkFails = [] # Nodes where links are incorrect |
| 410 | hostFails = [] # Nodes where hosts are incorrect |
| 411 | attempts = main.checkTopoAttempts # Remaining Attempts |
| 412 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 413 | mnSwitches = main.switches |
| 414 | mnLinks = main.links |
| 415 | mnHosts = main.hosts |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 416 | |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 417 | main.step( "Comparing Mininet topology to ONOS topology" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 418 | |
| 419 | while ( attempts >= 0 ) and\ |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 420 | ( not devicesResults or not linksResults or not hostsResults ): |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 421 | time.sleep( 2 ) |
| 422 | if not devicesResults: |
| 423 | devices = main.topo.getAllDevices( main ) |
| 424 | ports = main.topo.getAllPorts( main ) |
| 425 | devicesResults = main.TRUE |
| 426 | deviceFails = [] # Reset for each attempt |
| 427 | if not linksResults: |
| 428 | links = main.topo.getAllLinks( main ) |
| 429 | linksResults = main.TRUE |
| 430 | linkFails = [] # Reset for each attempt |
| 431 | if not hostsResults: |
| 432 | hosts = main.topo.getAllHosts( main ) |
| 433 | hostsResults = main.TRUE |
| 434 | hostFails = [] # Reset for each attempt |
| 435 | |
| 436 | # Check for matching topology on each node |
| 437 | for controller in range( main.numCtrls ): |
| 438 | controllerStr = str( controller + 1 ) # ONOS node number |
| 439 | # Compare Devices |
| 440 | if devices[ controller ] and ports[ controller ] and\ |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 441 | "Error" not in devices[ controller ] and\ |
| 442 | "Error" not in ports[ controller ]: |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 443 | |
| 444 | try: |
| 445 | deviceData = json.loads( devices[ controller ] ) |
| 446 | portData = json.loads( ports[ controller ] ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 447 | except ( TypeError, ValueError ): |
| 448 | main.log.error( "Could not load json:" + str( devices[ controller ] ) + ' or ' + str( ports[ controller ] ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 449 | currentDevicesResult = main.FALSE |
| 450 | else: |
| 451 | if mnSwitches == len( deviceData ): |
| 452 | currentDevicesResult = main.TRUE |
| 453 | else: |
| 454 | currentDevicesResult = main.FALSE |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 455 | main.log.error( "Node {} only sees {} device(s) but {} exist".format( |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 456 | controllerStr, len( deviceData ), mnSwitches ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 457 | else: |
| 458 | currentDevicesResult = main.FALSE |
| 459 | if not currentDevicesResult: |
| 460 | deviceFails.append( controllerStr ) |
| 461 | devicesResults = devicesResults and currentDevicesResult |
| 462 | # Compare Links |
| 463 | if links[ controller ] and "Error" not in links[ controller ]: |
| 464 | try: |
| 465 | linkData = json.loads( links[ controller ] ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 466 | except ( TypeError, ValueError ): |
| 467 | main.log.error( "Could not load json:" + str( links[ controller ] ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 468 | currentLinksResult = main.FALSE |
| 469 | else: |
| 470 | if mnLinks == len( linkData ): |
| 471 | currentLinksResult = main.TRUE |
| 472 | else: |
| 473 | currentLinksResult = main.FALSE |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 474 | main.log.error( "Node {} only sees {} link(s) but {} exist".format( |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 475 | controllerStr, len( linkData ), mnLinks ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 476 | else: |
| 477 | currentLinksResult = main.FALSE |
| 478 | if not currentLinksResult: |
| 479 | linkFails.append( controllerStr ) |
| 480 | linksResults = linksResults and currentLinksResult |
| 481 | # Compare Hosts |
| 482 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
| 483 | try: |
| 484 | hostData = json.loads( hosts[ controller ] ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 485 | except ( TypeError, ValueError ): |
| 486 | main.log.error( "Could not load json:" + str( hosts[ controller ] ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 487 | currentHostsResult = main.FALSE |
| 488 | else: |
| 489 | if mnHosts == len( hostData ): |
| 490 | currentHostsResult = main.TRUE |
| 491 | else: |
| 492 | currentHostsResult = main.FALSE |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 493 | main.log.error( "Node {} only sees {} host(s) but {} exist".format( |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 494 | controllerStr, len( hostData ), mnHosts ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 495 | else: |
| 496 | currentHostsResult = main.FALSE |
| 497 | if not currentHostsResult: |
| 498 | hostFails.append( controllerStr ) |
| 499 | hostsResults = hostsResults and currentHostsResult |
| 500 | # Decrement Attempts Remaining |
| 501 | attempts -= 1 |
| 502 | |
| 503 | utilities.assert_equals( expect=[], |
| 504 | actual=deviceFails, |
| 505 | onpass="ONOS correctly discovered all devices", |
| 506 | onfail="ONOS incorrectly discovered devices on nodes: " + |
| 507 | str( deviceFails ) ) |
| 508 | utilities.assert_equals( expect=[], |
| 509 | actual=linkFails, |
| 510 | onpass="ONOS correctly discovered all links", |
| 511 | onfail="ONOS incorrectly discovered links on nodes: " + |
| 512 | str( linkFails ) ) |
| 513 | utilities.assert_equals( expect=[], |
| 514 | actual=hostFails, |
| 515 | onpass="ONOS correctly discovered all hosts", |
| 516 | onfail="ONOS incorrectly discovered hosts on nodes: " + |
| 517 | str( hostFails ) ) |
| 518 | if hostsResults and linksResults and devicesResults: |
| 519 | topoResults = main.TRUE |
| 520 | else: |
| 521 | topoResults = main.FALSE |
| 522 | utilities.assert_equals( expect=main.TRUE, |
| 523 | actual=topoResults, |
| 524 | onpass="ONOS correctly discovered the topology", |
| 525 | onfail="ONOS incorrectly discovered the topology" ) |
| 526 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 527 | def CASE31( self, main ): |
| 528 | import time |
| 529 | """ |
| 530 | Add bidirectional point intents between 2 packet layer( mininet ) |
| 531 | devices and ping mininet hosts |
| 532 | """ |
| 533 | main.log.report( |
| 534 | "This testcase adds bidirectional point intents between 2 " + |
| 535 | "packet layer( mininet ) devices and ping mininet hosts" ) |
| 536 | main.case( "Install point intents between 2 packet layer device and " + |
| 537 | "ping the hosts" ) |
| 538 | main.caseExplanation = "This testcase adds bidirectional point intents between 2 " +\ |
| 539 | "packet layer( mininet ) devices and ping mininet hosts" |
| 540 | |
| 541 | main.step( "Adding point intents" ) |
| 542 | checkFlowResult = main.TRUE |
| 543 | main.pIntentsId = [] |
| 544 | pIntent1 = main.CLIs[ 0 ].addPointIntent( |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 545 | "of:0000000000000001/1", |
| 546 | "of:0000000000000002/1" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 547 | time.sleep( 10 ) |
| 548 | pIntent2 = main.CLIs[ 0 ].addPointIntent( |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 549 | "of:0000000000000002/1", |
| 550 | "of:0000000000000001/1" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 551 | main.pIntentsId.append( pIntent1 ) |
| 552 | main.pIntentsId.append( pIntent2 ) |
| 553 | time.sleep( 10 ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 554 | main.log.info( "Checking intents state" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 555 | checkStateResult = main.CLIs[ 0 ].checkIntentState( |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 556 | intentsId=main.pIntentsId ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 557 | time.sleep( 10 ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 558 | main.log.info( "Checking flows state" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 559 | checkFlowResult = main.CLIs[ 0 ].checkFlowsState() |
| 560 | # Sleep for 10 seconds to provide time for the intent state to change |
| 561 | time.sleep( 10 ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 562 | main.log.info( "Checking intents state one more time" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 563 | checkStateResult = main.CLIs[ 0 ].checkIntentState( |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 564 | intentsId=main.pIntentsId ) |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 565 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 566 | if checkStateResult and checkFlowResult: |
| 567 | addIntentsResult = main.TRUE |
| 568 | else: |
| 569 | addIntentsResult = main.FALSE |
| 570 | utilities.assert_equals( |
| 571 | expect=main.TRUE, |
| 572 | actual=addIntentsResult, |
| 573 | onpass="Successfully added point intents", |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 574 | onfail="Failed to add point intents" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 575 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 576 | pingResult = main.FALSE |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 577 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 578 | if not addIntentsResult: |
| 579 | main.log.error( "Intents were not properly installed. Skipping ping." ) |
| 580 | |
| 581 | else: |
| 582 | main.step( "Ping h1 and h2" ) |
| 583 | pingResult = main.LincOE.pingHostOptical( src="h1", target="h2" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 584 | utilities.assert_equals( |
| 585 | expect=main.TRUE, |
| 586 | actual=pingResult, |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 587 | onpass="Successfully pinged h1 and h2", |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 588 | onfail="Failed to ping between h1 and h2" ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 589 | |
| 590 | main.step( "Remove Point to Point intents" ) |
| 591 | removeResult = main.FALSE |
| 592 | # Check remaining intents |
| 593 | try: |
| 594 | intentsJson = json.loads( main.CLIs[ 0 ].intents() ) |
| 595 | main.log.debug( intentsJson ) |
| 596 | main.CLIs[ 0 ].removeIntent( intentId=pIntent1, purge=True ) |
| 597 | main.CLIs[ 0 ].removeIntent( intentId=pIntent2, purge=True ) |
| 598 | for intents in intentsJson: |
| 599 | main.CLIs[ 0 ].removeIntent( intentId=intents.get( 'id' ), |
| 600 | app='org.onosproject.cli', |
| 601 | purge=True ) |
| 602 | time.sleep( 15 ) |
| 603 | |
| 604 | for i in range( main.numCtrls ): |
| 605 | if len( json.loads( main.CLIs[ i ].intents() ) ): |
| 606 | print json.loads( main.CLIs[ i ].intents() ) |
| 607 | removeResult = main.FALSE |
| 608 | else: |
| 609 | removeResult = main.TRUE |
| 610 | except ( TypeError, ValueError ): |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 611 | main.log.error( "Cannot see intents on Node " + str( main.CLIs[ 0 ] ) + |
| 612 | ". Removing all intents." ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 613 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 614 | main.CLIs[ 0 ].removeAllIntents( purge=True, app='org.onosproject.cli' ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 615 | |
| 616 | utilities.assert_equals( expect=main.TRUE, |
| 617 | actual=removeResult, |
| 618 | onpass="Successfully removed host intents", |
| 619 | onfail="Failed to remove host intents" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 620 | |
| 621 | def CASE32( self ): |
| 622 | """ |
| 623 | Add host intents between 2 packet layer host |
| 624 | """ |
| 625 | import time |
| 626 | import json |
| 627 | main.log.report( "Adding host intents between 2 optical layer host" ) |
| 628 | main.case( "Test add host intents between optical layer host" ) |
| 629 | main.caseExplanation = "Test host intents between 2 optical layer host" |
| 630 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 631 | main.step( "Creating list of hosts" ) |
| 632 | hostnum = 0 |
| 633 | try: |
| 634 | hostData = json.loads( hosts[ controller ] ) |
| 635 | except( TypeError, ValueError ): |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 636 | main.log.error( "Could not load json:" + str( hosts[ controller ] ) ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 637 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 638 | main.step( "Adding host intents to h1 and h2" ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 639 | hostId = [] |
| 640 | # Listing host MAC addresses |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 641 | for host in hostData: |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 642 | hostId.append( host.get( "id" ) ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 643 | host1 = hostId[ 0 ] |
| 644 | host2 = hostId[ 1 ] |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 645 | main.log.debug( host1 ) |
| 646 | main.log.debug( host2 ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 647 | |
| 648 | intentsId = [] |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 649 | intent1 = main.CLIs[ 0 ].addHostIntent( hostIdOne=host1, |
| 650 | hostIdTwo=host2 ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 651 | intentsId.append( intent1 ) |
| 652 | # Checking intents state before pinging |
| 653 | main.log.info( "Checking intents state" ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 654 | intentResult = utilities.retry( f=main.CLIs[ 0 ].checkIntentState, |
| 655 | retValue=main.FALSE, args=intentsId, |
| 656 | sleep=main.checkIntentSleep, attempts=10 ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 657 | |
| 658 | # If intent state is still wrong, display intent states |
| 659 | if not intentResult: |
| 660 | main.log.error( main.CLIs[ 0 ].intents() ) |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 661 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 662 | utilities.assert_equals( expect=main.TRUE, |
| 663 | actual=intentResult, |
| 664 | onpass="All intents are in INSTALLED state ", |
| 665 | onfail="Some of the intents are not in " + |
| 666 | "INSTALLED state " ) |
| 667 | |
| 668 | if not intentResult: |
| 669 | main.log.error( "Intents were not properly installed. Skipping Ping" ) |
| 670 | else: |
| 671 | # Pinging h1 to h2 and then ping h2 to h1 |
| 672 | main.step( "Pinging h1 and h2" ) |
| 673 | pingResult = main.TRUE |
| 674 | pingResult = main.LincOE.pingHostOptical( src="h1", target="h2" ) \ |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 675 | and main.LincOE.pingHostOptical( src="h2", target="h1" ) |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 676 | |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 677 | utilities.assert_equals( expect=main.TRUE, |
| 678 | actual=pingResult, |
| 679 | onpass="Pinged successfully between h1 and h2", |
| 680 | onfail="Pinged failed between h1 and h2" ) |
| 681 | |
| 682 | # Removed all added host intents |
| 683 | main.step( "Removing host intents" ) |
| 684 | removeResult = main.TRUE |
| 685 | # Check remaining intents |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 686 | try: |
| 687 | intentsJson = json.loads( main.CLIs[ 0 ].intents() ) |
| 688 | main.CLIs[ 0 ].removeIntent( intentId=intent1, purge=True ) |
| 689 | #main.CLIs[ 0 ].removeIntent( intentId=intent2, purge=True ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 690 | main.log.debug( intentsJson ) |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 691 | for intents in intentsJson: |
Jeremy | e4bc713 | 2016-03-30 14:04:01 -0700 | [diff] [blame] | 692 | main.CLIs[ 0 ].removeIntent( intentId=intents.get( 'id' ), |
| 693 | app='org.onosproject.optical', |
| 694 | purge=True ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 695 | time.sleep( 15 ) |
acsmars | 51a7fe0 | 2015-10-29 18:33:32 -0700 | [diff] [blame] | 696 | |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 697 | for i in range( main.numCtrls ): |
| 698 | if len( json.loads( main.CLIs[ i ].intents() ) ): |
| 699 | print json.loads( main.CLIs[ i ].intents() ) |
| 700 | removeResult = main.FALSE |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 701 | else: |
| 702 | removeResult = main.TRUE |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 703 | except ( TypeError, ValueError ): |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 704 | main.log.error( "Cannot see intents on Node " + str( main.CLIs[ 0 ] ) + |
| 705 | ". Removing all intents." ) |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 706 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
Jon Hall | e02505a | 2017-05-24 16:36:43 -0700 | [diff] [blame] | 707 | main.CLIs[ 0 ].removeAllIntents( purge=True, app='org.onosproject.optical' ) |
Jeremy | 7134f5b | 2016-04-05 13:50:21 -0700 | [diff] [blame] | 708 | |
| 709 | utilities.assert_equals( expect=main.TRUE, |
| 710 | actual=removeResult, |
| 711 | onpass="Successfully removed host intents", |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 712 | onfail="Failed to remove host intents" ) |