Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2017 Open Networking Foundation ( ONF ) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | ( at your option ) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 22 | import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator |
| 23 | |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 24 | class SRDynamicConfTest: |
| 25 | def __init__( self ): |
| 26 | self.default = '' |
| 27 | |
| 28 | @staticmethod |
| 29 | def runTest( main, testIndex, topology, onosNodes, description, vlan=( 0, 0, 0, 0 ) ): |
| 30 | ''' |
| 31 | Tests connectivity for each test case. |
| 32 | Configuration files: |
| 33 | - (0x1, 0x2, 2x2, 2x4).json: device configuration, fed to ONOS before configuration change |
| 34 | - CASE*.json: interface configuration, fed to ONOS before configuration change |
| 35 | - CASE*0.chart: ping chart, used to check connectivity before configuration change. |
| 36 | Shared among same test scenario with different topology. |
| 37 | - CASE*0_after.chart: ping chart, used to check connectivity after configuration change. |
| 38 | Shared among same test scenario with different topology. |
| 39 | Only used when ping chart is updated. |
| 40 | ''' |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 41 | try: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 42 | topo = dict() |
| 43 | # (number of spine switch, number of leaf switch, dual-homed, description, port number of h1) |
| 44 | topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 1 ) |
| 45 | topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 2 ) |
| 46 | topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 3 ) |
| 47 | topo[ '2x4' ] = ( 2, 4, True, '2x4 dual-homed leaf-spine topology', 6 ) |
| 48 | fanout = 4 |
| 49 | switchNames = {} |
| 50 | switchNames[ '2x2' ] = [ "leaf1", "leaf2", "spine101", "spine102" ] |
| 51 | |
| 52 | TAG = 'CASE%d' % testIndex |
| 53 | skipPackage = False |
| 54 | init = False |
| 55 | dualHomed = topo[ topology ][ 2 ] |
| 56 | portNum = topo[ topology ][ 4 ] |
| 57 | defaultIntf = 'bond0' if dualHomed else 'eth0' |
| 58 | |
| 59 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
| 60 | if not hasattr( main, 'apps' ): |
| 61 | init = True |
| 62 | run.initTest( main ) |
| 63 | # Skip onos packaging if the clusrer size stays the same |
| 64 | if not init and onosNodes == main.Cluster.numCtrls: |
| 65 | skipPackage = True |
| 66 | |
| 67 | main.case( '%s, with %s and %d ONOS instance%s' % |
| 68 | ( description, topo[ topology ][ 3 ], onosNodes, 's' if onosNodes > 1 else '' ) ) |
| 69 | main.cfgName = topology |
| 70 | main.Cluster.setRunningNode( onosNodes ) |
| 71 | run.installOnos( main, skipPackage=skipPackage, cliSleep=5 ) |
| 72 | |
| 73 | # Provide common configuration |
| 74 | # TODO: Generate json and chart dynamically, according to topologies and scenarios |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 75 | if main.useBmv2: |
| 76 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 77 | translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame^] | 78 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' ) |
| 79 | if switchPrefix is None: |
| 80 | switchPrefix = '' |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 81 | translator.ofdpaToBmv2( main, switchPrefix=switchPrefix ) |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 82 | else: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 83 | translator.bmv2ToOfdpa( main ) |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame^] | 84 | if not main.persistentSetup: |
| 85 | run.loadJson( main ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 86 | run.loadChart( main ) |
| 87 | |
| 88 | # Provide topology-specific interface configuration |
| 89 | import json |
| 90 | try: |
| 91 | intfCfg = "%s%s%s.json" % ( main.configPath, main.forJson, TAG ) |
| 92 | if main.useBmv2: |
| 93 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 94 | translator.bmv2ToOfdpa( main, intfCfg ) # Try to cleanup if switching between switch types |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 95 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" ) |
| 96 | translator.ofdpaToBmv2( main, switchPrefix=switchPrefix, cfgFile=intfCfg ) |
| 97 | else: |
| 98 | translator.bmv2ToOfdpa( main, intfCfg ) |
| 99 | with open( intfCfg ) as cfg: |
| 100 | main.Cluster.active( 0 ).REST.setNetCfg( json.load( cfg ) ) |
| 101 | except IOError: |
| 102 | # Load default interface configuration |
| 103 | defaultIntfCfg = "%s%s%s_ports.json" % ( main.configPath, main.forJson, topology ) |
| 104 | if main.useBmv2: |
| 105 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 106 | translator.bmv2ToOfdpa( main, defaultIntfCfg ) # Try to cleanup if switching between switch types |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 107 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" ) |
| 108 | translator.ofdpaToBmv2( main, switchPrefix=switchPrefix, cfgFile=defaultIntfCfg ) |
| 109 | else: |
| 110 | translator.bmv2ToOfdpa( main, defaultIntfCfg ) |
| 111 | with open( defaultIntfCfg ) as cfg: |
| 112 | main.Cluster.active( 0 ).REST.setNetCfg( json.load( cfg ) ) |
| 113 | |
| 114 | try: |
| 115 | with open( "%s%sCASE%d.chart" % (main.configPath, main.forChart, testIndex / 10 * 10) ) as chart: |
| 116 | main.pingChart = json.load( chart ) |
| 117 | except IOError: |
| 118 | # Load default chart |
| 119 | with open( "%s%sdefault.chart" % (main.configPath, main.forChart) ) as chart: |
| 120 | main.pingChart = json.load( chart ) |
| 121 | |
| 122 | # Set up topology |
| 123 | if hasattr( main, 'Mininet1' ): |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 124 | run.mnDockerSetup( main ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 125 | # Run the test with mininet topology |
| 126 | mininet_args = ' --spine=%d --leaf=%d --fanout=%d' \ |
| 127 | % ( topo[ topology ][ 0 ], topo[ topology ][ 1 ], fanout ) |
| 128 | if len( vlan ) > 0 : |
| 129 | mininet_args += ' --vlan=%s' % ( ','.join( [ '%d' % vlanId for vlanId in vlan ] ) ) |
| 130 | if topo[ topology ][ 0 ] > 0: |
| 131 | mininet_args += ',0,0,0,0' |
| 132 | if dualHomed: |
| 133 | mininet_args += ' --dual-homed' |
| 134 | if main.useBmv2: |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 135 | mininet_args += ' --switch %s' % main.switchType |
| 136 | main.log.info( "Using %s switch" % main.switchType ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 137 | |
| 138 | run.startMininet( main, 'trellis_fabric.py', args=mininet_args ) |
| 139 | else: |
| 140 | # Run the test with physical devices |
| 141 | run.connectToPhysicalNetwork( main, switchNames[ topology ] ) |
| 142 | |
| 143 | # minFlowCountPerLeaf = 13 + [# of ports] * 5 + [# of hosts] * 2 + [# of vlan ids] |
| 144 | minFlowCountPerLeaf = 13 + ( fanout + topo[ topology ][ 0 ]) * 5 + fanout * 2 + len( set( vlan ) ) |
| 145 | run.checkFlows( main, minFlowCount=minFlowCountPerLeaf * topo[ topology ][ 1 ], sleep=5, dumpflows=False ) |
| 146 | # Check connectivity before changing interface configuration |
| 147 | run.pingAll( main, '%s_Before' % TAG, retryAttempts=2 ) |
| 148 | |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 149 | if main.useBmv2: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 150 | leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( topo[ topology ][ 1 ] ) ] |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 151 | else: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 152 | leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( topo[ topology ][ 1 ] ) ] |
| 153 | for dpid in leaf_dpid: |
| 154 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 155 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 156 | # Testcase-specific interface configuration change |
| 157 | if testIndex / 10 == 1: |
| 158 | # CASE11-14 |
| 159 | if hasattr( main, 'Mininet1' ): |
| 160 | # Assign vlan tag 10 to host h1 |
| 161 | main.Mininet1.assignVLAN( 'h1', 'h1-%s' % defaultIntf, '10' ) |
| 162 | # Update port configuration of port 1 |
| 163 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 164 | [ '10.0.2.254/24', ], tagged=[ 10, ] ) |
| 165 | else: |
| 166 | # TODO: update physical device configuration, same for all test cases |
| 167 | pass |
| 168 | elif testIndex / 10 == 2: |
| 169 | # CASE21-24 |
| 170 | if hasattr( main, 'Mininet1' ): |
| 171 | # Update port configuration of port 1 |
| 172 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 173 | [ '10.0.2.254/24', ], untagged=20 ) |
| 174 | elif testIndex / 10 == 3: |
| 175 | # CASE31-34 |
| 176 | if hasattr( main, 'Mininet1' ): |
| 177 | # Update port configuration of port 1 |
| 178 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 179 | [ '10.0.2.254/24', ], untagged=110 ) |
| 180 | # Update port configuration of port 2 |
| 181 | SRDynamicConfTest.updateIntfCfg( main, portNum + 1, dualHomed, |
| 182 | [ '10.0.2.254/24', ], untagged=110 ) |
| 183 | elif testIndex / 10 == 4: |
| 184 | # CASE41-44 |
| 185 | if hasattr( main, 'Mininet1' ): |
| 186 | # Assign vlan tag 20 to host h1 |
| 187 | main.Mininet1.assignVLAN( 'h1', 'h1-%s' % defaultIntf, '20') |
| 188 | # Update port configuration of port 1 |
| 189 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 190 | [ '10.0.2.254/24', ], tagged=[ 20, ] ) |
| 191 | elif testIndex / 10 == 5: |
| 192 | # CASE51-54 |
| 193 | if hasattr( main, 'Mininet1' ): |
| 194 | # Update port configuration of port 1 |
| 195 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 196 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=10 ) |
| 197 | elif testIndex / 10 == 6: |
| 198 | # CASE61-64 |
| 199 | if hasattr( main, 'Mininet1' ): |
| 200 | # Update port configuration of port 1 |
| 201 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 202 | [ '10.0.2.254/24', ], tagged=[ 120, ], native=110 ) |
| 203 | # Update port configuration of port 2 |
| 204 | SRDynamicConfTest.updateIntfCfg( main, portNum + 1, dualHomed, |
| 205 | [ '10.0.2.254/24', ], tagged=[ 120, ], native=110 ) |
| 206 | elif testIndex / 10 == 7: |
| 207 | # CASE71-74 |
| 208 | if hasattr( main, 'Mininet1' ): |
| 209 | # Update host configuration of h1 |
| 210 | main.Mininet1.removeVLAN( 'h1', 'h1-%s.10' % defaultIntf ) |
| 211 | # Update port configuration of port 1 |
| 212 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 213 | [ '10.0.2.254/24', ], untagged=10 ) |
| 214 | elif testIndex / 10 == 8: |
| 215 | # CASE81-84 |
| 216 | if hasattr( main, 'Mininet1' ): |
| 217 | # Update port configuration of port 1 |
| 218 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 219 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=10 ) |
| 220 | elif testIndex / 10 == 9: |
| 221 | # CASE91-94 |
| 222 | if hasattr( main, 'Mininet1' ): |
| 223 | # Update host configuration |
| 224 | main.Mininet1.removeVLAN( 'h1', 'h1-%s.10' % defaultIntf ) |
| 225 | main.Mininet1.removeVLAN( 'h2', 'h2-%s.10' % defaultIntf ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 226 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 227 | # Update port configuration |
| 228 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 229 | [ '10.0.2.254/24', ], tagged=[ 120, ], native=110 ) |
| 230 | SRDynamicConfTest.updateIntfCfg( main, portNum + 1, dualHomed, |
| 231 | [ '10.0.2.254/24', ], tagged=[ 120, ], native=110 ) |
| 232 | elif testIndex / 10 == 10: |
| 233 | # CASE101-104 |
| 234 | if hasattr( main, 'Mininet1' ): |
| 235 | # Update port configuration |
| 236 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 237 | [ '10.0.2.254/24', ], untagged=20 ) |
| 238 | elif testIndex / 10 == 11: |
| 239 | # CASE111-114 |
| 240 | if hasattr( main, 'Mininet1' ): |
| 241 | # Update port configuration |
| 242 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 243 | [ '10.0.2.254/24', ], tagged=[ 20, ] ) |
| 244 | elif testIndex / 10 == 12: |
| 245 | # CASE121-124 |
| 246 | if hasattr( main, 'Mininet1' ): |
| 247 | # Update port configuration |
| 248 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 249 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=110 ) |
| 250 | SRDynamicConfTest.updateIntfCfg( main, portNum + 1, dualHomed, |
| 251 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=110 ) |
| 252 | elif testIndex / 10 == 13: |
| 253 | # CASE131-134 |
| 254 | if hasattr( main, 'Mininet1' ): |
| 255 | # Update port configuration |
| 256 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 257 | [ '10.0.2.254/24', ], tagged=[ 120, ], native=10 ) |
| 258 | elif testIndex / 10 == 14: |
| 259 | # CASE141-144 |
| 260 | if hasattr( main, 'Mininet1' ): |
| 261 | # Update port configuration |
| 262 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 263 | [ '10.0.2.254/24', ], tagged=[ 20, ] ) |
| 264 | elif testIndex / 10 == 15: |
| 265 | # CASE151-154 |
| 266 | if hasattr( main, 'Mininet1' ): |
| 267 | # Update port configuration |
| 268 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 269 | [ '10.0.2.254/24', ], tagged=[ 120, ] ) |
| 270 | elif testIndex / 10 == 16: |
| 271 | # CASE161-164 |
| 272 | if hasattr( main, 'Mininet1' ): |
| 273 | # Update port configuration |
| 274 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 275 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=10 ) |
| 276 | elif testIndex / 10 == 17: |
| 277 | # CASE171-174 |
| 278 | if hasattr( main, 'Mininet1' ): |
| 279 | # Update port configuration |
| 280 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 281 | [ '10.0.2.254/24', ], tagged=[ 120, ] ) |
| 282 | elif testIndex / 10 == 18: |
| 283 | # CASE181-184 |
| 284 | if hasattr( main, 'Mininet1' ): |
| 285 | # Update port configuration |
| 286 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 287 | [ '10.0.2.254/24', ], tagged=[ 20, ], native=10 ) |
| 288 | elif testIndex / 10 == 19: |
| 289 | # CASE191-194 |
| 290 | if hasattr( main, 'Mininet1' ): |
| 291 | # Update port configuration |
| 292 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 293 | [ '10.0.2.254/24', ], untagged=20 ) |
| 294 | elif testIndex / 10 == 20: |
| 295 | # CASE201-204 |
| 296 | if hasattr( main, 'Mininet1' ): |
| 297 | # Update port configuration |
| 298 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 299 | [ '10.0.2.254/24', ], tagged=[ 20 ] ) |
| 300 | elif testIndex / 10 == 21: |
| 301 | # CASE211-214 |
| 302 | if hasattr( main, 'Mininet1' ): |
| 303 | # Update port configuration |
| 304 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 305 | [ '10.0.2.254/24', ], tagged=[ 20 ], native=110 ) |
| 306 | elif testIndex / 10 == 22: |
| 307 | # CASE221-224 |
| 308 | if hasattr( main, 'Mininet1' ): |
| 309 | # Update port configuration |
| 310 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 311 | [ '10.0.2.254/24', ], tagged=[ 120 ], native=10 ) |
| 312 | elif testIndex / 10 == 23: |
| 313 | # CASE231-234 |
| 314 | if hasattr( main, "Mininet1" ): |
| 315 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 316 | [ '10.0.2.254/24', ], tagged=[ 10, ] ) |
| 317 | for dpid in leaf_dpid: |
| 318 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 319 | main.pingChart[ 'leaf1' ][ 'expect' ] = False |
| 320 | run.pingAll( main, '%s_1' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 321 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 322 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 323 | [ '10.0.2.254/24', ], untagged=50 ) |
| 324 | for dpid in leaf_dpid: |
| 325 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 326 | run.pingAll( main, '%s_2' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 327 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 328 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 329 | [ '10.0.2.254/24', ], tagged=[ 20, ] ) |
| 330 | for dpid in leaf_dpid: |
| 331 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 332 | run.pingAll( main, '%s_3' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 333 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 334 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 335 | [ '10.0.2.254/24', ], tagged=[ 40, ], native=10 ) |
| 336 | for dpid in leaf_dpid: |
| 337 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 338 | main.pingChart[ 'leaf1' ][ 'expect' ] = True |
| 339 | run.pingAll( main, '%s_4' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 340 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 341 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 342 | [ '10.0.2.254/24', ], tagged=[ 20, ] ) |
| 343 | for dpid in leaf_dpid: |
| 344 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 345 | main.pingChart[ 'leaf1' ][ 'expect' ] = False |
| 346 | run.pingAll( main, '%s_5' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 347 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 348 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 349 | [ '10.0.2.254/24', ], untagged= 20 ) |
| 350 | for dpid in leaf_dpid: |
| 351 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 352 | run.pingAll( main, '%s_6' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 353 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 354 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 355 | [ '10.0.2.254/24', ], untagged= 10 ) |
| 356 | for dpid in leaf_dpid: |
| 357 | run.checkFlowsByDpid( main, dpid, minFlowCountPerLeaf, sleep=5 ) |
| 358 | main.pingChart[ 'leaf1' ][ 'expect' ] = True |
| 359 | elif testIndex / 10 == 24: |
| 360 | # CASE243-244 |
| 361 | # Only for 2x2 and 2x4 topology, to test reachability from other leaf |
| 362 | if hasattr( main, "Mininet1" ): |
| 363 | # Update host IP and default GW |
| 364 | main.Mininet1.changeIP( 'h1', 'h1-%s' % defaultIntf, '10.0.6.1', '255.255.255.0' ) |
| 365 | main.Mininet1.changeDefaultGateway( 'h1', '10.0.6.254' ) |
| 366 | # Update port configuration |
| 367 | SRDynamicConfTest.updateIntfCfg( main, portNum, dualHomed, |
| 368 | [ '10.0.6.254/24', ], untagged=60 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 369 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 370 | # Update ping chart in case it is changed |
| 371 | try: |
| 372 | with open( "%s%sCASE%d_after.chart" % (main.configPath, main.forChart, testIndex / 10 * 10 ) ) as chart: |
| 373 | main.pingChart = json.load(chart) |
| 374 | except IOError: |
| 375 | main.log.debug( "Ping chart is not changed" ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 376 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 377 | # Check connectivity after changing interface configuration |
| 378 | run.checkFlows( main, minFlowCount=minFlowCountPerLeaf * topo[ topology ][ 1 ], sleep=5, dumpflows=False ) |
| 379 | run.pingAll( main, '%s_After' % TAG, retryAttempts=2 ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 380 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 381 | except Exception as e: |
| 382 | main.log.exception( "Error in runTest" ) |
| 383 | main.skipCase( result="FAIL", msg=e ) |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 384 | finally: |
| 385 | run.cleanup( main ) |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 386 | |
| 387 | @staticmethod |
| 388 | def updateIntfCfg( main, portNum, dualHomed, ips=[], untagged=0, tagged=[], native=0 ): |
| 389 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 390 | if main.useBmv2: |
| 391 | run.updateIntfCfg( main, "device:bmv2:leaf1/%d" % portNum, |
Jonghwan Hyun | 812c70f | 2018-02-16 16:33:16 -0800 | [diff] [blame] | 392 | ips=ips, untagged=untagged, tagged=tagged, native=native ) |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 393 | else: |
| 394 | run.updateIntfCfg( main, "of:0000000000000001/%d" % portNum, |
| 395 | ips=ips, untagged=untagged, tagged=tagged, native=native ) |
| 396 | if dualHomed: |
| 397 | if main.useBmv2: |
| 398 | run.updateIntfCfg( main, "device:bmv2:leaf2/%d" % portNum, |
| 399 | ips=ips, untagged=untagged, tagged=tagged, native=native ) |
| 400 | else: |
| 401 | run.updateIntfCfg( main, "of:0000000000000002/%d" % portNum, |
| 402 | ips=ips, untagged=untagged, tagged=tagged, native=native ) |