kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 1 | class FUNCgroup: |
| 2 | |
| 3 | def __init__( self ): |
| 4 | self.default = '' |
| 5 | |
| 6 | def CASE1( self, main ): |
| 7 | import os |
| 8 | import imp |
| 9 | |
| 10 | """ |
| 11 | - Construct tests variables |
| 12 | - GIT ( optional ) |
| 13 | - Checkout ONOS master branch |
| 14 | - Pull latest ONOS code |
| 15 | - Building ONOS ( optional ) |
| 16 | - Install ONOS package |
| 17 | - Build ONOS package |
| 18 | """ |
| 19 | main.case( "Constructing test variables and building ONOS package" ) |
| 20 | main.step( "Constructing test variables" ) |
| 21 | |
| 22 | # Test variables |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 23 | main.testOnDirectory = os.path.dirname( os.getcwd() ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 24 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 25 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 26 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 27 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 28 | main.ONOSport = main.params[ 'CTRL' ][ 'port' ] |
| 29 | main.dependencyPath = main.testOnDirectory + \ |
| 30 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 31 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 32 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 33 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 34 | bucket = main.params[ 'DEPENDENCY' ][ 'bucket' ] |
| 35 | main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] ) |
| 36 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 37 | main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] ) |
| 38 | main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] ) |
| 39 | main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] ) |
| 40 | main.addGroupSleep = int( main.params[ 'SLEEP' ][ 'addGroup' ] ) |
| 41 | main.delGroupSleep = int( main.params[ 'SLEEP' ][ 'delGroup' ] ) |
| 42 | main.debug = main.params[ 'DEBUG' ] |
| 43 | main.swDPID = main.params[ 'TEST' ][ 'swDPID' ] |
| 44 | egressPort1 = main.params[ 'TEST' ][ 'egressPort1' ] |
| 45 | egressPort2 = main.params[ 'TEST' ][ 'egressPort2' ] |
| 46 | egressPort3 = main.params[ 'TEST' ][ 'egressPort3' ] |
| 47 | ingressPort = main.params[ 'TEST' ][ 'ingressPort' ] |
| 48 | appCookie = main.params[ 'TEST' ][ 'appCookie' ] |
| 49 | type1 = main.params[ 'TEST' ][ 'type1' ] |
| 50 | type2 = main.params[ 'TEST' ][ 'type2' ] |
| 51 | groupId = main.params[ 'TEST' ][ 'groupId' ] |
| 52 | priority = main.params[ 'TEST' ][ 'priority' ] |
| 53 | deviceId = main.params[ 'TEST' ][ 'swDPID' ] |
| 54 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 55 | main.cellData = {} # for creating cell file |
| 56 | main.CLIs = [] |
| 57 | main.ONOSip = [] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 58 | |
| 59 | main.debug = True if "on" in main.debug else False |
| 60 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 61 | main.ONOSip = main.ONOSbench.getOnosIps() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 62 | |
| 63 | # Assigning ONOS cli handles to a list |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 64 | for i in range( 1, main.maxNodes + 1 ): |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 65 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 66 | |
| 67 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 68 | main.startUp = imp.load_source( wrapperFile1, |
| 69 | main.dependencyPath + |
| 70 | wrapperFile1 + |
| 71 | ".py" ) |
| 72 | |
| 73 | main.topo = imp.load_source( wrapperFile2, |
| 74 | main.dependencyPath + |
| 75 | wrapperFile2 + |
| 76 | ".py" ) |
| 77 | |
| 78 | main.buckets = imp.load_source( bucket, |
| 79 | main.dependencyPath + |
| 80 | bucket + |
| 81 | ".py" ) |
| 82 | |
| 83 | copyResult = main.ONOSbench.scp( main.Mininet1, |
| 84 | main.dependencyPath + main.topology, |
| 85 | main.Mininet1.home + '/custom/', |
| 86 | direction="to" ) |
| 87 | |
| 88 | utilities.assert_equals( expect=main.TRUE, |
| 89 | actual=copyResult, |
| 90 | onpass="Successfully copy " + "test variables ", |
| 91 | onfail="Failed to copy test variables" ) |
| 92 | |
| 93 | if main.CLIs: |
| 94 | stepResult = main.TRUE |
| 95 | else: |
| 96 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 97 | stepResult = main.FALSE |
| 98 | |
| 99 | utilities.assert_equals( expect=main.TRUE, |
| 100 | actual=stepResult, |
| 101 | onpass="Successfully construct " + "test variables ", |
| 102 | onfail="Failed to construct test variables" ) |
| 103 | |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 104 | def CASE2( self, main ): |
| 105 | """ |
| 106 | - Set up cell |
| 107 | - Create cell file |
| 108 | - Set cell file |
| 109 | - Verify cell file |
| 110 | - Kill ONOS process |
| 111 | - Uninstall ONOS cluster |
| 112 | - Verify ONOS start up |
| 113 | - Install ONOS cluster |
| 114 | - Connect to cli |
| 115 | """ |
| 116 | import time |
| 117 | |
| 118 | main.numCtrls = int( main.maxNodes ) |
| 119 | |
| 120 | main.case( "Starting up " + str( main.numCtrls ) + |
| 121 | " node(s) ONOS cluster" ) |
| 122 | |
| 123 | #kill off all onos processes |
| 124 | main.log.info( "Safety check, killing all ONOS processes" + |
| 125 | " before initiating environment setup" ) |
| 126 | |
| 127 | for i in range( main.maxNodes ): |
| 128 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 129 | |
| 130 | main.log.info( "NODE COUNT = " + str( main.numCtrls ) ) |
| 131 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 132 | tempOnosIp = [] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 133 | for i in range( main.numCtrls ): |
| 134 | tempOnosIp.append( main.ONOSip[ i ] ) |
| 135 | |
| 136 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 137 | "temp", |
| 138 | main.Mininet1.ip_address, |
| 139 | main.apps, |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 140 | tempOnosIp, main.ONOScli1.user_name ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 141 | |
| 142 | main.step( "Apply cell to environment" ) |
| 143 | cellResult = main.ONOSbench.setCell( "temp" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 144 | verifyResult = main.ONOSbench.verifyCell() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 145 | stepResult = cellResult and verifyResult |
| 146 | utilities.assert_equals( expect=main.TRUE, |
| 147 | actual=stepResult, |
| 148 | onpass="Successfully applied cell to " + "environment", |
| 149 | onfail="Failed to apply cell to environment " ) |
| 150 | |
| 151 | main.step( "Creating ONOS package" ) |
| 152 | packageResult = main.ONOSbench.buckBuild() |
| 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 | time.sleep( main.startUpSleep ) |
| 171 | main.step( "Installing ONOS package" ) |
| 172 | onosInstallResult = main.TRUE |
| 173 | for i in range( main.numCtrls ): |
| 174 | onosInstallResult = onosInstallResult and \ |
| 175 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 176 | stepResult = onosInstallResult |
| 177 | utilities.assert_equals( expect=main.TRUE, |
| 178 | actual=stepResult, |
| 179 | onpass="Successfully installed ONOS package", |
| 180 | onfail="Failed to install ONOS package" ) |
| 181 | |
| 182 | time.sleep( main.startUpSleep ) |
| 183 | main.step( "Starting ONOS service" ) |
| 184 | stopResult = main.TRUE |
| 185 | startResult = main.TRUE |
| 186 | onosIsUp = main.TRUE |
| 187 | |
| 188 | for i in range( main.numCtrls ): |
| 189 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
| 190 | if onosIsUp == main.TRUE: |
| 191 | main.log.report( "ONOS instance is up and ready" ) |
| 192 | else: |
| 193 | main.log.report( "ONOS instance may not be up, stop and " + |
| 194 | "start ONOS again " ) |
| 195 | for i in range( main.numCtrls ): |
| 196 | stopResult = stopResult and \ |
| 197 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 198 | for i in range( main.numCtrls ): |
| 199 | startResult = startResult and \ |
| 200 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 201 | stepResult = onosIsUp and stopResult and startResult |
| 202 | utilities.assert_equals( expect=main.TRUE, |
| 203 | actual=stepResult, |
| 204 | onpass="ONOS service is ready", |
| 205 | onfail="ONOS service did not start properly" ) |
| 206 | |
| 207 | main.step( "Set up ONOS secure SSH" ) |
| 208 | secureSshResult = main.TRUE |
| 209 | for i in range( int( main.numCtrls ) ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 210 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 211 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 212 | onpass="Test step PASS", |
| 213 | onfail="Test step FAIL" ) |
| 214 | |
| 215 | main.step( "Start ONOS cli" ) |
| 216 | cliResult = main.TRUE |
| 217 | for i in range( main.numCtrls ): |
| 218 | cliResult = cliResult and \ |
| 219 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
| 220 | stepResult = cliResult |
| 221 | utilities.assert_equals( expect=main.TRUE, |
| 222 | actual=stepResult, |
| 223 | onpass="Successfully start ONOS cli", |
| 224 | onfail="Failed to start ONOS cli" ) |
| 225 | |
| 226 | def CASE3( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 227 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 228 | Start Mininet |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 229 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 230 | import json |
| 231 | |
| 232 | main.case( "Setup mininet and compare ONOS topology view to Mininet topology" ) |
| 233 | main.caseExplanation = "Start mininet with custom topology and compare topology " +\ |
| 234 | "elements between Mininet and ONOS" |
| 235 | |
| 236 | main.step( "Setup Mininet Topology" ) |
| 237 | topology = main.Mininet1.home + '/custom/' + main.topology |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 238 | stepResult = main.Mininet1.startNet( topoFile=topology ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 239 | |
| 240 | utilities.assert_equals( expect=main.TRUE, |
| 241 | actual=stepResult, |
| 242 | onpass="Successfully loaded topology", |
| 243 | onfail="Failed to load topology" ) |
| 244 | |
| 245 | main.step( "Assign switch to controller" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 246 | stepResult = main.Mininet1.assignSwController( "s1", main.ONOSip[ 0 ] ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 247 | |
| 248 | utilities.assert_equals( expect=main.TRUE, |
| 249 | actual=stepResult, |
| 250 | onpass="Successfully assigned switch to controller", |
| 251 | onfail="Failed to assign switch to controller" ) |
| 252 | |
| 253 | time.sleep( main.startMNSleep ) |
| 254 | |
| 255 | main.step( "Comparing MN topology to ONOS topology" ) |
| 256 | main.log.info( "Gathering topology information" ) |
| 257 | devices = main.topo.getAllDevices( main ) |
| 258 | hosts = main.topo.getAllHosts( main ) |
| 259 | ports = main.topo.getAllPorts( main ) |
| 260 | links = main.topo.getAllLinks( main ) |
| 261 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 262 | mnSwitches = main.Mininet1.getSwitches() |
| 263 | mnLinks = main.Mininet1.getLinks() |
| 264 | mnHosts = main.Mininet1.getHosts() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 265 | |
| 266 | for controller in range( main.numCtrls ): |
| 267 | controllerStr = str( controller + 1 ) |
| 268 | if devices[ controller ] and ports[ controller ] and\ |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 269 | "Error" not in devices[ controller ] and\ |
| 270 | "Error" not in ports[ controller ]: |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 271 | |
| 272 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 273 | mnSwitches, |
| 274 | json.loads( devices[ controller ] ), |
| 275 | json.loads( ports[ controller ] ) ) |
| 276 | else: |
| 277 | currentDevicesResult = main.FALSE |
| 278 | utilities.assert_equals( expect=main.TRUE, |
| 279 | actual=currentDevicesResult, |
| 280 | onpass="ONOS" + controllerStr + |
| 281 | " Switches view is correct", |
| 282 | onfail="ONOS" + controllerStr + |
| 283 | " Switches view is incorrect" ) |
| 284 | if links[ controller ] and "Error" not in links[ controller ]: |
| 285 | currentLinksResult = main.Mininet1.compareLinks( |
| 286 | mnSwitches, mnLinks, |
| 287 | json.loads( links[ controller ] ) ) |
| 288 | else: |
| 289 | currentLinksResult = main.FALSE |
| 290 | utilities.assert_equals( expect=main.TRUE, |
| 291 | actual=currentLinksResult, |
| 292 | onpass="ONOS" + controllerStr + |
| 293 | " links view is correct", |
| 294 | onfail="ONOS" + controllerStr + |
| 295 | " links view is incorrect" ) |
| 296 | |
| 297 | if hosts[ controller ] or "Error" not in hosts[ controller ]: |
| 298 | currentHostsResult = main.Mininet1.compareHosts( |
| 299 | mnHosts, |
| 300 | json.loads( hosts[ controller ] ) ) |
| 301 | else: |
| 302 | currentHostsResult = main.FALSE |
| 303 | utilities.assert_equals( expect=main.TRUE, |
| 304 | actual=currentHostsResult, |
| 305 | onpass="ONOS" + controllerStr + |
| 306 | " hosts exist in Mininet", |
| 307 | onfail="ONOS" + controllerStr + |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 308 | " hosts don't match Mininet" ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 309 | |
| 310 | def CASE4( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 311 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 312 | Testing scapy |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 313 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 314 | main.case( "Testing scapy" ) |
| 315 | main.step( "Creating Host1 component" ) |
| 316 | main.Scapy.createHostComponent( "h1" ) |
| 317 | main.Scapy.createHostComponent( "h2" ) |
| 318 | hosts = [ main.h1, main.h2 ] |
| 319 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 320 | host.startHostCli() |
| 321 | host.startScapy() |
| 322 | host.updateSelf() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 323 | main.log.debug( host.name ) |
| 324 | main.log.debug( host.hostIp ) |
| 325 | main.log.debug( host.hostMac ) |
| 326 | |
| 327 | main.step( "Sending/Receiving Test packet - Filter doesn't match" ) |
| 328 | main.log.info( "Starting Filter..." ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 329 | main.h2.startFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 330 | main.log.info( "Building Ether frame..." ) |
| 331 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 332 | main.log.info( "Sending Packet..." ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 333 | main.h1.sendPacket() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 334 | main.log.info( "Checking Filter..." ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 335 | finished = main.h2.checkFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 336 | main.log.debug( finished ) |
| 337 | i = "" |
| 338 | if finished: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 339 | a = main.h2.readPackets() |
| 340 | for i in a.splitlines(): |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 341 | main.log.info( i ) |
| 342 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 343 | kill = main.h2.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 344 | main.log.debug( kill ) |
| 345 | main.h2.handle.sendline( "" ) |
| 346 | main.h2.handle.expect( main.h2.scapyPrompt ) |
| 347 | main.log.debug( main.h2.handle.before ) |
| 348 | utilities.assert_equals( expect=True, |
| 349 | actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i, |
| 350 | onpass="Pass", |
| 351 | onfail="Fail" ) |
| 352 | |
| 353 | main.step( "Sending/Receiving Test packet - Filter matches" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 354 | main.h2.startFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 355 | main.h1.buildEther( dst=main.h2.hostMac ) |
| 356 | main.h1.buildIP( dst=main.h2.hostIp ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 357 | main.h1.sendPacket() |
| 358 | finished = main.h2.checkFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 359 | i = "" |
| 360 | if finished: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 361 | a = main.h2.readPackets() |
| 362 | for i in a.splitlines(): |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 363 | main.log.info( i ) |
| 364 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 365 | kill = main.h2.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 366 | main.log.debug( kill ) |
| 367 | main.h2.handle.sendline( "" ) |
| 368 | main.h2.handle.expect( main.h2.scapyPrompt ) |
| 369 | main.log.debug( main.h2.handle.before ) |
| 370 | utilities.assert_equals( expect=True, |
| 371 | actual="dst=00:00:00:00:00:02 src=00:00:00:00:00:01" in i, |
| 372 | onpass="Pass", |
| 373 | onfail="Fail" ) |
| 374 | |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 375 | main.step( "Clean up host components" ) |
| 376 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 377 | host.stopScapy() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 378 | main.Mininet1.removeHostComponent( "h1" ) |
| 379 | main.Mininet1.removeHostComponent( "h2" ) |
| 380 | |
| 381 | def CASE5( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 382 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 383 | Adding Group of type "ALL" using Rest api |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 384 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 385 | import json |
| 386 | import time |
| 387 | isAdded = main.FALSE |
| 388 | main.case( "Verify Group of type All are successfully Added" ) |
| 389 | main.caseExplanation = " Install a Group of type ALL " +\ |
| 390 | " Verify the Group is Added " +\ |
| 391 | " Add a flow using the group " +\ |
| 392 | " Send a packet that verifies the action bucket of the group" |
| 393 | |
| 394 | main.step( "Add Group using Rest api" ) |
| 395 | bucketList = [] |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 396 | bucket = main.buckets.addBucket( main, egressPort=egressPort1 ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 397 | bucketList.append( bucket ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 398 | bucket = main.buckets.addBucket( main, egressPort=egressPort2 ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 399 | bucketList.append( bucket ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 400 | bucket = main.buckets.addBucket( main, egressPort=egressPort3 ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 401 | bucketList.append( bucket ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 402 | response = main.ONOSrest.addGroup( deviceId=deviceId, |
| 403 | groupType=type1, |
| 404 | bucketList=bucketList, |
| 405 | appCookie=appCookie, |
| 406 | groupId=groupId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 407 | |
| 408 | utilities.assert_equals( expect=main.TRUE, |
| 409 | actual=response, |
| 410 | onpass="Successfully added Groups of type ALL", |
| 411 | onfail="Failed to add Groups of type ALL" ) |
| 412 | |
| 413 | # Giving ONOS time to add the group |
| 414 | time.sleep( main.addGroupSleep ) |
| 415 | |
| 416 | main.step( "Check groups are in ADDED state" ) |
| 417 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 418 | response = main.ONOSrest.getGroups( deviceId=deviceId, |
| 419 | appCookie=appCookie ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 420 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 421 | for item in responsejson: |
| 422 | if item[ "state" ] == "ADDED": |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 423 | isAdded = main.TRUE |
| 424 | |
| 425 | utilities.assert_equals( expect=main.TRUE, |
| 426 | actual=isAdded, |
| 427 | onpass="All Group is in Added State", |
| 428 | onfail="All Group is not in Added State" ) |
| 429 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 430 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 431 | Adding flow using rest api |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 432 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 433 | isAdded = main.FALSE |
| 434 | |
| 435 | main.step( "Adding flow with Group using rest api" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 436 | response = main.ONOSrest.addFlow( deviceId=deviceId, |
| 437 | priority=priority, |
| 438 | ingressPort=ingressPort, |
| 439 | groupId=groupId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 440 | utilities.assert_equals( expect=main.TRUE, |
| 441 | actual=response, |
| 442 | onpass="Successfully Added Flows", |
| 443 | onfail="Failed to Add flows" ) |
| 444 | |
| 445 | # Giving ONOS time to add the flow |
| 446 | time.sleep( main.addFlowSleep ) |
| 447 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 448 | response = main.ONOSrest.getFlows( deviceId=deviceId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 449 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 450 | for item in responsejson: |
| 451 | if item[ "priority" ] == int( priority ) and item[ "state" ] == "ADDED": |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 452 | isAdded = main.TRUE |
| 453 | |
| 454 | utilities.assert_equals( expect=main.TRUE, |
| 455 | actual=isAdded, |
| 456 | onpass="Flow is in Added State", |
| 457 | onfail="Flow is not in Added State" ) |
| 458 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 459 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 460 | Sends a packet using scapy |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 461 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 462 | main.step( "Testing Group by sending packet using Scapy" ) |
| 463 | main.log.info( "Creating host components" ) |
| 464 | main.Scapy.createHostComponent( "h1" ) |
| 465 | main.Scapy.createHostComponent( "h2" ) |
| 466 | main.Scapy.createHostComponent( "h3" ) |
| 467 | main.Scapy.createHostComponent( "h4" ) |
| 468 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 469 | hosts = [ main.h1, main.h2, main.h3, main.h4 ] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 470 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 471 | host.startHostCli() |
| 472 | host.startScapy() |
| 473 | host.updateSelf() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 474 | main.log.info( "Constructing Packet" ) |
| 475 | main.h1.buildEther( dst=main.h1.hostMac ) |
| 476 | main.h1.buildIP( dst=main.h1.hostIp ) |
| 477 | main.log.info( "Start Filter on host2,host3,host4" ) |
| 478 | main.h2.startFilter( pktFilter="ether host %s and ip host %s" % ( main.h1.hostMac, main.h1.hostIp ) ) |
| 479 | main.h3.startFilter( pktFilter="ether host %s and ip host %s" % ( main.h1.hostMac, main.h1.hostIp ) ) |
| 480 | main.h4.startFilter( pktFilter="ether host %s and ip host %s" % ( main.h1.hostMac, main.h1.hostIp ) ) |
| 481 | main.log.info( "sending packet to Host" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 482 | main.h1.sendPacket() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 483 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 484 | stepResultH2 = main.h2.checkFilter() |
| 485 | stepResultH3 = main.h3.checkFilter() |
| 486 | stepResultH4 = main.h4.checkFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 487 | |
| 488 | if stepResultH2: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 489 | main.log.info( "Packet : %s" % main.h2.readPackets() ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 490 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 491 | main.h2.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 492 | |
| 493 | if stepResultH3: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 494 | main.log.info( "Packet : %s" % main.h3.readPackets() ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 495 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 496 | main.h2.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 497 | |
| 498 | if stepResultH4: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 499 | main.log.info( "Packet : %s" % main.h4.readPackets() ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 500 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 501 | main.h4.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 502 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 503 | if stepResultH2 and stepResultH3 and stepResultH4: |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 504 | main.log.info( "Success!!!Packet sent to port 1 is received at port 2,3 and 4" ) |
| 505 | stepResult = main.TRUE |
| 506 | else: |
| 507 | main.log.info( "Failure!!!Packet sent to port 1 is not received at port 2,3 and 4" ) |
| 508 | stepResult = main.FALSE |
| 509 | |
| 510 | main.log.info( "Clean up host components" ) |
| 511 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 512 | host.stopScapy() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 513 | main.Mininet1.removeHostComponent( "h1" ) |
| 514 | main.Mininet1.removeHostComponent( "h2" ) |
| 515 | main.Mininet1.removeHostComponent( "h3" ) |
| 516 | main.Mininet1.removeHostComponent( "h4" ) |
| 517 | |
| 518 | utilities.assert_equals( expect=main.TRUE, |
| 519 | actual=stepResult, |
| 520 | onpass="Packet sent to port 1 is received at port 2,3,4 ", |
| 521 | onfail="Packet sent to port 1 is not received at port 2,3,4 " ) |
| 522 | |
| 523 | def CASE6( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 524 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 525 | Deleting the Group and Flow |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 526 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 527 | import json |
| 528 | import time |
| 529 | respFlowId = 1 |
| 530 | |
| 531 | main.case( "Delete the Group and Flow added through Rest api " ) |
| 532 | main.step( "Deleting Group and Flows" ) |
| 533 | |
| 534 | #Get Flow ID |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 535 | response = main.ONOSrest.getFlows( deviceId=deviceId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 536 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 537 | for item in responsejson: |
| 538 | if item[ "priority" ] == int( priority ): |
| 539 | respFlowId = item[ "id" ] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 540 | |
| 541 | main.step( "Deleting the created flow by deviceId and flowId" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 542 | flowResponse = main.ONOSrest.removeFlow( deviceId=deviceId, |
| 543 | flowId=respFlowId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 544 | |
| 545 | utilities.assert_equals( expect=main.TRUE, |
| 546 | actual=flowResponse, |
| 547 | onpass="Deleting flow is successful!!!", |
| 548 | onfail="Deleting flow is failure!!!" ) |
| 549 | |
| 550 | # Giving ONOS time to delete the flow |
| 551 | time.sleep( main.delFlowSleep ) |
| 552 | |
| 553 | main.step( "Deleting the created group by deviceId and appCookie" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 554 | groupResponse = main.ONOSrest.removeGroup( deviceId=deviceId, |
| 555 | appCookie=appCookie ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 556 | |
| 557 | utilities.assert_equals( expect=main.TRUE, |
| 558 | actual=groupResponse, |
| 559 | onpass="Deleting Group is successful!!!", |
| 560 | onfail="Deleting Group is failure!!!" ) |
| 561 | |
| 562 | # Giving ONOS time to delete the group |
| 563 | time.sleep( main.delGroupSleep ) |
| 564 | |
| 565 | def CASE7( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 566 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 567 | Adding Group of type "INDIRECT" using Rest api. |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 568 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 569 | import json |
| 570 | import time |
| 571 | isAdded = main.FALSE |
| 572 | |
| 573 | main.case( "Verify Group of type INDIRECT are successfully Added" ) |
| 574 | main.caseExplanation = " Install a Group of type INDIRECT " +\ |
| 575 | " Verify the Group is Added " +\ |
| 576 | " Add a flow using the group " +\ |
| 577 | " Send a packet that verifies the action bucket of the group" |
| 578 | |
| 579 | main.step( "Add Group using Rest api" ) |
| 580 | bucketList = [] |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 581 | bucket = main.buckets.addBucket( main, egressPort=egressPort1 ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 582 | bucketList.append( bucket ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 583 | response = main.ONOSrest.addGroup( deviceId=deviceId, |
| 584 | groupType=type2, |
| 585 | bucketList=bucketList, |
| 586 | appCookie=appCookie, |
| 587 | groupId=groupId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 588 | |
| 589 | utilities.assert_equals( expect=main.TRUE, |
| 590 | actual=response, |
| 591 | onpass="Successfully added Groups of type INDIRECT", |
| 592 | onfail="Failed to add Groups of type INDIRECT" ) |
| 593 | |
| 594 | # Giving ONOS time to add the group |
| 595 | time.sleep( main.addGroupSleep ) |
| 596 | |
| 597 | main.step( "Check groups are in ADDED state" ) |
| 598 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 599 | response = main.ONOSrest.getGroups( deviceId=deviceId, |
| 600 | appCookie=appCookie ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 601 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 602 | for item in responsejson: |
| 603 | if item[ "state" ] == "ADDED": |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 604 | isAdded = main.TRUE |
| 605 | |
| 606 | utilities.assert_equals( expect=main.TRUE, |
| 607 | actual=isAdded, |
| 608 | onpass="INDIRECT Group is in Added State", |
| 609 | onfail="INDIRECT Group is not in Added State" ) |
| 610 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 611 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 612 | Adding flows using rest api |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 613 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 614 | isAdded = main.FALSE |
| 615 | |
| 616 | main.step( "Adding flow with Group using rest api" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 617 | response = main.ONOSrest.addFlow( deviceId=deviceId, |
| 618 | priority=priority, |
| 619 | ingressPort=ingressPort, |
| 620 | groupId=groupId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 621 | utilities.assert_equals( expect=main.TRUE, |
| 622 | actual=response, |
| 623 | onpass="Successfully Added Flows", |
| 624 | onfail="Failed to Add flows" ) |
| 625 | |
| 626 | # Giving ONOS time to add the flow |
| 627 | time.sleep( main.addFlowSleep ) |
| 628 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 629 | response = main.ONOSrest.getFlows( deviceId=deviceId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 630 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 631 | for item in responsejson: |
| 632 | if item[ "priority" ] == int( priority ) and item[ "state" ] == "ADDED": |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 633 | isAdded = main.TRUE |
| 634 | |
| 635 | utilities.assert_equals( expect=main.TRUE, |
| 636 | actual=isAdded, |
| 637 | onpass="Flow is in Added State", |
| 638 | onfail="Flow is not in Added State" ) |
| 639 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 640 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 641 | Sends a packet using scapy |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 642 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 643 | main.step( "Testing Group by sending packet using Scapy" ) |
| 644 | main.log.info( "Creating host components" ) |
| 645 | main.Scapy.createHostComponent( "h1" ) |
| 646 | main.Scapy.createHostComponent( "h2" ) |
| 647 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 648 | hosts = [ main.h1, main.h2 ] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 649 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 650 | host.startHostCli() |
| 651 | host.startScapy() |
| 652 | host.updateSelf() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 653 | main.log.info( "Constructing Packet" ) |
| 654 | main.h1.buildEther( dst=main.h1.hostMac ) |
| 655 | main.h1.buildIP( dst=main.h1.hostIp ) |
| 656 | main.log.info( "Start Filter on host2" ) |
| 657 | main.h2.startFilter( pktFilter="ether host %s and ip host %s" % ( main.h1.hostMac, main.h1.hostIp ) ) |
| 658 | main.log.info( "sending packet to Host" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 659 | main.h1.sendPacket() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 660 | main.log.info( "Checking filter for our packet" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 661 | stepResultH2 = main.h2.checkFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 662 | |
| 663 | if stepResultH2: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 664 | main.log.info( "Packet : %s" % main.h2.readPackets() ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 665 | else: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 666 | main.h2.killFilter() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 667 | |
| 668 | main.log.info( "Clean up host components" ) |
| 669 | for host in hosts: |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 670 | host.stopScapy() |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 671 | main.Mininet1.removeHostComponent( "h1" ) |
| 672 | main.Mininet1.removeHostComponent( "h2" ) |
| 673 | |
| 674 | utilities.assert_equals( expect=main.TRUE, |
| 675 | actual=stepResultH2, |
| 676 | onpass="Packet sent to port 1 is received at port 2 successfully!!!", |
| 677 | onfail="Failure!!!Packet sent to port 1 is not received at port 2" ) |
| 678 | |
| 679 | def CASE8( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 680 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 681 | Deleting the Group and Flow |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 682 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 683 | import json |
| 684 | import time |
| 685 | respFlowId = 1 |
| 686 | |
| 687 | main.case( "Delete the Group and Flow added through Rest api " ) |
| 688 | main.step( "Deleting Group and Flows" ) |
| 689 | |
| 690 | #Getting Flow ID |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 691 | response = main.ONOSrest.getFlows( deviceId=deviceId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 692 | responsejson = json.loads( response ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 693 | for item in responsejson: |
| 694 | if item[ "priority" ] == int( priority ): |
| 695 | respFlowId = item[ "id" ] |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 696 | |
| 697 | main.step( "Deleting the created flow by deviceId and flowId" ) |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 698 | flowResponse = main.ONOSrest.removeFlow( deviceId=deviceId, |
| 699 | flowId=respFlowId ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 700 | |
| 701 | utilities.assert_equals( expect=main.TRUE, |
| 702 | actual=flowResponse, |
| 703 | onpass="Deleting flow is successful!!!", |
| 704 | onfail="Deleting flow is failure!!!" ) |
| 705 | |
| 706 | # Giving ONOS time to delete the flow |
| 707 | time.sleep( main.delFlowSleep ) |
| 708 | |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 709 | groupResponse = main.ONOSrest.removeGroup( deviceId=deviceId, |
| 710 | appCookie=appCookie ) |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 711 | |
| 712 | utilities.assert_equals( expect=main.TRUE, |
| 713 | actual=groupResponse, |
| 714 | onpass="Deleting Group is successful!!!", |
| 715 | onfail="Deleting Group is failure!!!" ) |
| 716 | |
| 717 | # Giving ONOS time to delete the group |
| 718 | time.sleep( main.delGroupSleep ) |
| 719 | |
| 720 | def CASE100( self, main ): |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 721 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 722 | Report errors/warnings/exceptions |
Jon Hall | 602d0a7 | 2017-05-24 16:06:53 -0700 | [diff] [blame] | 723 | """ |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 724 | main.log.info( "Error report: \n" ) |
| 725 | main.ONOSbench.logReport( main.ONOSip[ 0 ], |
| 726 | [ "INFO", |
| 727 | "FOLLOWER", |
| 728 | "WARN", |
| 729 | "flow", |
| 730 | "group", |
| 731 | "ERROR", |
| 732 | "Except" ], |
| 733 | "s" ) |