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 |
Jon Hall | c03ade9 | 2021-09-13 17:19:10 -0700 | [diff] [blame] | 51 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
Jon Hall | 32c90f3 | 2021-06-24 16:32:44 -0700 | [diff] [blame] | 52 | import json |
| 53 | except ImportError: |
| 54 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 55 | main.cleanAndExit() |
| 56 | try: |
| 57 | main.funcs |
| 58 | except ( NameError, AttributeError ): |
| 59 | main.funcs = SRStagingTest() |
| 60 | |
| 61 | descPrefix = "Host to gateway connectivity" |
| 62 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 63 | main.funcs.setupTest( main, |
| 64 | topology='0x2', |
| 65 | onosNodes=3, |
| 66 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
Jon Hall | c03ade9 | 2021-09-13 17:19:10 -0700 | [diff] [blame] | 67 | hosts = [ 'h1', 'h2', 'h3', 'mgmt' ] |
Jon Hall | 32c90f3 | 2021-06-24 16:32:44 -0700 | [diff] [blame] | 68 | run.pingAllFabricIntfs( main, hosts, dumpFlows=False ) |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 69 | main.funcs.cleanup( main ) |
| 70 | |
| 71 | def CASE101( self, main ): |
| 72 | """ |
| 73 | Connect to Pod |
| 74 | Create Flow between 2 dual homed hosts |
| 75 | Kill link from leaf to src host used by flow |
| 76 | Verify flow continues using other link |
| 77 | Collect logs and analyze results |
| 78 | """ |
| 79 | try: |
| 80 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 81 | import json |
| 82 | except ImportError: |
| 83 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 84 | main.cleanAndExit() |
| 85 | try: |
| 86 | main.funcs |
| 87 | except ( NameError, AttributeError ): |
| 88 | main.funcs = SRStagingTest() |
| 89 | |
| 90 | descPrefix = "CASE101-Source-Link" |
| 91 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 92 | main.funcs.setupTest( main, |
| 93 | topology='0x2', |
| 94 | onosNodes=3, |
| 95 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 96 | srcComponent = getattr( main, 'Compute1' ) |
| 97 | dstComponent = getattr( main, 'Compute2' ) |
| 98 | |
| 99 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 100 | shortDesc = descPrefix + "-Failure" |
| 101 | longDesc = "%s Failure: Bring down port with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 102 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 103 | longDesc, stat='packetsReceived', bidirectional=False ) |
| 104 | # TODO: These should be "bidirectional" names |
| 105 | shortDesc = descPrefix + "-Recovery" |
| 106 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 107 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 108 | bidirectional=False ) |
| 109 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 110 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 111 | main.funcs.cleanup( main ) |
| 112 | |
| 113 | def CASE102( self, main ): |
| 114 | """ |
| 115 | Connect to Pod |
| 116 | Create Flow between 2 dual homed hosts |
| 117 | Kill link from leaf to dst host used by flow |
| 118 | Verify flow continues using other link |
| 119 | Collect logs and analyze results |
| 120 | """ |
| 121 | try: |
| 122 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 123 | import json |
| 124 | except ImportError: |
| 125 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 126 | main.cleanAndExit() |
| 127 | try: |
| 128 | main.funcs |
| 129 | except ( NameError, AttributeError ): |
| 130 | main.funcs = SRStagingTest() |
| 131 | |
| 132 | descPrefix = "CASE102-Destination-Link" |
| 133 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 134 | main.funcs.setupTest( main, |
| 135 | topology='0x2', |
| 136 | onosNodes=3, |
| 137 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 138 | srcComponent = getattr( main, 'Compute2' ) |
| 139 | dstComponent = getattr( main, 'Compute1' ) |
| 140 | |
| 141 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 142 | shortDesc = descPrefix + "-Failure" |
| 143 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 144 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 145 | longDesc, stat='packetsSent', bidirectional=False ) |
| 146 | # TODO: These should be "bidirectional" names |
| 147 | shortDesc = descPrefix + "-Recovery" |
| 148 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 149 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 150 | bidirectional=False ) |
| 151 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 152 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 153 | main.funcs.cleanup( main ) |
| 154 | |
| 155 | def CASE103( self, main ): |
| 156 | """ |
| 157 | Connect to Pod |
| 158 | Create Flow between 1 dual homed host and 1 single homed host |
| 159 | Kill link from leaf to src host used by flow |
| 160 | Verify flow continues using other link |
| 161 | Collect logs and analyze results |
| 162 | """ |
| 163 | try: |
| 164 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 165 | import json |
| 166 | except ImportError: |
| 167 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 168 | main.cleanAndExit() |
| 169 | try: |
| 170 | main.funcs |
| 171 | except ( NameError, AttributeError ): |
| 172 | main.funcs = SRStagingTest() |
| 173 | |
| 174 | descPrefix = "CASE103-Source-Link" |
| 175 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 176 | main.funcs.setupTest( main, |
| 177 | topology='0x2', |
| 178 | onosNodes=3, |
| 179 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 180 | srcComponent = getattr( main, 'Compute1' ) |
| 181 | dstComponent = getattr( main, 'Compute3' ) |
| 182 | |
| 183 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 184 | shortDesc = descPrefix + "-Failure" |
| 185 | longDesc = "%s Failure: Bring down port with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 186 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 187 | longDesc, stat='packetsReceived', bidirectional=False ) |
| 188 | # TODO: These should be "bidirectional" names |
| 189 | shortDesc = descPrefix + "-Recovery" |
| 190 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 191 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 192 | bidirectional=False ) |
| 193 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 194 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 195 | main.funcs.cleanup( main ) |
| 196 | |
| 197 | def CASE104( self, main ): |
| 198 | """ |
| 199 | Connect to Pod |
| 200 | Create Flow between 1 dual homed host and 1 single homed host |
| 201 | Kill link from leaf to dst host used by flow |
| 202 | Verify flow continues using other link |
| 203 | Collect logs and analyze results |
| 204 | """ |
| 205 | try: |
| 206 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 207 | import json |
| 208 | except ImportError: |
| 209 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 210 | main.cleanAndExit() |
| 211 | try: |
| 212 | main.funcs |
| 213 | except ( NameError, AttributeError ): |
| 214 | main.funcs = SRStagingTest() |
| 215 | |
| 216 | descPrefix = "CASE104-Destination-Link" |
| 217 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 218 | main.funcs.setupTest( main, |
| 219 | topology='0x2', |
| 220 | onosNodes=3, |
| 221 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 222 | srcComponent = getattr( main, 'Compute3' ) |
| 223 | dstComponent = getattr( main, 'Compute1' ) |
| 224 | |
| 225 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 226 | shortDesc = descPrefix + "-Failure" |
| 227 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 228 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, dstComponent, shortDesc, |
| 229 | longDesc, stat='packetsSent', bidirectional=False ) |
| 230 | # TODO: These should be "bidirectional" names |
| 231 | shortDesc = descPrefix + "-Recovery" |
| 232 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 233 | main.funcs.linkUp( killDevice, killPort, srcComponent, dstComponent, shortDesc, longDesc, |
| 234 | bidirectional=False ) |
| 235 | # Cleanup |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 236 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 237 | main.funcs.cleanup( main ) |
| 238 | |
| 239 | def CASE201( self, main ): |
| 240 | """ |
| 241 | Connect to Pod |
| 242 | Create Flow between 2 dual homed hosts |
| 243 | Kill the leaf that traffic first flows into |
| 244 | Verify flow continues using other link |
| 245 | Collect logs and analyze results |
| 246 | """ |
| 247 | try: |
| 248 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 249 | import json |
| 250 | except ImportError: |
| 251 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 252 | main.cleanAndExit() |
| 253 | try: |
| 254 | main.funcs |
| 255 | except ( NameError, AttributeError ): |
| 256 | main.funcs = SRStagingTest() |
| 257 | |
| 258 | descPrefix = "CASE201-Source-Leaf" |
| 259 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 260 | main.funcs.setupTest( main, |
| 261 | topology='0x2', |
| 262 | onosNodes=3, |
| 263 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 264 | srcComponent = getattr( main, 'Compute1' ) |
| 265 | dstComponent = getattr( main, 'Compute2' ) |
| 266 | |
| 267 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 268 | shortDescFailure = descPrefix + "-Failure" |
| 269 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 270 | shortDescRecovery = descPrefix + "-Recovery" |
| 271 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 272 | main.funcs.onlReboot( targets, srcComponent, dstComponent, |
| 273 | shortDescFailure, longDescFailure, |
| 274 | shortDescRecovery, longDescRecovery, |
| 275 | stat='packetsReceived', bidirectional=False ) |
| 276 | # Cleanup |
| 277 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 278 | main.funcs.cleanup( main ) |
| 279 | |
| 280 | def CASE202( self, main ): |
| 281 | """ |
| 282 | Connect to Pod |
| 283 | Create Flow between 2 dual homed hosts |
| 284 | Kill the last leaf that traffic flows out of |
| 285 | Verify flow continues using other link |
| 286 | Collect logs and analyze results |
| 287 | """ |
| 288 | try: |
| 289 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 290 | import json |
| 291 | except ImportError: |
| 292 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 293 | main.cleanAndExit() |
| 294 | try: |
| 295 | main.funcs |
| 296 | except ( NameError, AttributeError ): |
| 297 | main.funcs = SRStagingTest() |
| 298 | |
| 299 | descPrefix = "CASE202-Destination-Leaf" |
| 300 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 301 | main.funcs.setupTest( main, |
| 302 | topology='0x2', |
| 303 | onosNodes=3, |
| 304 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 305 | srcComponent = getattr( main, 'Compute1' ) |
| 306 | dstComponent = getattr( main, 'Compute2' ) |
| 307 | |
| 308 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 309 | shortDescFailure = descPrefix + "-Failure" |
| 310 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 311 | shortDescRecovery = descPrefix + "-Recovery" |
| 312 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 313 | main.funcs.onlReboot( targets, srcComponent, dstComponent, |
| 314 | shortDescFailure, longDescFailure, |
| 315 | shortDescRecovery, longDescRecovery, |
| 316 | stat='packetsSent', bidirectional=False ) |
| 317 | # Cleanup |
| 318 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 319 | main.funcs.cleanup( main ) |
| 320 | |
| 321 | def CASE203( self, main ): |
| 322 | """ |
| 323 | Connect to Pod |
| 324 | Create Flow between 1 dual homed host and 1 single homed host |
| 325 | Kill the leaf that traffic first flows into |
| 326 | Verify flow continues using other link |
| 327 | Collect logs and analyze results |
| 328 | """ |
| 329 | try: |
| 330 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 331 | import json |
| 332 | except ImportError: |
| 333 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 334 | main.cleanAndExit() |
| 335 | try: |
| 336 | main.funcs |
| 337 | except ( NameError, AttributeError ): |
| 338 | main.funcs = SRStagingTest() |
| 339 | |
| 340 | descPrefix = "CASE203-Source-Leaf" |
| 341 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 342 | main.funcs.setupTest( main, |
| 343 | topology='0x2', |
| 344 | onosNodes=3, |
| 345 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 346 | srcComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 347 | dstComponent = getattr( main, 'Compute3' ) |
| 348 | |
| 349 | targets = main.funcs.getHostConnections( main, srcComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 350 | shortDescFailure = descPrefix + "-Failure" |
| 351 | longDescFailure = "%s Failure: Bring down switch with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 352 | shortDescRecovery = descPrefix + "-Recovery" |
| 353 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 354 | main.funcs.onlReboot( targets, srcComponentList, dstComponent, |
| 355 | shortDescFailure, longDescFailure, |
| 356 | shortDescRecovery, longDescRecovery, |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 357 | stat='packetsReceived', bidirectional=False, |
| 358 | singleFlow=True ) |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 359 | # Cleanup |
| 360 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 361 | main.funcs.cleanup( main ) |
| 362 | |
| 363 | def CASE204( self, main ): |
| 364 | """ |
| 365 | Connect to Pod |
| 366 | Create Flow between 1 dual homed host and 1 single homed host |
| 367 | Kill the last leaf that traffic flows out of |
| 368 | Verify flow continues using other link |
| 369 | Collect logs and analyze results |
| 370 | """ |
| 371 | try: |
| 372 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 373 | import json |
| 374 | except ImportError: |
| 375 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 376 | main.cleanAndExit() |
| 377 | try: |
| 378 | main.funcs |
| 379 | except ( NameError, AttributeError ): |
| 380 | main.funcs = SRStagingTest() |
| 381 | |
| 382 | descPrefix = "CASE204-Destination-Leaf" |
| 383 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 384 | main.funcs.setupTest( main, |
| 385 | topology='0x2', |
| 386 | onosNodes=3, |
| 387 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 388 | srcComponent = getattr( main, 'Compute3' ) |
| 389 | dstComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 390 | |
| 391 | targets = main.funcs.getHostConnections( main, dstComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 392 | shortDescFailure = descPrefix + "-Failure" |
| 393 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 394 | shortDescRecovery = descPrefix + "-Recovery" |
| 395 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 396 | main.funcs.onlReboot( targets, srcComponent, dstComponentList, |
| 397 | shortDescFailure, longDescFailure, |
| 398 | shortDescRecovery, longDescRecovery, |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 399 | stat='packetsSent', bidirectional=False, |
| 400 | singleFlow=True ) |
| 401 | # Cleanup |
| 402 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 403 | main.funcs.cleanup( main ) |
| 404 | |
| 405 | def CASE205( self, main ): |
| 406 | """ |
| 407 | Connect to Pod |
| 408 | Create Flow between 2 dual homed hosts |
| 409 | Kill the leaf that traffic first flows into |
| 410 | Verify flow continues using other link |
| 411 | Collect logs and analyze results |
| 412 | """ |
| 413 | try: |
| 414 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 415 | import json |
| 416 | except ImportError: |
| 417 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 418 | main.cleanAndExit() |
| 419 | try: |
| 420 | main.funcs |
| 421 | except ( NameError, AttributeError ): |
| 422 | main.funcs = SRStagingTest() |
| 423 | |
| 424 | descPrefix = "CASE205-Source-Leaf" |
| 425 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 426 | main.funcs.setupTest( main, |
| 427 | topology='0x2', |
| 428 | onosNodes=3, |
| 429 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 430 | srcComponent = getattr( main, 'Compute1' ) |
| 431 | dstComponent = getattr( main, 'Compute2' ) |
| 432 | |
| 433 | targets = main.funcs.getHostConnections( main, srcComponent ) |
| 434 | shortDescFailure = descPrefix + "-Failure" |
| 435 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 436 | shortDescRecovery = descPrefix + "-Recovery" |
| 437 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 438 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponent, |
| 439 | shortDescFailure, longDescFailure, |
| 440 | shortDescRecovery, longDescRecovery, |
| 441 | stat='packetsReceived', bidirectional=False ) |
| 442 | # Cleanup |
| 443 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 444 | main.funcs.cleanup( main ) |
| 445 | |
| 446 | def CASE206( self, main ): |
| 447 | """ |
| 448 | Connect to Pod |
| 449 | Create Flow between 2 dual homed hosts |
| 450 | Kill the last leaf that traffic flows out of |
| 451 | Verify flow continues using other link |
| 452 | Collect logs and analyze results |
| 453 | """ |
| 454 | try: |
| 455 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 456 | import json |
| 457 | except ImportError: |
| 458 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 459 | main.cleanAndExit() |
| 460 | try: |
| 461 | main.funcs |
| 462 | except ( NameError, AttributeError ): |
| 463 | main.funcs = SRStagingTest() |
| 464 | |
| 465 | descPrefix = "CASE206-Destination-Leaf" |
| 466 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 467 | main.funcs.setupTest( main, |
| 468 | topology='0x2', |
| 469 | onosNodes=3, |
| 470 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 471 | srcComponent = getattr( main, 'Compute1' ) |
| 472 | dstComponent = getattr( main, 'Compute2' ) |
| 473 | |
| 474 | targets = main.funcs.getHostConnections( main, dstComponent ) |
| 475 | shortDescFailure = descPrefix + "-Failure" |
| 476 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 477 | shortDescRecovery = descPrefix + "-Recovery" |
| 478 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 479 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponent, |
| 480 | shortDescFailure, longDescFailure, |
| 481 | shortDescRecovery, longDescRecovery, |
Jon Hall | 22a3bcf | 2021-07-23 11:40:11 -0700 | [diff] [blame] | 482 | stat='packetsSent', bidirectional=False ) |
| 483 | # Cleanup |
Jon Hall | 66ce22f | 2021-06-30 14:57:40 -0700 | [diff] [blame] | 484 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 485 | main.funcs.cleanup( main ) |
Jon Hall | 49d781c | 2021-07-29 11:23:46 -0700 | [diff] [blame] | 486 | |
| 487 | def CASE207( self, main ): |
| 488 | """ |
| 489 | Connect to Pod |
| 490 | Create Flow between 1 dual homed host and 1 single homed host |
| 491 | Kill the leaf that traffic first flows into |
| 492 | Verify flow continues using other link |
| 493 | Collect logs and analyze results |
| 494 | """ |
| 495 | try: |
| 496 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 497 | import json |
| 498 | except ImportError: |
| 499 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 500 | main.cleanAndExit() |
| 501 | try: |
| 502 | main.funcs |
| 503 | except ( NameError, AttributeError ): |
| 504 | main.funcs = SRStagingTest() |
| 505 | |
| 506 | descPrefix = "CASE207-Source-Leaf" |
| 507 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 508 | main.funcs.setupTest( main, |
| 509 | topology='0x2', |
| 510 | onosNodes=3, |
| 511 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 512 | srcComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 513 | dstComponent = getattr( main, 'Compute3' ) |
| 514 | |
| 515 | targets = main.funcs.getHostConnections( main, srcComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 516 | shortDescFailure = descPrefix + "-Failure" |
| 517 | longDescFailure = "%s Failure: Bring down switch with traffic to %s" % ( descPrefix, dstComponent.name ) |
| 518 | shortDescRecovery = descPrefix + "-Recovery" |
| 519 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 520 | main.funcs.killSwitchAgent( targets, srcComponentList, dstComponent, |
| 521 | shortDescFailure, longDescFailure, |
| 522 | shortDescRecovery, longDescRecovery, |
| 523 | stat='packetsReceived', bidirectional=False, |
| 524 | singleFlow=True ) |
| 525 | # Cleanup |
| 526 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 527 | main.funcs.cleanup( main ) |
| 528 | |
| 529 | def CASE208( self, main ): |
| 530 | """ |
| 531 | Connect to Pod |
| 532 | Create Flow between 1 dual homed host and 1 single homed host |
| 533 | Kill the last leaf that traffic flows out of |
| 534 | Verify flow continues using other link |
| 535 | Collect logs and analyze results |
| 536 | """ |
| 537 | try: |
| 538 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 539 | import json |
| 540 | except ImportError: |
| 541 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 542 | main.cleanAndExit() |
| 543 | try: |
| 544 | main.funcs |
| 545 | except ( NameError, AttributeError ): |
| 546 | main.funcs = SRStagingTest() |
| 547 | |
| 548 | descPrefix = "CASE208-Destination-Leaf" |
| 549 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 550 | main.funcs.setupTest( main, |
| 551 | topology='0x2', |
| 552 | onosNodes=3, |
| 553 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 554 | srcComponent = getattr( main, 'Compute3' ) |
| 555 | dstComponentList = [ getattr( main, name ) for name in [ 'ManagmentServer', 'Compute1', 'Compute2' ] ] |
| 556 | |
| 557 | targets = main.funcs.getHostConnections( main, dstComponentList, excludedDIDs=[ 'leaf2' ] ) |
| 558 | shortDescFailure = descPrefix + "-Failure" |
| 559 | longDescFailure = "%s Failure: Bring down switch with traffic from %s" % ( descPrefix, srcComponent.name ) |
| 560 | shortDescRecovery = descPrefix + "-Recovery" |
| 561 | longDescRecovery = "%s Recovery: Bring up switch previously killed" % descPrefix |
| 562 | main.funcs.killSwitchAgent( targets, srcComponent, dstComponentList, |
| 563 | shortDescFailure, longDescFailure, |
| 564 | shortDescRecovery, longDescRecovery, |
| 565 | stat='packetsSent', bidirectional=False, |
| 566 | singleFlow=True ) |
| 567 | # Cleanup |
| 568 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 569 | main.funcs.cleanup( main ) |
Jon Hall | 62ab675 | 2021-08-22 16:47:43 -0700 | [diff] [blame] | 570 | |
| 571 | def CASE301( self, main ): |
| 572 | """ |
| 573 | Connect to Pod |
| 574 | Setup static route to public internet via mgmt |
| 575 | Ping public ip |
| 576 | chech which link the ICMP traffic is going to |
| 577 | Kill that link |
| 578 | Verify flow continues using other link |
| 579 | Restore link |
| 580 | verify traffic still flows |
| 581 | Collect logs and analyze results |
| 582 | """ |
| 583 | try: |
| 584 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 585 | import json |
| 586 | import re |
| 587 | except ImportError: |
| 588 | main.log.error( "SRStagingTest not found. Exiting the test" ) |
| 589 | main.cleanAndExit() |
| 590 | try: |
| 591 | main.funcs |
| 592 | except ( NameError, AttributeError ): |
| 593 | main.funcs = SRStagingTest() |
| 594 | |
| 595 | descPrefix = "CASE301-Upstream-Link" |
| 596 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 597 | main.funcs.setupTest( main, |
| 598 | topology='0x2', |
| 599 | onosNodes=3, |
| 600 | description="%s tests on the %s pod" % ( descPrefix, pod ) ) |
| 601 | |
| 602 | # TODO Route ADD |
| 603 | dstIp = "8.8.8.8" |
| 604 | route = "%s/32" % dstIp |
| 605 | """ |
| 606 | Try this on the host: |
| 607 | ip route add 8.8.8.8/32 via <fabric interface ip> |
| 608 | and this in ONOS: |
| 609 | route-add 8.8.8.8/32 via <mgmt server fabric ip |
| 610 | """ |
| 611 | |
| 612 | srcComponent = getattr( main, 'Compute1' ) |
| 613 | nextHopComponent = getattr( main, 'ManagmentServer' ) |
| 614 | |
| 615 | # Add route in host to outside host via gateway ip |
| 616 | srcIface = srcComponent.interfaces[0].get( 'name' ) |
| 617 | srcIp = srcComponent.getIPAddress( iface=srcIface ) |
| 618 | hostsJson = json.loads( main.Cluster.active( 0 ).hosts() ) |
| 619 | netcfgJson = json.loads( main.Cluster.active( 0 ).getNetCfg( subjectClass='ports') ) |
| 620 | ips = [] |
| 621 | fabricIntfIp = None |
| 622 | for obj in hostsJson: |
| 623 | if srcIp in obj['ipAddresses']: |
| 624 | for location in obj['locations']: |
| 625 | main.log.debug( location ) |
| 626 | did = location['elementId'].encode( 'utf-8' ) |
| 627 | port = location['port'].encode( 'utf-8' ) |
| 628 | m = re.search( '\((\d+)\)', port ) |
| 629 | if m: |
| 630 | port = m.group(1) |
| 631 | portId = "%s/%s" % ( did, port ) |
| 632 | # Lookup ip assigned to this network port |
| 633 | ips.extend( [ x.encode( 'utf-8' ) for x in netcfgJson[ portId ][ 'interfaces' ][0][ 'ips' ] ] ) |
| 634 | ips = set( ips ) |
| 635 | ipRE = r'(\d+\.\d+\.\d+\.\d+)/\d+|([\w,:]*)/\d+' |
| 636 | for ip in ips: |
| 637 | ipMatch = re.search( ipRE, ip ) |
| 638 | if ipMatch: |
| 639 | fabricIntfIp = ipMatch.group(1) |
| 640 | main.log.debug( "Found %s as gateway ip for %s" % ( fabricIntfIp, srcComponent.shortName ) ) |
| 641 | # 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] | 642 | srcComponent.addRouteToHost( route, fabricIntfIp, srcIface, sudoRequired=True, purgeOnDisconnect=True ) |
Jon Hall | 62ab675 | 2021-08-22 16:47:43 -0700 | [diff] [blame] | 643 | main.log.debug( srcComponent.getRoutes() ) |
| 644 | |
| 645 | # Add route in ONOS |
| 646 | nextHopIface = nextHopComponent.interfaces[0].get( 'name' ) |
| 647 | nextHopIp = nextHopComponent.getIPAddress( iface=nextHopIface ) |
| 648 | main.Cluster.active( 0 ).routeAdd( route, nextHopIp ) |
| 649 | main.log.debug( main.Cluster.active( 0 ).routes() ) |
| 650 | |
| 651 | |
| 652 | |
| 653 | #### |
| 654 | targets = main.funcs.getHostConnections( main, nextHopComponent ) |
| 655 | shortDesc = descPrefix + "-Failure" |
| 656 | longDesc = "%s Failure: Bring down port with traffic to %s" % ( descPrefix, route ) |
| 657 | #TODO: Option to just do ping |
| 658 | killDevice, killPort = main.funcs.linkDown( targets, srcComponent, nextHopComponent, shortDesc, |
| 659 | longDesc, stat='packetsSent', bidirectional=False, |
| 660 | pingOnly=True, dstIp=dstIp ) |
| 661 | shortDesc = descPrefix + "-Recovery" |
| 662 | longDesc = "%s Recovery: Bring up %s/%s" % ( descPrefix, killDevice, killPort ) |
| 663 | main.funcs.linkUp( killDevice, killPort, srcComponent, nextHopComponent, shortDesc, longDesc, |
| 664 | bidirectional=False, pingOnly=True, dstIp=dstIp ) |
| 665 | |
| 666 | # Remove route in ONOS |
| 667 | main.Cluster.active( 0 ).routeRemove( route, nextHopIp ) |
| 668 | main.log.debug( main.Cluster.active( 0 ).routes() ) |
| 669 | # Remove route on host |
| 670 | srcComponent.deleteRoute( route, fabricIntfIp, srcIface, sudoRequired=True ) |
| 671 | main.log.debug( srcComponent.getRoutes() ) |
| 672 | # Cleanup |
| 673 | main.log.warn( json.dumps( main.downtimeResults, indent=4, sort_keys=True ) ) |
| 674 | main.funcs.cleanup( main ) |
Yi Tseng | f459571 | 2021-08-27 14:10:58 -0700 | [diff] [blame] | 675 | |
| 676 | def CASE302 ( self, main ): |
| 677 | """ |
| 678 | Send ping packets from one host to another host and check flows from DeepInsight. |
| 679 | """ |
| 680 | |
| 681 | try: |
| 682 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 683 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 684 | from core import utilities |
| 685 | import time |
| 686 | import socket |
| 687 | except ImportError as e: |
| 688 | main.log.exception( "SRStagingTest not found. Exiting the test" ) |
| 689 | main.cleanAndExit() |
| 690 | try: |
| 691 | main.funcs |
| 692 | except ( NameError, AttributeError ): |
| 693 | main.funcs = SRStagingTest() |
| 694 | |
| 695 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 696 | main.cfgName = 'CASE302' |
| 697 | main.funcs.setupTest( main, |
| 698 | topology='0x2', |
| 699 | onosNodes=3, |
| 700 | description="INT flow report tests on %s POD" % ( pod ) ) |
| 701 | startTimeMs = ( time.time() - 5 ) * 1000 |
| 702 | run.verifyPing( main, ['h1'], ['h2'] ) |
| 703 | endTimeMs = ( time.time() + 5 ) * 1000 |
| 704 | main.step( "Checking flow report from DeepInsight" ) |
| 705 | |
| 706 | def getFiveTupleCount(*args, **kwargs): |
| 707 | flows = main.DeepInsight.getFlows( |
| 708 | startTimeMs=startTimeMs, |
| 709 | endTimeMs=endTimeMs, |
| 710 | srcIp=main.h1.interfaces[0]['ips'][0], |
| 711 | dstIp=main.h2.interfaces[0]['ips'][0], |
| 712 | ipProto=socket.IPPROTO_ICMP |
| 713 | ) |
| 714 | if "FiveTupleCount" in flows: |
| 715 | return flows["FiveTupleCount"] |
| 716 | else: |
| 717 | return 0 |
| 718 | |
| 719 | # Need to wait few seconds until DeepInsight database updated. |
| 720 | fiveTupleCount = utilities.retry( |
| 721 | f=getFiveTupleCount, |
| 722 | retValue=0, |
| 723 | attempts=60, |
| 724 | ) |
| 725 | |
| 726 | utilities.assert_equals( |
| 727 | expect=1, actual=fiveTupleCount, |
| 728 | onpass="Got 1 flow report from DeepInsight as expected.", |
| 729 | onfail="Got %d flow reports from DeepInsight (expect 1)" % ( fiveTupleCount ) |
| 730 | ) |
| 731 | |
| 732 | main.funcs.cleanup( main ) |
Yi Tseng | decb71f | 2021-09-15 12:36:30 -0700 | [diff] [blame] | 733 | |
| 734 | def CASE303 ( self, main ): |
| 735 | """ |
| 736 | Send a packet with invalid VLAN from one host to another host and check |
| 737 | if DeepInsight receives drop reports. |
| 738 | """ |
| 739 | |
| 740 | try: |
| 741 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 742 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 743 | from core import utilities |
| 744 | import time |
| 745 | import socket |
| 746 | except ImportError as e: |
| 747 | main.log.exception( "SRStagingTest not found. Exiting the test" ) |
| 748 | main.cleanAndExit() |
| 749 | try: |
| 750 | main.funcs |
| 751 | except ( NameError, AttributeError ): |
| 752 | main.funcs = SRStagingTest() |
| 753 | |
| 754 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 755 | main.cfgName = 'CASE303' |
| 756 | main.funcs.setupTest( main, |
| 757 | topology='0x2', |
| 758 | onosNodes=3, |
| 759 | description="INT drop report tests on %s POD with invalid VLAN" % ( pod ) ) |
| 760 | # FIXME: Remove this ping test |
| 761 | # Use this ping function to initialize 'main.h1' and 'main.h2'. |
| 762 | # Same question, maybe there is a better way to initialize them? |
| 763 | run.verifyPing( main, ['h1', 'h2'], ['h2'] ) |
| 764 | main.h1.sudoRequired = True |
| 765 | main.h2.sudoRequired = True |
| 766 | main.h1.startScapy() |
| 767 | main.h2.startScapy() |
| 768 | srcIfaceName = main.h1.interfaces[0]['name'] |
| 769 | dstIfaceName = main.h2.interfaces[0]['name'] |
| 770 | srcMac = main.h1.getMac(srcIfaceName) |
| 771 | dstMac = main.h2.getMac(dstIfaceName) |
| 772 | srcIp = main.h1.getIp(srcIfaceName) |
| 773 | dstIp = main.h2.getIp(dstIfaceName) |
| 774 | srcPort = 2000 |
| 775 | dstPort = 8888 |
| 776 | |
| 777 | main.step( "Sending a packet with invalid VLAN ID from h1" ) |
| 778 | startTimeMs = ( time.time() - 5 ) * 1000 |
| 779 | pkt = '''( |
| 780 | Ether(src='{}', dst='{}') / |
| 781 | Dot1Q(vlan=123) / |
| 782 | IP(src='{}', dst='{}') / |
| 783 | UDP(sport={}, dport={}) / |
| 784 | ('A'*30) |
| 785 | )'''.format(srcMac, dstMac, srcIp, dstIp, srcPort, dstPort) |
| 786 | main.h1.sendPacket( iface=srcIfaceName, packet=pkt ) |
| 787 | endTimeMs = ( time.time() + 5 ) * 1000 |
| 788 | |
| 789 | main.step( "Checking drop report from DeepInsight" ) |
| 790 | def getDropAnomalies(*args, **kwargs): |
| 791 | return main.DeepInsight.getAnomalyRecords( |
| 792 | startTime=startTimeMs, |
| 793 | endTime=endTimeMs, |
| 794 | srcIp=srcIp, |
| 795 | dstIp=dstIp, |
| 796 | srcPort=srcPort, |
| 797 | dstPort=dstPort, |
| 798 | ipProto=socket.IPPROTO_UDP, |
| 799 | anomalyType="packet_drop", |
| 800 | ) |
| 801 | |
| 802 | # Need to wait few seconds until DeepInsight database updated. |
| 803 | dropAnomalies = utilities.retry( |
| 804 | f=getDropAnomalies, |
| 805 | retValue=[[]], |
| 806 | attempts=60, |
| 807 | ) |
| 808 | |
| 809 | utilities.assert_equals( |
| 810 | expect=1, actual=len(dropAnomalies), |
| 811 | onpass="Got 1 drop anomaly from DeepInsight as expected.", |
| 812 | onfail="Got %d drop anomaly from DeepInsight (expect 1)" % ( len(dropAnomalies) ) |
| 813 | ) |
| 814 | |
| 815 | dropAnomaly = dropAnomalies[0] |
| 816 | dropReason = dropAnomaly["DropReason"] |
| 817 | |
| 818 | # DROP_REASON_PORT_VLAN_MAPPING_MISS = 55 |
| 819 | utilities.assert_equals( |
| 820 | expect=55, actual=dropReason, |
| 821 | onpass="Got drop reason '55' as expected.", |
| 822 | onfail="Got drop reason '%d', expect '55'." % ( dropReason ) |
| 823 | ) |
| 824 | |
| 825 | main.h1.stopScapy() |
| 826 | main.h2.stopScapy() |
| 827 | main.funcs.cleanup( main ) |
| 828 | |
| 829 | def CASE304 ( self, main ): |
| 830 | """ |
| 831 | Send a packet with IP TTL value 1 from one host to another host and check |
| 832 | if DeepInsight receives drop reports. |
| 833 | """ |
| 834 | |
| 835 | try: |
| 836 | from tests.USECASE.SegmentRouting.SRStaging.dependencies.SRStagingTest import SRStagingTest |
| 837 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 838 | from core import utilities |
| 839 | import time |
| 840 | import socket |
| 841 | import json |
| 842 | except ImportError as e: |
| 843 | main.log.exception( "SRStagingTest not found. Exiting the test" ) |
| 844 | main.cleanAndExit() |
| 845 | try: |
| 846 | main.funcs |
| 847 | except ( NameError, AttributeError ): |
| 848 | main.funcs = SRStagingTest() |
| 849 | |
| 850 | pod = main.params['GRAPH'].get( 'nodeCluster', "hardware" ) |
| 851 | main.cfgName = 'CASE304' |
| 852 | main.funcs.setupTest( main, |
| 853 | topology='0x2', |
| 854 | onosNodes=3, |
| 855 | description="INT drop report tests with IP TTL 1 on %s POD" % ( pod ) ) |
| 856 | # FIXME: Remove this ping test |
| 857 | # Use this ping function to initialize 'main.h1' and 'main.h3'. |
| 858 | # Is there a better way to initialize them? |
| 859 | run.verifyPing( main, ['h1'], ['h3'] ) |
| 860 | main.h1.sudoRequired = True |
| 861 | main.h3.sudoRequired = True |
| 862 | main.h1.startScapy() |
| 863 | main.h3.startScapy() |
| 864 | srcIfaceName = main.h1.interfaces[0]['name'] |
| 865 | dstIfaceName = main.h3.interfaces[0]['name'] |
| 866 | srcMac = main.h1.getMac(srcIfaceName) |
| 867 | netcfgJson = json.loads( main.Cluster.active( 0 ).getNetCfg( subjectClass='devices') ) |
| 868 | dstMac = netcfgJson["device:leaf2"]["segmentrouting"]["routerMac"] |
| 869 | srcIp = main.h1.getIp(srcIfaceName) |
| 870 | dstIp = main.h3.getIp(dstIfaceName) |
| 871 | srcPort = 3000 |
| 872 | dstPort = 8888 |
| 873 | |
| 874 | main.step( "Sending a packet with IP TTL value 1 from h1" ) |
| 875 | startTimeMs = ( time.time() - 5 ) * 1000 |
| 876 | pkt = '''( |
| 877 | Ether(src='{}', dst='{}') / |
| 878 | IP(src='{}', dst='{}', ttl=1) / |
| 879 | UDP(sport={}, dport={}) / |
| 880 | ('A'*30) |
| 881 | )'''.format(srcMac, dstMac, srcIp, dstIp, srcPort, dstPort) |
| 882 | main.h1.sendPacket( iface=srcIfaceName, packet=pkt ) |
| 883 | endTimeMs = ( time.time() + 5 ) * 1000 |
| 884 | |
| 885 | main.step( "Checking drop report from DeepInsight" ) |
| 886 | def getDropAnomalies(*args, **kwargs): |
| 887 | return main.DeepInsight.getAnomalyRecords( |
| 888 | startTime=startTimeMs, |
| 889 | endTime=endTimeMs, |
| 890 | srcIp=srcIp, |
| 891 | dstIp=dstIp, |
| 892 | srcPort=srcPort, |
| 893 | dstPort=dstPort, |
| 894 | ipProto=socket.IPPROTO_UDP, |
| 895 | anomalyType="packet_drop", |
| 896 | ) |
| 897 | |
| 898 | # Need to wait few seconds until DeepInsight database updated. |
| 899 | dropAnomalies = utilities.retry( |
| 900 | f=getDropAnomalies, |
| 901 | retValue=[[]], |
| 902 | attempts=60, |
| 903 | ) |
| 904 | |
| 905 | utilities.assert_equals( |
| 906 | expect=1, actual=len(dropAnomalies), |
| 907 | onpass="Got 1 drop anomaly from DeepInsight as expected.", |
| 908 | onfail="Got %d drop anomaly from DeepInsight (expect 1)" % ( len(dropAnomalies) ) |
| 909 | ) |
| 910 | |
| 911 | dropAnomaly = dropAnomalies[0] |
| 912 | dropReason = dropAnomaly["DropReason"] |
| 913 | |
| 914 | # DROP_REASON_IP_TTL_ZERO = 26 |
| 915 | utilities.assert_equals( |
| 916 | expect=26, actual=dropReason, |
| 917 | onpass="Got drop reason '26' as expected.", |
| 918 | onfail="Got drop reason '%d', expect 26" % ( dropReason ) |
| 919 | ) |
| 920 | |
| 921 | main.h1.stopScapy() |
| 922 | main.h3.stopScapy() |
| 923 | main.funcs.cleanup( main ) |