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