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