Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1 | # from cupshelpers.config import prefix |
| 2 | |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 3 | # Testing the basic functionality of SDN-IP |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 4 | |
| 5 | |
| 6 | class PeeringRouterTest: |
| 7 | |
| 8 | def __init__( self ): |
| 9 | self.default = '' |
| 10 | |
| 11 | # from cupshelpers.config import prefix |
| 12 | |
| 13 | # Testing the basic functionality of SDN-IP |
| 14 | |
| 15 | |
| 16 | class PeeringRouterTest: |
| 17 | |
| 18 | def __init__( self ): |
| 19 | self.default = '' |
| 20 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 21 | def CASE6 (self, main): |
| 22 | import time |
| 23 | import json |
| 24 | from operator import eq |
| 25 | # from datetime import datetime |
| 26 | from time import localtime, strftime |
| 27 | |
| 28 | #============================= Ping Test ======================== |
| 29 | main.log.info("Start ping test") |
| 30 | pingTestResults = main.QuaggaCliHost.pingTestAndCheck( |
| 31 | "1.168.30.100" ) |
| 32 | main.log.info("Ping test result") |
| 33 | if pingTestResults: |
| 34 | main.log.info("Test succeeded") |
| 35 | else: |
| 36 | main.log.info("Test failed") |
| 37 | |
| 38 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 39 | onpass="Default connectivity check PASS", |
| 40 | onfail="Default connectivity check FAIL") |
| 41 | |
| 42 | |
| 43 | def CASE4( self, main): |
| 44 | import time |
| 45 | import json |
| 46 | from operator import eq |
| 47 | # from datetime import datetime |
| 48 | from time import localtime, strftime |
| 49 | |
| 50 | main.case("The test case is to help to setup the TestON environment \ |
| 51 | and test new drivers" ) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 52 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 53 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet" |
| 54 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 55 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 56 | |
| 57 | # Copy the json files to config dir |
| 58 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 59 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 60 | |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 61 | # Launch mininet topology for this case |
| 62 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py" |
| 63 | main.step( "Launch mininet" ) |
| 64 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 65 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 66 | time.sleep(20) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 67 | main.step( "Test whether Mininet is started" ) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 68 | main.log.info( "Login Quagga CLI on host3" ) |
| 69 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 70 | # all expected routes for all BGP peers |
| 71 | allRoutesExpected = [] |
| 72 | main.step( "Start to generate routes for all BGP peers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 73 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 74 | main.log.info( "Generate prefixes for host3" ) |
| 75 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 76 | main.log.info( prefixesHost3 ) |
| 77 | # generate route with next hop |
| 78 | for prefix in prefixesHost3: |
| 79 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 80 | routeIntentsExpectedHost3 = \ |
| 81 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 82 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 83 | SDNIPJSONFILEPATH ) |
| 84 | |
| 85 | main.log.info( "Generate prefixes for host4" ) |
| 86 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 87 | main.log.info( prefixesHost4 ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 88 | # generate route with next hop |
| 89 | for prefix in prefixesHost4: |
| 90 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 91 | routeIntentsExpectedHost4 = \ |
| 92 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 93 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 94 | SDNIPJSONFILEPATH ) |
| 95 | |
| 96 | main.log.info( "Generate prefixes for host5" ) |
| 97 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 98 | main.log.info( prefixesHost5 ) |
| 99 | for prefix in prefixesHost5: |
| 100 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 101 | routeIntentsExpectedHost5 = \ |
| 102 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 103 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 104 | SDNIPJSONFILEPATH ) |
| 105 | |
| 106 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 107 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 108 | |
| 109 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 110 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 111 | main.step( "Set cell for ONOS-cli environment" ) |
| 112 | main.ONOScli.setCell( cellName ) |
| 113 | verifyResult = main.ONOSbench.verifyCell() |
| 114 | |
| 115 | main.log.report( "Removing raft logs" ) |
| 116 | main.ONOSbench.onosRemoveRaftLogs() |
| 117 | main.log.report( "Uninstalling ONOS" ) |
| 118 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 119 | |
| 120 | main.step( "Installing ONOS package" ) |
| 121 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 122 | options="-f", node=ONOS1Ip ) |
| 123 | |
| 124 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 125 | if not onos1Isup: |
| 126 | main.log.report( "ONOS1 didn't start!" ) |
| 127 | |
| 128 | main.step( "Start ONOS-cli" ) |
| 129 | |
| 130 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 131 | |
| 132 | main.step( "Get devices in the network" ) |
| 133 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 134 | main.log.info( listResult ) |
| 135 | time.sleep( 10 ) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 136 | main.log.info( "Installing bgprouter feature" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 137 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 138 | time.sleep( 10 ) |
| 139 | main.step( "Login all BGP peers and add routes into peers" ) |
| 140 | |
| 141 | main.log.info( "Login Quagga CLI on host3" ) |
| 142 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 143 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 144 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 145 | main.log.info( "Add routes to Quagga on host3" ) |
| 146 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 147 | |
| 148 | main.log.info( "Login Quagga CLI on host4" ) |
| 149 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 150 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 151 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 152 | main.log.info( "Add routes to Quagga on host4" ) |
| 153 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 154 | |
| 155 | main.log.info( "Login Quagga CLI on host5" ) |
| 156 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 157 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 158 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 159 | main.log.info( "Add routes to Quagga on host5" ) |
| 160 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 161 | |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 162 | time.sleep( 30 ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 163 | |
| 164 | # get routes inside SDN-IP |
| 165 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 166 | |
| 167 | # parse routes from ONOS CLI |
sanghoshin | e35a8a5 | 2015-02-27 20:47:26 -0800 | [diff] [blame] | 168 | allRoutesActual = \ |
| 169 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 170 | |
| 171 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 172 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 173 | main.step( "Check routes installed" ) |
| 174 | main.log.info( "Routes expected:" ) |
| 175 | main.log.info( allRoutesStrExpected ) |
| 176 | main.log.info( "Routes get from ONOS CLI:" ) |
| 177 | main.log.info( allRoutesStrActual ) |
| 178 | utilities.assertEquals( |
| 179 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 180 | onpass="***Routes in SDN-IP are correct!***", |
| 181 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 182 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 183 | main.log.report( |
| 184 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 185 | else: |
| 186 | main.log.report( |
| 187 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 188 | |
| 189 | #============================= Ping Test ======================== |
| 190 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 191 | main.log.info("Ping test result") |
| 192 | if pingTestResults: |
| 193 | main.log.info("Test succeeded") |
| 194 | else: |
| 195 | main.log.info("Test failed") |
| 196 | |
| 197 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 198 | onpass="Default connectivity check PASS", |
| 199 | onfail="Default connectivity check FAIL") |
| 200 | |
| 201 | #============================= Deleting Routes ================== |
| 202 | main.step( "Check deleting routes installed" ) |
| 203 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 204 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 205 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 206 | |
| 207 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
sanghoshin | e35a8a5 | 2015-02-27 20:47:26 -0800 | [diff] [blame] | 208 | allRoutesActual = \ |
| 209 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 210 | |
| 211 | main.log.info( "allRoutes_actual = " ) |
| 212 | main.log.info( allRoutesActual ) |
| 213 | |
| 214 | utilities.assertEquals( |
| 215 | expect="[]", actual=str( allRoutesActual ), |
| 216 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 217 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 218 | |
| 219 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 220 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 221 | else: |
| 222 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 223 | |
| 224 | #============================= Ping Test ======================== |
| 225 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 226 | main.log.info("Ping test result") |
| 227 | if pingTestResults: |
| 228 | main.log.info("Test succeeded") |
| 229 | else: |
| 230 | main.log.info("Test failed") |
| 231 | |
| 232 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 233 | onpass="disconnect check PASS", |
| 234 | onfail="disconnect check FAIL") |
| 235 | |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 236 | main.ONOScli.disconnect() |
| 237 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 238 | main.Mininet.stopNet() |
| 239 | time.sleep(10) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 240 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 241 | def CASE5( self, main ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 242 | """ |
| 243 | Test the SDN-IP functionality |
| 244 | allRoutesExpected: all expected routes for all BGP peers |
| 245 | routeIntentsExpected: all expected MultiPointToSinglePointIntent \ |
| 246 | intents |
| 247 | bgpIntentsExpected: expected PointToPointIntent intents |
| 248 | allRoutesActual: all routes from ONOS LCI |
| 249 | routeIntentsActual: actual MultiPointToSinglePointIntent intents from \ |
| 250 | ONOS CLI |
| 251 | bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI |
| 252 | """ |
| 253 | import time |
| 254 | import json |
| 255 | from operator import eq |
| 256 | # from datetime import datetime |
| 257 | from time import localtime, strftime |
| 258 | |
| 259 | main.case("The test case is to help to setup the TestON environment \ |
| 260 | and test new drivers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 261 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 262 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet" |
| 263 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 264 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 265 | # all expected routes for all BGP peers |
| 266 | allRoutesExpected = [] |
| 267 | main.step( "Start to generate routes for all BGP peers" ) |
| 268 | main.log.info( "Generate prefixes for host3" ) |
| 269 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 270 | main.log.info( prefixesHost3 ) |
| 271 | # generate route with next hop |
| 272 | for prefix in prefixesHost3: |
| 273 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 274 | routeIntentsExpectedHost3 = \ |
| 275 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 276 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 277 | SDNIPJSONFILEPATH ) |
| 278 | |
| 279 | main.log.info( "Generate prefixes for host4" ) |
| 280 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 281 | main.log.info( prefixesHost4 ) |
| 282 | # generate route with next hop |
| 283 | for prefix in prefixesHost4: |
| 284 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 285 | routeIntentsExpectedHost4 = \ |
| 286 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 287 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 288 | SDNIPJSONFILEPATH ) |
| 289 | |
| 290 | main.log.info( "Generate prefixes for host5" ) |
| 291 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 292 | main.log.info( prefixesHost5 ) |
| 293 | for prefix in prefixesHost5: |
| 294 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 295 | routeIntentsExpectedHost5 = \ |
| 296 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 297 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 298 | SDNIPJSONFILEPATH ) |
| 299 | |
| 300 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 301 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 302 | |
| 303 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 304 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 305 | main.step( "Set cell for ONOS-cli environment" ) |
| 306 | main.ONOScli.setCell( cellName ) |
| 307 | verifyResult = main.ONOSbench.verifyCell() |
| 308 | |
| 309 | main.log.report( "Removing raft logs" ) |
| 310 | main.ONOSbench.onosRemoveRaftLogs() |
| 311 | main.log.report( "Uninstalling ONOS" ) |
| 312 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 313 | |
| 314 | main.step( "Installing ONOS package" ) |
| 315 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 316 | options="-f", node=ONOS1Ip ) |
| 317 | |
| 318 | main.step( "Checking if ONOS is up yet" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 319 | time.sleep( 20 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 320 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 321 | if not onos1Isup: |
| 322 | main.log.report( "ONOS1 didn't start!" ) |
| 323 | |
| 324 | main.step( "Start ONOS-cli" ) |
| 325 | |
| 326 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 327 | |
| 328 | main.step( "Get devices in the network" ) |
| 329 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 330 | main.log.info( listResult ) |
| 331 | time.sleep( 10 ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 332 | main.log.info( "Installing gbprouter feature" ) |
| 333 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 334 | time.sleep( 10 ) |
| 335 | main.step( "Login all BGP peers and add routes into peers" ) |
| 336 | |
| 337 | main.log.info( "Login Quagga CLI on host3" ) |
| 338 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 339 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 340 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 341 | main.log.info( "Add routes to Quagga on host3" ) |
| 342 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 343 | |
| 344 | main.log.info( "Login Quagga CLI on host4" ) |
| 345 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 346 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 347 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 348 | main.log.info( "Add routes to Quagga on host4" ) |
| 349 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 350 | |
| 351 | main.log.info( "Login Quagga CLI on host5" ) |
| 352 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 353 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 354 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 355 | main.log.info( "Add routes to Quagga on host5" ) |
| 356 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 357 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 358 | #time.sleep( 30 ) |
| 359 | time.sleep(10) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 360 | |
| 361 | # get routes inside SDN-IP |
| 362 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 363 | |
| 364 | # parse routes from ONOS CLI |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 365 | # allRoutesActual = \ |
| 366 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 367 | allRoutesActual = [] |
| 368 | main.log.info("allRoutesExpected") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 369 | |
| 370 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 371 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 372 | main.step( "Check routes installed" ) |
| 373 | main.log.info( "Routes expected:" ) |
| 374 | main.log.info( allRoutesStrExpected ) |
| 375 | main.log.info( "Routes get from ONOS CLI:" ) |
| 376 | main.log.info( allRoutesStrActual ) |
| 377 | utilities.assertEquals( |
| 378 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 379 | onpass="***Routes in SDN-IP are correct!***", |
| 380 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 381 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 382 | main.log.report( |
| 383 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 384 | else: |
| 385 | main.log.report( |
| 386 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 387 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 388 | #time.sleep( 20 ) |
| 389 | #getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 390 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 391 | #main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 392 | # routeIntentsExpected are generated when generating routes |
| 393 | # get rpoute intents from ONOS CLI |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 394 | #routeIntentsActual = \ |
| 395 | # main.QuaggaCliHost3.extractActualRouteIntents( |
| 396 | # getIntentsResult ) |
| 397 | #routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 398 | #routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" ) |
| 399 | #main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 400 | #main.log.info( routeIntentsStrExpected ) |
| 401 | #main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 402 | #main.log.info( routeIntentsStrActual ) |
| 403 | #utilities.assertEquals( |
| 404 | # expect=True, |
| 405 | # actual=eq( routeIntentsStrExpected, routeIntentsStrActual ), |
| 406 | # onpass="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 407 | # correct!***", |
| 408 | # onfail="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 409 | # wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 410 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 411 | #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 412 | # main.log.report( "***MultiPointToSinglePoint Intents before \ |
| 413 | # deleting routes correct!***" ) |
| 414 | #else: |
| 415 | # main.log.report( "***MultiPointToSinglePoint Intents before \ |
| 416 | # deleting routes wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 417 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 418 | #main.step( "Check BGP PointToPointIntent intents installed" ) |
| 419 | ## bgp intents expected |
| 420 | #bgpIntentsExpected = \ |
| 421 | # main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH ) |
| 422 | ## get BGP intents from ONOS CLI |
| 423 | #bgpIntentsActual = \ |
| 424 | # main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 425 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 426 | #bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" ) |
| 427 | #bgpIntentsStrActual = str( bgpIntentsActual ) |
| 428 | #main.log.info( "PointToPointIntent intents expected:" ) |
| 429 | #main.log.info( bgpIntentsStrExpected ) |
| 430 | #main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 431 | #main.log.info( bgpIntentsStrActual ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 432 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 433 | #utilities.assertEquals( |
| 434 | # expect=True, |
| 435 | # actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ), |
| 436 | # onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 437 | # onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 438 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 439 | #if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ): |
| 440 | # main.log.report( |
| 441 | # "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
| 442 | #else: |
| 443 | # main.log.report( |
| 444 | # "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 445 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 446 | #============================= Ping Test ======================== |
| 447 | # wait until all MultiPointToSinglePoint |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 448 | time.sleep( 10 ) |
| 449 | main.log.info("Start ping test") |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 450 | pingTestScript = TESTCASE_ROOT_PATH + "CASE4-ping-as2host.sh" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 451 | pingTestResultsFile = \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 452 | TESTCASE_ROOT_PATH + "CASE4-ping-results-before-delete-routes-" \ |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 453 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 454 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 455 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 456 | main.log.info("Ping test result") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 457 | main.log.info( pingTestResults ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 458 | time.sleep( 10 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 459 | |
| 460 | #============================= Deleting Routes ================== |
| 461 | main.step( "Check deleting routes installed" ) |
| 462 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 463 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 464 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 465 | |
| 466 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 467 | # FIX ME |
| 468 | #allRoutesActual = \ |
| 469 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 470 | allRoutesActual = [] |
| 471 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 472 | main.log.info( "allRoutes_actual = " ) |
| 473 | main.log.info( allRoutesActual ) |
| 474 | |
| 475 | utilities.assertEquals( |
| 476 | expect="[]", actual=str( allRoutesActual ), |
| 477 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 478 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 479 | |
| 480 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 481 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 482 | else: |
| 483 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 484 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 485 | #main.step( "Check intents after deleting routes" ) |
| 486 | #getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 487 | #routeIntentsActual = \ |
| 488 | # main.QuaggaCliHost3.extractActualRouteIntents( |
| 489 | # getIntentsResult ) |
| 490 | #main.log.info( "main.ONOScli.intents()= " ) |
| 491 | #main.log.info( routeIntentsActual ) |
| 492 | #utilities.assertEquals( |
| 493 | # expect="[]", actual=str( routeIntentsActual ), |
| 494 | # onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \ |
| 495 | # correct!***", |
| 496 | # onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \ |
| 497 | # wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 498 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 499 | #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 500 | # main.log.report( "***MultiPointToSinglePoint Intents after \ |
| 501 | # deleting routes correct!***" ) |
| 502 | #else: |
| 503 | # main.log.report( "***MultiPointToSinglePoint Intents after \ |
| 504 | # deleting routes wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 505 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 506 | time.sleep( 10 ) |
| 507 | main.log.info("Ping test after removing routs") |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 508 | pingTestScript = TESTCASE_ROOT_PATH + "CASE4-ping-as2host.sh" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 509 | pingTestResultsFile = \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 510 | TESTCASE_ROOT_PATH + "CASE4-ping-results-after-delete-routes-" \ |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 511 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 512 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 513 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 514 | main.log.info("Ping test results") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 515 | main.log.info( pingTestResults ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 516 | time.sleep( 10 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 517 | |
| 518 | # main.step( "Test whether Mininet is started" ) |
| 519 | # main.Mininet2.handle.sendline( "xterm host1" ) |
| 520 | # main.Mininet2.handle.expect( "mininet>" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 521 | main.ONOScli.disconnect() |
| 522 | main.ONOSbench.onosStop(ONOS1Ip); |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 523 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 524 | # Route convergence and connectivity test |
| 525 | def CASE21( self, main): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 526 | import time |
| 527 | import json |
| 528 | from operator import eq |
| 529 | # from datetime import datetime |
| 530 | from time import localtime, strftime |
| 531 | |
| 532 | main.case("The test case is to help to setup the TestON environment \ |
| 533 | and test new drivers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 534 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 535 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet" |
| 536 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 537 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 538 | |
| 539 | # Copy the json files to config dir |
| 540 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 541 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 542 | |
| 543 | # Launch mininet topology for this case |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 544 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py" |
| 545 | main.step( "Launch mininet" ) |
| 546 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 547 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 548 | time.sleep(20) |
| 549 | main.step( "Test whether Mininet is started" ) |
| 550 | main.log.info( "Login Quagga CLI on host3" ) |
| 551 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 552 | # all expected routes for all BGP peers |
| 553 | allRoutesExpected = [] |
| 554 | main.step( "Start to generate routes for all BGP peers" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 555 | main.log.info( "Generate prefixes for host3" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 556 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 557 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 558 | main.log.info( prefixesHost3 ) |
| 559 | # generate route with next hop |
| 560 | for prefix in prefixesHost3: |
| 561 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 562 | routeIntentsExpectedHost3 = \ |
| 563 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 564 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 565 | SDNIPJSONFILEPATH ) |
| 566 | |
| 567 | main.log.info( "Generate prefixes for host4" ) |
| 568 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 569 | main.log.info( prefixesHost4 ) |
| 570 | # generate route with next hop |
| 571 | for prefix in prefixesHost4: |
| 572 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 573 | routeIntentsExpectedHost4 = \ |
| 574 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 575 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 576 | SDNIPJSONFILEPATH ) |
| 577 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 578 | main.log.info( "Generate prefixes for host5" ) |
| 579 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 580 | main.log.info( prefixesHost5 ) |
| 581 | for prefix in prefixesHost5: |
| 582 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 583 | routeIntentsExpectedHost5 = \ |
| 584 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 585 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 586 | SDNIPJSONFILEPATH ) |
| 587 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 588 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 589 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 590 | |
| 591 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 592 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 593 | main.step( "Set cell for ONOS-cli environment" ) |
| 594 | main.ONOScli.setCell( cellName ) |
| 595 | verifyResult = main.ONOSbench.verifyCell() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 596 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 597 | main.log.report( "Removing raft logs" ) |
| 598 | main.ONOSbench.onosRemoveRaftLogs() |
| 599 | main.log.report( "Uninstalling ONOS" ) |
| 600 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 601 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 602 | main.step( "Installing ONOS package" ) |
| 603 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 604 | options="-f", node=ONOS1Ip ) |
| 605 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 606 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 607 | if not onos1Isup: |
| 608 | main.log.report( "ONOS1 didn't start!" ) |
| 609 | |
| 610 | main.step( "Start ONOS-cli" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 611 | |
| 612 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 613 | |
| 614 | main.step( "Get devices in the network" ) |
| 615 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 616 | main.log.info( listResult ) |
| 617 | time.sleep( 10 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 618 | main.log.info( "Installing gbprouter feature" ) |
| 619 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 620 | time.sleep( 10 ) |
| 621 | main.step( "Login all BGP peers and add routes into peers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 622 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 623 | main.log.info( "Login Quagga CLI on host3" ) |
| 624 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 625 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 626 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 627 | main.log.info( "Add routes to Quagga on host3" ) |
| 628 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 629 | |
| 630 | main.log.info( "Login Quagga CLI on host4" ) |
| 631 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 632 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 633 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 634 | main.log.info( "Add routes to Quagga on host4" ) |
| 635 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 636 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 637 | main.log.info( "Login Quagga CLI on host5" ) |
| 638 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 639 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 640 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 641 | main.log.info( "Add routes to Quagga on host5" ) |
| 642 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 643 | |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 644 | time.sleep( 30 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 645 | |
| 646 | # get routes inside SDN-IP |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 647 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 648 | |
| 649 | # parse routes from ONOS CLI |
| 650 | allRoutesActual = \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 651 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 652 | |
| 653 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 654 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 655 | main.step( "Check routes installed" ) |
| 656 | main.log.info( "Routes expected:" ) |
| 657 | main.log.info( allRoutesStrExpected ) |
| 658 | main.log.info( "Routes get from ONOS CLI:" ) |
| 659 | main.log.info( allRoutesStrActual ) |
| 660 | utilities.assertEquals( |
| 661 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 662 | onpass="***Routes in SDN-IP are correct!***", |
| 663 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 664 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 665 | main.log.report( |
| 666 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 667 | else: |
| 668 | main.log.report( |
| 669 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 670 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 671 | #============================= Ping Test ======================== |
| 672 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 673 | main.log.info("Ping test result") |
| 674 | if pingTestResults: |
| 675 | main.log.info("Test succeeded") |
| 676 | else: |
| 677 | main.log.info("Test failed") |
| 678 | |
| 679 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 680 | onpass="Default connectivity check PASS", |
| 681 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 682 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 683 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 684 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 685 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 686 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 687 | time.sleep(150) |
| 688 | # get routes inside SDN-IP |
| 689 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 690 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 691 | |
| 692 | # parse routes from ONOS CLI |
| 693 | newAllRoutesActual = \ |
| 694 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 695 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 696 | |
| 697 | # Expected routes with changed next hop |
| 698 | newAllRoutesExpected = [] |
| 699 | for prefix in prefixesHost3: |
| 700 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 701 | for prefix in prefixesHost4: |
| 702 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 703 | for prefix in prefixesHost5: |
| 704 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 705 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 706 | main.step( "Check routes installed after convergence-1" ) |
| 707 | main.log.info( "Routes expected:" ) |
| 708 | main.log.info( newAllRoutesStrExpected ) |
| 709 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 710 | main.log.info( newAllRoutesStrActual ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 711 | utilities.assertEquals( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 712 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 713 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 714 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 715 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 716 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 717 | "***Routes in SDN-IP after convergence are correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 718 | else: |
| 719 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 720 | "***Routes in SDN-IP after convergence are wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 721 | |
| 722 | #============================= Ping Test ======================== |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 723 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 724 | main.log.info("Ping test result") |
| 725 | if pingTestResults: |
| 726 | main.log.info("Test succeeded") |
| 727 | else: |
| 728 | main.log.info("Test failed") |
| 729 | |
| 730 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 731 | onpass="Default connectivity check PASS", |
| 732 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 733 | |
| 734 | #============================= Deleting Routes ================== |
| 735 | main.step( "Check deleting routes installed" ) |
| 736 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 737 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 738 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 739 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 740 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 741 | allRoutesActual = \ |
| 742 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 743 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 744 | main.log.info( "allRoutes_actual = " ) |
| 745 | main.log.info( allRoutesActual ) |
| 746 | |
| 747 | utilities.assertEquals( |
| 748 | expect="[]", actual=str( allRoutesActual ), |
| 749 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 750 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 751 | |
| 752 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 753 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 754 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 755 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 756 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 757 | #============================= Ping Test ======================== |
| 758 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 759 | main.log.info("Ping test result") |
| 760 | if pingTestResults: |
| 761 | main.log.info("Test succeeded") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 762 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 763 | main.log.info("Test failed") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 764 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 765 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 766 | onpass="disconnect check PASS", |
| 767 | onfail="disconnect check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 768 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 769 | main.ONOScli.disconnect() |
| 770 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 771 | main.Mininet.stopNet() |
| 772 | time.sleep(10) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 773 | |