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