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