Jon Hall | 32c90f3 | 2021-06-24 16:32:44 -0700 | [diff] [blame] | 1 | class SRpairedLeaves: |
| 2 | def __init__( self ): |
| 3 | self.default = '' |
| 4 | |
| 5 | def CASE1( self, main ): |
| 6 | """ |
| 7 | Connect to Pod |
| 8 | Check host dataplane connectivity |
| 9 | Collect logs and analyze results |
| 10 | """ |
| 11 | try: |
| 12 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 13 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 14 | import datetime |
| 15 | import json |
| 16 | except ImportError as e: |
| 17 | main.log.exception( "SRStagingTest not found. Exiting the test" ) |
| 18 | main.cleanAndExit() |
| 19 | try: |
| 20 | main.funcs |
| 21 | except ( NameError, AttributeError ): |
| 22 | main.funcs = SRStagingTest() |
| 23 | |
| 24 | try: |
| 25 | main.log.debug( "loading parser script" ) |
| 26 | import tests.USECASE.SegmentRouting.SRStaging.dependencies.log_breakdown as logParser |
| 27 | except ImportError as e: |
| 28 | main.log.exception( "Error running script" ) |
| 29 | descPrefix = "Host Connectivity" |
| 30 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 31 | main.cfgName = 'CASE001' |
| 32 | main.funcs.setupTest( main, |
| 33 | topology='0x2', |
| 34 | onosNodes=3, |
| 35 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 36 | switches = int( main.params[ 'TOPO' ][ 'switchNum' ] ) |
| 37 | links = int( main.params[ 'TOPO' ][ 'linkNum' ] ) |
| 38 | hosts = [ 'h1', 'h2', 'h3', 'mgmt' ] |
| 39 | run.verifyTopology( main, switches, links, main.Cluster.numCtrls ) |
Jon Hall | 32c90f3 | 2021-06-24 16:32:44 -0700 | [diff] [blame] | 40 | run.verifyPing( main, hosts, hosts ) |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 41 | main.funcs.cleanup( main ) |
Jon Hall | 32c90f3 | 2021-06-24 16:32:44 -0700 | [diff] [blame] | 42 | |
| 43 | def CASE2( self, main ): |
| 44 | """ |
| 45 | Connect to Pod |
| 46 | Check host to gateway connectivity |
| 47 | Collect logs and analyze results |
| 48 | """ |
| 49 | try: |
| 50 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 51 | import json |
| 52 | except ImportError: |
| 53 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 54 | main.cleanAndExit() |
| 55 | try: |
| 56 | main.funcs |
| 57 | except ( NameError, AttributeError ): |
| 58 | main.funcs = SRStagingTest() |
| 59 | |
| 60 | descPrefix = "Host to gateway connectivity" |
| 61 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 62 | main.funcs.setupTest( main, |
| 63 | topology='0x2', |
| 64 | onosNodes=3, |
| 65 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 66 | run.pingAllFabricIntfs( main, hosts, dumpFlows=False ) |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 67 | main.funcs.cleanup( main ) |
| 68 | |
| 69 | def CASE101( self, main ): |
| 70 | """ |
| 71 | Connect to Pod |
| 72 | Create Flow between 2 dual homed hosts |
| 73 | Kill link from leaf to src host used by flow |
| 74 | Verify flow continues using other link |
| 75 | Collect logs and analyze results |
| 76 | """ |
| 77 | try: |
| 78 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 79 | import json |
| 80 | except ImportError: |
| 81 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 82 | main.cleanAndExit() |
| 83 | try: |
| 84 | main.funcs |
| 85 | except ( NameError, AttributeError ): |
| 86 | main.funcs = SRStagingTest() |
| 87 | |
| 88 | descPrefix = "CASE101-Source-Link" |
| 89 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 90 | main.funcs.setupTest( main, |
| 91 | topology='0x2', |
| 92 | onosNodes=3, |
| 93 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 94 | srcComponent = getattr( main, 'Compute1' ) |
| 95 | dstComponent = getattr( main, 'Compute2' ) |
| 96 | |
| 97 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 98 | shortDesc = descPrefix + "-Failure" |
| 99 | longDesc = "%s Failure: Bring down port with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 100 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 101 | longDesc, stat='packetsReceived', bidirectional=False ) |
| 102 | # TODO: These should be "bidirectional" names |
| 103 | shortDesc = descPrefix + "-Recovery" |
| 104 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 105 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 106 | bidirectional=False ) |
| 107 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 108 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 109 | main.funcs.cleanup( main ) |
| 110 | |
| 111 | def CASE102( self, main ): |
| 112 | """ |
| 113 | Connect to Pod |
| 114 | Create Flow between 2 dual homed hosts |
| 115 | Kill link from leaf to dst host used by flow |
| 116 | Verify flow continues using other link |
| 117 | Collect logs and analyze results |
| 118 | """ |
| 119 | try: |
| 120 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 121 | import json |
| 122 | except ImportError: |
| 123 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 124 | main.cleanAndExit() |
| 125 | try: |
| 126 | main.funcs |
| 127 | except ( NameError, AttributeError ): |
| 128 | main.funcs = SRStagingTest() |
| 129 | |
| 130 | descPrefix = "CASE102-Destination-Link" |
| 131 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 132 | main.funcs.setupTest( main, |
| 133 | topology='0x2', |
| 134 | onosNodes=3, |
| 135 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 136 | srcComponent = getattr( main, 'Compute2' ) |
| 137 | dstComponent = getattr( main, 'Compute1' ) |
| 138 | |
| 139 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 140 | shortDesc = descPrefix + "-Failure" |
| 141 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 142 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 143 | longDesc, stat='packetsSent', bidirectional=False ) |
| 144 | # TODO: These should be "bidirectional" names |
| 145 | shortDesc = descPrefix + "-Recovery" |
| 146 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 147 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 148 | bidirectional=False ) |
| 149 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 150 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 151 | main.funcs.cleanup( main ) |
| 152 | |
| 153 | def CASE103( self, main ): |
| 154 | """ |
| 155 | Connect to Pod |
| 156 | Create Flow between 1 dual homed host and 1 single homed host |
| 157 | Kill link from leaf to src host used by flow |
| 158 | Verify flow continues using other link |
| 159 | Collect logs and analyze results |
| 160 | """ |
| 161 | try: |
| 162 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 163 | import json |
| 164 | except ImportError: |
| 165 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 166 | main.cleanAndExit() |
| 167 | try: |
| 168 | main.funcs |
| 169 | except ( NameError, AttributeError ): |
| 170 | main.funcs = SRStagingTest() |
| 171 | |
| 172 | descPrefix = "CASE103-Source-Link" |
| 173 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 174 | main.funcs.setupTest( main, |
| 175 | topology='0x2', |
| 176 | onosNodes=3, |
| 177 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 178 | srcComponent = getattr( main, 'Compute1' ) |
| 179 | dstComponent = getattr( main, 'Compute3' ) |
| 180 | |
| 181 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 182 | shortDesc = descPrefix + "-Failure" |
| 183 | longDesc = "%s Failure: Bring down port with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 184 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 185 | longDesc, stat='packetsReceived', bidirectional=False ) |
| 186 | # TODO: These should be "bidirectional" names |
| 187 | shortDesc = descPrefix + "-Recovery" |
| 188 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 189 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 190 | bidirectional=False ) |
| 191 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 192 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 193 | main.funcs.cleanup( main ) |
| 194 | |
| 195 | def CASE104( self, main ): |
| 196 | """ |
| 197 | Connect to Pod |
| 198 | Create Flow between 1 dual homed host and 1 single homed host |
| 199 | Kill link from leaf to dst host used by flow |
| 200 | Verify flow continues using other link |
| 201 | Collect logs and analyze results |
| 202 | """ |
| 203 | try: |
| 204 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 205 | import json |
| 206 | except ImportError: |
| 207 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 208 | main.cleanAndExit() |
| 209 | try: |
| 210 | main.funcs |
| 211 | except ( NameError, AttributeError ): |
| 212 | main.funcs = SRStagingTest() |
| 213 | |
| 214 | descPrefix = "CASE104-Destination-Link" |
| 215 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 216 | main.funcs.setupTest( main, |
| 217 | topology='0x2', |
| 218 | onosNodes=3, |
| 219 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 220 | srcComponent = getattr( main, 'Compute3' ) |
| 221 | dstComponent = getattr( main, 'Compute1' ) |
| 222 | |
| 223 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 224 | shortDesc = descPrefix + "-Failure" |
| 225 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 226 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 227 | longDesc, stat='packetsSent', bidirectional=False ) |
| 228 | # TODO: These should be "bidirectional" names |
| 229 | shortDesc = descPrefix + "-Recovery" |
| 230 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 231 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 232 | bidirectional=False ) |
| 233 | # Cleanup |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 234 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 235 | main.funcs.cleanup( main ) |
| 236 | |
| 237 | def CASE201( self, main ): |
| 238 | """ |
| 239 | Connect to Pod |
| 240 | Create Flow between 2 dual homed hosts |
| 241 | Kill the leaf that traffic first flows into |
| 242 | Verify flow continues using other link |
| 243 | Collect logs and analyze results |
| 244 | """ |
| 245 | try: |
| 246 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 247 | import json |
| 248 | except ImportError: |
| 249 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 250 | main.cleanAndExit() |
| 251 | try: |
| 252 | main.funcs |
| 253 | except ( NameError, AttributeError ): |
| 254 | main.funcs = SRStagingTest() |
| 255 | |
| 256 | descPrefix = "CASE201-Source-Leaf" |
| 257 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 258 | main.funcs.setupTest( main, |
| 259 | topology='0x2', |
| 260 | onosNodes=3, |
| 261 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 262 | srcComponent = getattr( main, 'Compute1' ) |
| 263 | dstComponent = getattr( main, 'Compute2' ) |
| 264 | |
| 265 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 266 | shortDescFailure = descPrefix + "-Failure" |
| 267 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 268 | shortDescRecovery = descPrefix + "-Recovery" |
| 269 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 270 | main.funcs.onlReboot( targets, srcComponent, dstComponent, |
| 271 | shortDescFailure, longDescFailure, |
| 272 | shortDescRecovery, longDescRecovery, |
| 273 | stat='packetsReceived', bidirectional=False ) |
| 274 | # Cleanup |
| 275 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 276 | main.funcs.cleanup( main ) |
| 277 | |
| 278 | def CASE202( self, main ): |
| 279 | """ |
| 280 | Connect to Pod |
| 281 | Create Flow between 2 dual homed hosts |
| 282 | Kill the last leaf that traffic flows out of |
| 283 | Verify flow continues using other link |
| 284 | Collect logs and analyze results |
| 285 | """ |
| 286 | try: |
| 287 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 288 | import json |
| 289 | except ImportError: |
| 290 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 291 | main.cleanAndExit() |
| 292 | try: |
| 293 | main.funcs |
| 294 | except ( NameError, AttributeError ): |
| 295 | main.funcs = SRStagingTest() |
| 296 | |
| 297 | descPrefix = "CASE202-Destination-Leaf" |
| 298 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 299 | main.funcs.setupTest( main, |
| 300 | topology='0x2', |
| 301 | onosNodes=3, |
| 302 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 303 | srcComponent = getattr( main, 'Compute1' ) |
| 304 | dstComponent = getattr( main, 'Compute2' ) |
| 305 | |
| 306 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 307 | shortDescFailure = descPrefix + "-Failure" |
| 308 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 309 | shortDescRecovery = descPrefix + "-Recovery" |
| 310 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 311 | main.funcs.onlReboot( targets, srcComponent, dstComponent, |
| 312 | shortDescFailure, longDescFailure, |
| 313 | shortDescRecovery, longDescRecovery, |
| 314 | stat='packetsSent', bidirectional=False ) |
| 315 | # Cleanup |
| 316 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 317 | main.funcs.cleanup( main ) |
| 318 | |
| 319 | def CASE203( self, main ): |
| 320 | """ |
| 321 | Connect to Pod |
| 322 | Create Flow between 1 dual homed host and 1 single homed host |
| 323 | Kill the leaf that traffic first flows into |
| 324 | Verify flow continues using other link |
| 325 | Collect logs and analyze results |
| 326 | """ |
| 327 | try: |
| 328 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 329 | import json |
| 330 | except ImportError: |
| 331 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 332 | main.cleanAndExit() |
| 333 | try: |
| 334 | main.funcs |
| 335 | except ( NameError, AttributeError ): |
| 336 | main.funcs = SRStagingTest() |
| 337 | |
| 338 | descPrefix = "CASE203-Source-Leaf" |
| 339 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 340 | main.funcs.setupTest( main, |
| 341 | topology='0x2', |
| 342 | onosNodes=3, |
| 343 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 344 | srcComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 345 | dstComponent = getattr( main, 'Compute3' ) |
| 346 | |
| 347 | targets = main.funcs.getHostConnections( main, srcComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 348 | shortDescFailure = descPrefix + "-Failure" |
| 349 | longDescFailure = "%s Failure: Bring down switch with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 350 | shortDescRecovery = descPrefix + "-Recovery" |
| 351 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 352 | main.funcs.onlReboot( targets, srcComponentList, dstComponent, |
| 353 | shortDescFailure, longDescFailure, |
| 354 | shortDescRecovery, longDescRecovery, |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 355 | stat='packetsReceived', bidirectional=False, |
| 356 | singleFlow=True ) |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 357 | # Cleanup |
| 358 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 359 | main.funcs.cleanup( main ) |
| 360 | |
| 361 | def CASE204( self, main ): |
| 362 | """ |
| 363 | Connect to Pod |
| 364 | Create Flow between 1 dual homed host and 1 single homed host |
| 365 | Kill the last leaf that traffic flows out of |
| 366 | Verify flow continues using other link |
| 367 | Collect logs and analyze results |
| 368 | """ |
| 369 | try: |
| 370 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 371 | import json |
| 372 | except ImportError: |
| 373 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 374 | main.cleanAndExit() |
| 375 | try: |
| 376 | main.funcs |
| 377 | except ( NameError, AttributeError ): |
| 378 | main.funcs = SRStagingTest() |
| 379 | |
| 380 | descPrefix = "CASE204-Destination-Leaf" |
| 381 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 382 | main.funcs.setupTest( main, |
| 383 | topology='0x2', |
| 384 | onosNodes=3, |
| 385 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 386 | srcComponent = getattr( main, 'Compute3' ) |
| 387 | dstComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 388 | |
| 389 | targets = main.funcs.getHostConnections( main, dstComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 390 | shortDescFailure = descPrefix + "-Failure" |
| 391 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 392 | shortDescRecovery = descPrefix + "-Recovery" |
| 393 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 394 | main.funcs.onlReboot( targets, srcComponent, dstComponentList, |
| 395 | shortDescFailure, longDescFailure, |
| 396 | shortDescRecovery, longDescRecovery, |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 397 | stat='packetsSent', bidirectional=False, |
| 398 | singleFlow=True ) |
| 399 | # Cleanup |
| 400 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 401 | main.funcs.cleanup( main ) |
| 402 | |
| 403 | def CASE205( self, main ): |
| 404 | """ |
| 405 | Connect to Pod |
| 406 | Create Flow between 2 dual homed hosts |
| 407 | Kill the leaf that traffic first flows into |
| 408 | Verify flow continues using other link |
| 409 | Collect logs and analyze results |
| 410 | """ |
| 411 | try: |
| 412 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 413 | import json |
| 414 | except ImportError: |
| 415 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 416 | main.cleanAndExit() |
| 417 | try: |
| 418 | main.funcs |
| 419 | except ( NameError, AttributeError ): |
| 420 | main.funcs = SRStagingTest() |
| 421 | |
| 422 | descPrefix = "CASE205-Source-Leaf" |
| 423 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 424 | main.funcs.setupTest( main, |
| 425 | topology='0x2', |
| 426 | onosNodes=3, |
| 427 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 428 | srcComponent = getattr( main, 'Compute1' ) |
| 429 | dstComponent = getattr( main, 'Compute2' ) |
| 430 | |
| 431 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 432 | shortDescFailure = descPrefix + "-Failure" |
| 433 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 434 | shortDescRecovery = descPrefix + "-Recovery" |
| 435 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 436 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponent, |
| 437 | shortDescFailure, longDescFailure, |
| 438 | shortDescRecovery, longDescRecovery, |
| 439 | stat='packetsReceived', bidirectional=False ) |
| 440 | # Cleanup |
| 441 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 442 | main.funcs.cleanup( main ) |
| 443 | |
| 444 | def CASE206( self, main ): |
| 445 | """ |
| 446 | Connect to Pod |
| 447 | Create Flow between 2 dual homed hosts |
| 448 | Kill the last leaf that traffic flows out of |
| 449 | Verify flow continues using other link |
| 450 | Collect logs and analyze results |
| 451 | """ |
| 452 | try: |
| 453 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 454 | import json |
| 455 | except ImportError: |
| 456 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 457 | main.cleanAndExit() |
| 458 | try: |
| 459 | main.funcs |
| 460 | except ( NameError, AttributeError ): |
| 461 | main.funcs = SRStagingTest() |
| 462 | |
| 463 | descPrefix = "CASE206-Destination-Leaf" |
| 464 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 465 | main.funcs.setupTest( main, |
| 466 | topology='0x2', |
| 467 | onosNodes=3, |
| 468 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 469 | srcComponent = getattr( main, 'Compute1' ) |
| 470 | dstComponent = getattr( main, 'Compute2' ) |
| 471 | |
| 472 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 473 | shortDescFailure = descPrefix + "-Failure" |
| 474 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 475 | shortDescRecovery = descPrefix + "-Recovery" |
| 476 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 477 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponent, |
| 478 | shortDescFailure, longDescFailure, |
| 479 | shortDescRecovery, longDescRecovery, |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 480 | stat='packetsSent', bidirectional=False ) |
| 481 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 482 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 483 | main.funcs.cleanup( main ) |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 484 | |
| 485 | def CASE207( self, main ): |
| 486 | """ |
| 487 | Connect to Pod |
| 488 | Create Flow between 1 dual homed host and 1 single homed host |
| 489 | Kill the leaf that traffic first flows into |
| 490 | Verify flow continues using other link |
| 491 | Collect logs and analyze results |
| 492 | """ |
| 493 | try: |
| 494 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 495 | import json |
| 496 | except ImportError: |
| 497 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 498 | main.cleanAndExit() |
| 499 | try: |
| 500 | main.funcs |
| 501 | except ( NameError, AttributeError ): |
| 502 | main.funcs = SRStagingTest() |
| 503 | |
| 504 | descPrefix = "CASE207-Source-Leaf" |
| 505 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 506 | main.funcs.setupTest( main, |
| 507 | topology='0x2', |
| 508 | onosNodes=3, |
| 509 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 510 | srcComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 511 | dstComponent = getattr( main, 'Compute3' ) |
| 512 | |
| 513 | targets = main.funcs.getHostConnections( main, srcComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 514 | shortDescFailure = descPrefix + "-Failure" |
| 515 | longDescFailure = "%s Failure: Bring down switch with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 516 | shortDescRecovery = descPrefix + "-Recovery" |
| 517 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 518 | main.funcs.killSwitchAgent( targets, srcComponentList, dstComponent, |
| 519 | shortDescFailure, longDescFailure, |
| 520 | shortDescRecovery, longDescRecovery, |
| 521 | stat='packetsReceived', bidirectional=False, |
| 522 | singleFlow=True ) |
| 523 | # Cleanup |
| 524 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 525 | main.funcs.cleanup( main ) |
| 526 | |
| 527 | def CASE208( self, main ): |
| 528 | """ |
| 529 | Connect to Pod |
| 530 | Create Flow between 1 dual homed host and 1 single homed host |
| 531 | Kill the last leaf that traffic flows out of |
| 532 | Verify flow continues using other link |
| 533 | Collect logs and analyze results |
| 534 | """ |
| 535 | try: |
| 536 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 537 | import json |
| 538 | except ImportError: |
| 539 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 540 | main.cleanAndExit() |
| 541 | try: |
| 542 | main.funcs |
| 543 | except ( NameError, AttributeError ): |
| 544 | main.funcs = SRStagingTest() |
| 545 | |
| 546 | descPrefix = "CASE208-Destination-Leaf" |
| 547 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 548 | main.funcs.setupTest( main, |
| 549 | topology='0x2', |
| 550 | onosNodes=3, |
| 551 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 552 | srcComponent = getattr( main, 'Compute3' ) |
| 553 | dstComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 554 | |
| 555 | targets = main.funcs.getHostConnections( main, dstComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 556 | shortDescFailure = descPrefix + "-Failure" |
| 557 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 558 | shortDescRecovery = descPrefix + "-Recovery" |
| 559 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 560 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponentList, |
| 561 | shortDescFailure, longDescFailure, |
| 562 | shortDescRecovery, longDescRecovery, |
| 563 | stat='packetsSent', bidirectional=False, |
| 564 | singleFlow=True ) |
| 565 | # Cleanup |
| 566 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 567 | main.funcs.cleanup( main ) |
Jon Hall | 62ab675 | 2021-08-22 16:47:43 -0700 | [diff] [blame] | 568 | |
| 569 | def CASE301( self, main ): |
| 570 | """ |
| 571 | Connect to Pod |
| 572 | Setup static route to public internet via mgmt |
| 573 | Ping public ip |
| 574 | chech which link the ICMP traffic is going to |
| 575 | Kill that link |
| 576 | Verify flow continues using other link |
| 577 | Restore link |
| 578 | verify traffic still flows |
| 579 | Collect logs and analyze results |
| 580 | """ |
| 581 | try: |
| 582 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 583 | import json |
| 584 | import re |
| 585 | except ImportError: |
| 586 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 587 | main.cleanAndExit() |
| 588 | try: |
| 589 | main.funcs |
| 590 | except ( NameError, AttributeError ): |
| 591 | main.funcs = SRStagingTest() |
| 592 | |
| 593 | descPrefix = "CASE301-Upstream-Link" |
| 594 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 595 | main.funcs.setupTest( main, |
| 596 | topology='0x2', |
| 597 | onosNodes=3, |
| 598 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 599 | |
| 600 | # TODO Route ADD |
| 601 | dstIp = "8.8.8.8" |
| 602 | route = "%s/32" % dstIp |
| 603 | """ |
| 604 | Try this on the host: |
| 605 | ip route add 8.8.8.8/32 via <fabric interface ip> |
| 606 | and this in ONOS: |
| 607 | route-add 8.8.8.8/32 via <mgmt server fabric ip |
| 608 | """ |
| 609 | |
| 610 | srcComponent = getattr( main, 'Compute1' ) |
| 611 | nextHopComponent = getattr( main, 'ManagmentServer' ) |
| 612 | |
| 613 | # Add route in host to outside host via gateway ip |
| 614 | srcIface = srcComponent.interfaces[0].get( 'name' ) |
| 615 | srcIp = srcComponent.getIPAddress( iface=srcIface ) |
| 616 | hostsJson = json.loads( main.Cluster.active( 0 ).hosts() ) |
| 617 | netcfgJson = json.loads( main.Cluster.active( 0 ).getNetCfg( subjectClass='ports') ) |
| 618 | ips = [] |
| 619 | fabricIntfIp = None |
| 620 | for obj in hostsJson: |
| 621 | if srcIp in obj['ipAddresses']: |
| 622 | for location in obj['locations']: |
| 623 | main.log.debug( location ) |
| 624 | did = location['elementId'].encode( 'utf-8' ) |
| 625 | port = location['port'].encode( 'utf-8' ) |
| 626 | m = re.search( '\((\d+)\)', port ) |
| 627 | if m: |
| 628 | port = m.group(1) |
| 629 | portId = "%s/%s" % ( did, port ) |
| 630 | # Lookup ip assigned to this network port |
| 631 | ips.extend( [ x.encode( 'utf-8' ) for x in netcfgJson[ portId ][ 'interfaces' ][0][ 'ips' ] ] ) |
| 632 | ips = set( ips ) |
| 633 | ipRE = r'(\d+\.\d+\.\d+\.\d+)/\d+|([\w,:]*)/\d+' |
| 634 | for ip in ips: |
| 635 | ipMatch = re.search( ipRE, ip ) |
| 636 | if ipMatch: |
| 637 | fabricIntfIp = ipMatch.group(1) |
| 638 | main.log.debug( "Found %s as gateway ip for %s" % ( fabricIntfIp, srcComponent.shortName ) ) |
| 639 | # FIXME: How to chose the correct one if there are multiple? look at subnets |
Jon Hall | d3ab356 | 2021-08-25 16:11:54 -0700 | [diff] [blame] | 640 | srcComponent.addRouteToHost( route, fabricIntfIp, srcIface, sudoRequired=True, purgeOnDisconnect=True ) |
Jon Hall | 62ab675 | 2021-08-22 16:47:43 -0700 | [diff] [blame] | 641 | main.log.debug( srcComponent.getRoutes() ) |
| 642 | |
| 643 | # Add route in ONOS |
| 644 | nextHopIface = nextHopComponent.interfaces[0].get( 'name' ) |
| 645 | nextHopIp = nextHopComponent.getIPAddress( iface=nextHopIface ) |
| 646 | main.Cluster.active( 0 ).routeAdd( route, nextHopIp ) |
| 647 | main.log.debug( main.Cluster.active( 0 ).routes() ) |
| 648 | |
| 649 | |
| 650 | |
| 651 | #### |
| 652 | targets = main.funcs.getHostConnections( main, nextHopComponent ) |
| 653 | shortDesc = descPrefix + "-Failure" |
| 654 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, route ) |
| 655 | #TODO: Option to just do ping |
| 656 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, nextHopComponent, shortDesc, |
| 657 | longDesc, stat='packetsSent', bidirectional=False, |
| 658 | pingOnly=True, dstIp=dstIp ) |
| 659 | shortDesc = descPrefix + "-Recovery" |
| 660 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 661 | main.funcs.linkUp( killDevice, killPort, srcComponent, nextHopComponent, shortDesc, longDesc, |
| 662 | bidirectional=False, pingOnly=True, dstIp=dstIp ) |
| 663 | |
| 664 | # Remove route in ONOS |
| 665 | main.Cluster.active( 0 ).routeRemove( route, nextHopIp ) |
| 666 | main.log.debug( main.Cluster.active( 0 ).routes() ) |
| 667 | # Remove route on host |
| 668 | srcComponent.deleteRoute( route, fabricIntfIp, srcIface, sudoRequired=True ) |
| 669 | main.log.debug( srcComponent.getRoutes() ) |
| 670 | # Cleanup |
| 671 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 672 | main.funcs.cleanup( main ) |
Yi Tseng | f459571 | 2021-08-27 14:10:58 -0700 | [diff] [blame^] | 673 | |
| 674 | def CASE302 ( self, main ): |
| 675 | """ |
| 676 | Send ping packets from one host to another host and check flows from DeepInsight. |
| 677 | """ |
| 678 | |
| 679 | try: |
| 680 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 681 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 682 | from core import utilities |
| 683 | import time |
| 684 | import socket |
| 685 | except ImportError as e: |
| 686 | main.log.exception( "SRStagingTest not found. Exiting the test" ) |
| 687 | main.cleanAndExit() |
| 688 | try: |
| 689 | main.funcs |
| 690 | except ( NameError, AttributeError ): |
| 691 | main.funcs = SRStagingTest() |
| 692 | |
| 693 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 694 | main.cfgName = 'CASE302' |
| 695 | main.funcs.setupTest( main, |
| 696 | topology='0x2', |
| 697 | onosNodes=3, |
| 698 | description="INT flow report tests on %s POD" % ( pod ) ) |
| 699 | startTimeMs = ( time.time() - 5 ) * 1000 |
| 700 | run.verifyPing( main, ['h1'], ['h2'] ) |
| 701 | endTimeMs = ( time.time() + 5 ) * 1000 |
| 702 | main.step( "Checking flow report from DeepInsight" ) |
| 703 | |
| 704 | def getFiveTupleCount(*args, **kwargs): |
| 705 | flows = main.DeepInsight.getFlows( |
| 706 | startTimeMs=startTimeMs, |
| 707 | endTimeMs=endTimeMs, |
| 708 | srcIp=main.h1.interfaces[0]['ips'][0], |
| 709 | dstIp=main.h2.interfaces[0]['ips'][0], |
| 710 | ipProto=socket.IPPROTO_ICMP |
| 711 | ) |
| 712 | if "FiveTupleCount" in flows: |
| 713 | return flows["FiveTupleCount"] |
| 714 | else: |
| 715 | return 0 |
| 716 | |
| 717 | # Need to wait few seconds until DeepInsight database updated. |
| 718 | fiveTupleCount = utilities.retry( |
| 719 | f=getFiveTupleCount, |
| 720 | retValue=0, |
| 721 | attempts=60, |
| 722 | ) |
| 723 | |
| 724 | utilities.assert_equals( |
| 725 | expect=1, actual=fiveTupleCount, |
| 726 | onpass="Got 1 flow report from DeepInsight as expected.", |
| 727 | onfail="Got %d flow reports from DeepInsight (expect 1)" % ( fiveTupleCount ) |
| 728 | ) |
| 729 | |
| 730 | main.funcs.cleanup( main ) |