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) |
| 56 | # Launch mininet topology for this case |
| 57 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py" |
| 58 | main.step( "Launch mininet" ) |
| 59 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 60 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 61 | time.sleep(20) |
| 62 | main.step("verifying mininet launch") |
| 63 | main.log.info( "Login Quagga CLI on host3" ) |
| 64 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 65 | # all expected routes for all BGP peers |
| 66 | allRoutesExpected = [] |
| 67 | main.step( "Start to generate routes for all BGP peers" ) |
| 68 | main.log.info( "Generate prefixes for host3" ) |
| 69 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 70 | main.log.info( prefixesHost3 ) |
| 71 | # generate route with next hop |
| 72 | for prefix in prefixesHost3: |
| 73 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 74 | routeIntentsExpectedHost3 = \ |
| 75 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 76 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 77 | SDNIPJSONFILEPATH ) |
| 78 | |
| 79 | main.log.info( "Generate prefixes for host4" ) |
| 80 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 81 | main.log.info( prefixesHost4 ) |
| 82 | |
| 83 | # generate route with next hop |
| 84 | for prefix in prefixesHost3: |
| 85 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 86 | routeIntentsExpectedHost3 = \ |
| 87 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 88 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 89 | SDNIPJSONFILEPATH ) |
| 90 | |
| 91 | main.log.info( "Generate prefixes for host4" ) |
| 92 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 93 | main.log.info( prefixesHost4 ) |
| 94 | # generate route with next hop |
| 95 | for prefix in prefixesHost4: |
| 96 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 97 | routeIntentsExpectedHost4 = \ |
| 98 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 99 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 100 | SDNIPJSONFILEPATH ) |
| 101 | |
| 102 | main.log.info( "Generate prefixes for host5" ) |
| 103 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 104 | main.log.info( prefixesHost5 ) |
| 105 | for prefix in prefixesHost5: |
| 106 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 107 | routeIntentsExpectedHost5 = \ |
| 108 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 109 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 110 | SDNIPJSONFILEPATH ) |
| 111 | |
| 112 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 113 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 114 | |
| 115 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 116 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 117 | main.step( "Set cell for ONOS-cli environment" ) |
| 118 | main.ONOScli.setCell( cellName ) |
| 119 | verifyResult = main.ONOSbench.verifyCell() |
| 120 | |
| 121 | main.log.report( "Removing raft logs" ) |
| 122 | main.ONOSbench.onosRemoveRaftLogs() |
| 123 | main.log.report( "Uninstalling ONOS" ) |
| 124 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 125 | |
| 126 | main.step( "Installing ONOS package" ) |
| 127 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 128 | options="-f", node=ONOS1Ip ) |
| 129 | |
| 130 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 131 | if not onos1Isup: |
| 132 | main.log.report( "ONOS1 didn't start!" ) |
| 133 | |
| 134 | main.step( "Start ONOS-cli" ) |
| 135 | |
| 136 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 137 | |
| 138 | main.step( "Get devices in the network" ) |
| 139 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 140 | main.log.info( listResult ) |
| 141 | time.sleep( 10 ) |
| 142 | main.log.info( "Installing gbprouter feature" ) |
| 143 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 144 | time.sleep( 10 ) |
| 145 | main.step( "Login all BGP peers and add routes into peers" ) |
| 146 | |
| 147 | main.log.info( "Login Quagga CLI on host3" ) |
| 148 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 149 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 150 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 151 | main.log.info( "Add routes to Quagga on host3" ) |
| 152 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 153 | |
| 154 | main.log.info( "Login Quagga CLI on host4" ) |
| 155 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 156 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 157 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 158 | main.log.info( "Add routes to Quagga on host4" ) |
| 159 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 160 | |
| 161 | main.log.info( "Login Quagga CLI on host5" ) |
| 162 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 163 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 164 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 165 | main.log.info( "Add routes to Quagga on host5" ) |
| 166 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 167 | |
| 168 | #time.sleep( 30 ) |
| 169 | time.sleep(10) |
| 170 | |
| 171 | # get routes inside SDN-IP |
| 172 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 173 | |
| 174 | # parse routes from ONOS CLI |
| 175 | # allRoutesActual = \ |
| 176 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 177 | allRoutesActual = [] |
| 178 | main.log.info("allRoutesExpected") |
| 179 | |
| 180 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 181 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 182 | main.step( "Check routes installed" ) |
| 183 | main.log.info( "Routes expected:" ) |
| 184 | main.log.info( allRoutesStrExpected ) |
| 185 | main.log.info( "Routes get from ONOS CLI:" ) |
| 186 | main.log.info( allRoutesStrActual ) |
| 187 | utilities.assertEquals( |
| 188 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 189 | onpass="***Routes in SDN-IP are correct!***", |
| 190 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 191 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 192 | main.log.report( |
| 193 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 194 | else: |
| 195 | main.log.report( |
| 196 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 197 | |
| 198 | #============================= Ping Test ======================== |
| 199 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 200 | main.log.info("Ping test result") |
| 201 | if pingTestResults: |
| 202 | main.log.info("Test succeeded") |
| 203 | else: |
| 204 | main.log.info("Test failed") |
| 205 | |
| 206 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 207 | onpass="Default connectivity check PASS", |
| 208 | onfail="Default connectivity check FAIL") |
| 209 | |
| 210 | #============================= Deleting Routes ================== |
| 211 | main.step( "Check deleting routes installed" ) |
| 212 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 213 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 214 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 215 | |
| 216 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 217 | # FIX ME |
| 218 | #allRoutesActual = \ |
| 219 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 220 | allRoutesActual = [] |
| 221 | |
| 222 | main.log.info( "allRoutes_actual = " ) |
| 223 | main.log.info( allRoutesActual ) |
| 224 | |
| 225 | utilities.assertEquals( |
| 226 | expect="[]", actual=str( allRoutesActual ), |
| 227 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 228 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 229 | |
| 230 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 231 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 232 | else: |
| 233 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 234 | |
| 235 | #============================= Ping Test ======================== |
| 236 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 237 | main.log.info("Ping test result") |
| 238 | if pingTestResults: |
| 239 | main.log.info("Test succeeded") |
| 240 | else: |
| 241 | main.log.info("Test failed") |
| 242 | |
| 243 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 244 | onpass="disconnect check PASS", |
| 245 | onfail="disconnect check FAIL") |
| 246 | |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame^] | 247 | main.ONOScli.disconnect() |
| 248 | main.ONOSbench.onosStop(ONOS1Ip); |
| 249 | main.Mininet.disconnect() |
| 250 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 251 | def CASE5( self, main ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 252 | """ |
| 253 | Test the SDN-IP functionality |
| 254 | allRoutesExpected: all expected routes for all BGP peers |
| 255 | routeIntentsExpected: all expected MultiPointToSinglePointIntent \ |
| 256 | intents |
| 257 | bgpIntentsExpected: expected PointToPointIntent intents |
| 258 | allRoutesActual: all routes from ONOS LCI |
| 259 | routeIntentsActual: actual MultiPointToSinglePointIntent intents from \ |
| 260 | ONOS CLI |
| 261 | bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI |
| 262 | """ |
| 263 | import time |
| 264 | import json |
| 265 | from operator import eq |
| 266 | # from datetime import datetime |
| 267 | from time import localtime, strftime |
| 268 | |
| 269 | main.case("The test case is to help to setup the TestON environment \ |
| 270 | and test new drivers" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 271 | CURRENT_PATH = "/home/sdnip/TestON/tests/PeeringRouterTest/" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 272 | SDNIPJSONFILEPATH = \ |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 273 | "/home/sdnip/TestON/tests/PeeringRouterTest/sdnip.json" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 274 | # all expected routes for all BGP peers |
| 275 | allRoutesExpected = [] |
| 276 | main.step( "Start to generate routes for all BGP peers" ) |
| 277 | main.log.info( "Generate prefixes for host3" ) |
| 278 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 279 | main.log.info( prefixesHost3 ) |
| 280 | # generate route with next hop |
| 281 | for prefix in prefixesHost3: |
| 282 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 283 | routeIntentsExpectedHost3 = \ |
| 284 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 285 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 286 | SDNIPJSONFILEPATH ) |
| 287 | |
| 288 | main.log.info( "Generate prefixes for host4" ) |
| 289 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 290 | main.log.info( prefixesHost4 ) |
| 291 | # generate route with next hop |
| 292 | for prefix in prefixesHost4: |
| 293 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 294 | routeIntentsExpectedHost4 = \ |
| 295 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 296 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 297 | SDNIPJSONFILEPATH ) |
| 298 | |
| 299 | main.log.info( "Generate prefixes for host5" ) |
| 300 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 301 | main.log.info( prefixesHost5 ) |
| 302 | for prefix in prefixesHost5: |
| 303 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 304 | routeIntentsExpectedHost5 = \ |
| 305 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 306 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 307 | SDNIPJSONFILEPATH ) |
| 308 | |
| 309 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 310 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 311 | |
| 312 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 313 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 314 | main.step( "Set cell for ONOS-cli environment" ) |
| 315 | main.ONOScli.setCell( cellName ) |
| 316 | verifyResult = main.ONOSbench.verifyCell() |
| 317 | |
| 318 | main.log.report( "Removing raft logs" ) |
| 319 | main.ONOSbench.onosRemoveRaftLogs() |
| 320 | main.log.report( "Uninstalling ONOS" ) |
| 321 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 322 | |
| 323 | main.step( "Installing ONOS package" ) |
| 324 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 325 | options="-f", node=ONOS1Ip ) |
| 326 | |
| 327 | main.step( "Checking if ONOS is up yet" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 328 | time.sleep( 20 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 329 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 330 | if not onos1Isup: |
| 331 | main.log.report( "ONOS1 didn't start!" ) |
| 332 | |
| 333 | main.step( "Start ONOS-cli" ) |
| 334 | |
| 335 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 336 | |
| 337 | main.step( "Get devices in the network" ) |
| 338 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 339 | main.log.info( listResult ) |
| 340 | time.sleep( 10 ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 341 | main.log.info( "Installing gbprouter feature" ) |
| 342 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 343 | time.sleep( 10 ) |
| 344 | main.step( "Login all BGP peers and add routes into peers" ) |
| 345 | |
| 346 | main.log.info( "Login Quagga CLI on host3" ) |
| 347 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 348 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 349 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 350 | main.log.info( "Add routes to Quagga on host3" ) |
| 351 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 352 | |
| 353 | main.log.info( "Login Quagga CLI on host4" ) |
| 354 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 355 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 356 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 357 | main.log.info( "Add routes to Quagga on host4" ) |
| 358 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 359 | |
| 360 | main.log.info( "Login Quagga CLI on host5" ) |
| 361 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 362 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 363 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 364 | main.log.info( "Add routes to Quagga on host5" ) |
| 365 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 366 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 367 | #time.sleep( 30 ) |
| 368 | time.sleep(10) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 369 | |
| 370 | # get routes inside SDN-IP |
| 371 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 372 | |
| 373 | # parse routes from ONOS CLI |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 374 | # allRoutesActual = \ |
| 375 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 376 | allRoutesActual = [] |
| 377 | main.log.info("allRoutesExpected") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 378 | |
| 379 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 380 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 381 | main.step( "Check routes installed" ) |
| 382 | main.log.info( "Routes expected:" ) |
| 383 | main.log.info( allRoutesStrExpected ) |
| 384 | main.log.info( "Routes get from ONOS CLI:" ) |
| 385 | main.log.info( allRoutesStrActual ) |
| 386 | utilities.assertEquals( |
| 387 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 388 | onpass="***Routes in SDN-IP are correct!***", |
| 389 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 390 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 391 | main.log.report( |
| 392 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 393 | else: |
| 394 | main.log.report( |
| 395 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 396 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 397 | #time.sleep( 20 ) |
| 398 | #getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 399 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 400 | #main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 401 | # routeIntentsExpected are generated when generating routes |
| 402 | # get rpoute intents from ONOS CLI |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 403 | #routeIntentsActual = \ |
| 404 | # main.QuaggaCliHost3.extractActualRouteIntents( |
| 405 | # getIntentsResult ) |
| 406 | #routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 407 | #routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" ) |
| 408 | #main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 409 | #main.log.info( routeIntentsStrExpected ) |
| 410 | #main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 411 | #main.log.info( routeIntentsStrActual ) |
| 412 | #utilities.assertEquals( |
| 413 | # expect=True, |
| 414 | # actual=eq( routeIntentsStrExpected, routeIntentsStrActual ), |
| 415 | # onpass="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 416 | # correct!***", |
| 417 | # onfail="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 418 | # wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 419 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 420 | #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 421 | # main.log.report( "***MultiPointToSinglePoint Intents before \ |
| 422 | # deleting routes correct!***" ) |
| 423 | #else: |
| 424 | # main.log.report( "***MultiPointToSinglePoint Intents before \ |
| 425 | # deleting routes wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 426 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 427 | #main.step( "Check BGP PointToPointIntent intents installed" ) |
| 428 | ## bgp intents expected |
| 429 | #bgpIntentsExpected = \ |
| 430 | # main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH ) |
| 431 | ## get BGP intents from ONOS CLI |
| 432 | #bgpIntentsActual = \ |
| 433 | # main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 434 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 435 | #bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" ) |
| 436 | #bgpIntentsStrActual = str( bgpIntentsActual ) |
| 437 | #main.log.info( "PointToPointIntent intents expected:" ) |
| 438 | #main.log.info( bgpIntentsStrExpected ) |
| 439 | #main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 440 | #main.log.info( bgpIntentsStrActual ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 441 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 442 | #utilities.assertEquals( |
| 443 | # expect=True, |
| 444 | # actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ), |
| 445 | # onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 446 | # onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 447 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 448 | #if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ): |
| 449 | # main.log.report( |
| 450 | # "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
| 451 | #else: |
| 452 | # main.log.report( |
| 453 | # "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 454 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 455 | #============================= Ping Test ======================== |
| 456 | # wait until all MultiPointToSinglePoint |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 457 | time.sleep( 10 ) |
| 458 | main.log.info("Start ping test") |
| 459 | pingTestScript = CURRENT_PATH + "CASE4-ping-as2host.sh" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 460 | pingTestResultsFile = \ |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 461 | CURRENT_PATH + "CASE4-ping-results-before-delete-routes-" \ |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 462 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 463 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 464 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 465 | main.log.info("Ping test result") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 466 | main.log.info( pingTestResults ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 467 | time.sleep( 10 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 468 | |
| 469 | #============================= Deleting Routes ================== |
| 470 | main.step( "Check deleting routes installed" ) |
| 471 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 472 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 473 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 474 | |
| 475 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 476 | # FIX ME |
| 477 | #allRoutesActual = \ |
| 478 | # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 479 | allRoutesActual = [] |
| 480 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 481 | main.log.info( "allRoutes_actual = " ) |
| 482 | main.log.info( allRoutesActual ) |
| 483 | |
| 484 | utilities.assertEquals( |
| 485 | expect="[]", actual=str( allRoutesActual ), |
| 486 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 487 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 488 | |
| 489 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 490 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 491 | else: |
| 492 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 493 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 494 | #main.step( "Check intents after deleting routes" ) |
| 495 | #getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 496 | #routeIntentsActual = \ |
| 497 | # main.QuaggaCliHost3.extractActualRouteIntents( |
| 498 | # getIntentsResult ) |
| 499 | #main.log.info( "main.ONOScli.intents()= " ) |
| 500 | #main.log.info( routeIntentsActual ) |
| 501 | #utilities.assertEquals( |
| 502 | # expect="[]", actual=str( routeIntentsActual ), |
| 503 | # onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \ |
| 504 | # correct!***", |
| 505 | # onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \ |
| 506 | # wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 507 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 508 | #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 509 | # main.log.report( "***MultiPointToSinglePoint Intents after \ |
| 510 | # deleting routes correct!***" ) |
| 511 | #else: |
| 512 | # main.log.report( "***MultiPointToSinglePoint Intents after \ |
| 513 | # deleting routes wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 514 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 515 | time.sleep( 10 ) |
| 516 | main.log.info("Ping test after removing routs") |
| 517 | pingTestScript = CURRENT_PATH + "CASE4-ping-as2host.sh" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 518 | pingTestResultsFile = \ |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 519 | CURRENT_PATH + "CASE4-ping-results-after-delete-routes-" \ |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 520 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 521 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 522 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 523 | main.log.info("Ping test results") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 524 | main.log.info( pingTestResults ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 525 | time.sleep( 10 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 526 | |
| 527 | # main.step( "Test whether Mininet is started" ) |
| 528 | # main.Mininet2.handle.sendline( "xterm host1" ) |
| 529 | # main.Mininet2.handle.expect( "mininet>" ) |
| 530 | |
| 531 | def CASE3( self, main ): |
| 532 | """ |
| 533 | Test the SDN-IP functionality |
| 534 | allRoutesExpected: all expected routes for all BGP peers |
| 535 | routeIntentsExpected: all expected MultiPointToSinglePointIntent intents |
| 536 | bgpIntentsExpected: expected PointToPointIntent intents |
| 537 | allRoutesActual: all routes from ONOS LCI |
| 538 | routeIntentsActual: actual MultiPointToSinglePointIntent intents from \ |
| 539 | ONOS CLI |
| 540 | bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI |
| 541 | """ |
| 542 | import time |
| 543 | import json |
| 544 | from operator import eq |
| 545 | # from datetime import datetime |
| 546 | from time import localtime, strftime |
| 547 | |
| 548 | main.case( "The test case is to help to setup the TestON \ |
| 549 | environment and test new drivers" ) |
| 550 | # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json" |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 551 | TESTPATH = "/home/adnip/TestOn/tests/PeeringRouterTest/" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 552 | SDNIPJSONFILEPATH = \ |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 553 | "/home/sdnip/onos/tools/package/config/sdnip.json" |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 554 | # all expected routes for all BGP peers |
| 555 | allRoutesExpected = [] |
| 556 | main.step( "Start to generate routes for all BGP peers" ) |
| 557 | main.log.info( "Generate prefixes for host3" ) |
| 558 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 559 | main.log.info( prefixesHost3 ) |
| 560 | # generate route with next hop |
| 561 | for prefix in prefixesHost3: |
| 562 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 563 | routeIntentsExpectedHost3 = \ |
| 564 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 565 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 566 | SDNIPJSONFILEPATH ) |
| 567 | |
| 568 | main.log.info( "Generate prefixes for host4" ) |
| 569 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 570 | main.log.info( prefixesHost4 ) |
| 571 | # generate route with next hop |
| 572 | for prefix in prefixesHost4: |
| 573 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 574 | routeIntentsExpectedHost4 = \ |
| 575 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 576 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 577 | SDNIPJSONFILEPATH ) |
| 578 | |
| 579 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 580 | routeIntentsExpectedHost4 |
| 581 | |
| 582 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 583 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 584 | main.step( "Set cell for ONOS-cli environment" ) |
| 585 | main.ONOScli.setCell( cellName ) |
| 586 | verifyResult = main.ONOSbench.verifyCell() |
| 587 | |
| 588 | main.log.report( "Removing raft logs" ) |
| 589 | main.ONOSbench.onosRemoveRaftLogs() |
| 590 | main.log.report( "Uninstalling ONOS" ) |
| 591 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 592 | |
| 593 | main.step( "Installing ONOS package" ) |
| 594 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 595 | options="-f", node=ONOS1Ip ) |
| 596 | |
| 597 | main.step( "Checking if ONOS is up yet" ) |
| 598 | time.sleep( 60 ) |
| 599 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 600 | if not onos1Isup: |
| 601 | main.log.report( "ONOS1 didn't start!" ) |
| 602 | |
| 603 | main.step( "Start ONOS-cli" ) |
| 604 | |
| 605 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 606 | |
| 607 | main.step( "Get devices in the network" ) |
| 608 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 609 | main.log.info( listResult ) |
| 610 | time.sleep( 10 ) |
| 611 | main.log.info( "Installing sdn-ip feature" ) |
| 612 | main.ONOScli.featureInstall( "onos-app-sdnip" ) |
| 613 | time.sleep( 10 ) |
| 614 | main.step( "Login all BGP peers and add routes into peers" ) |
| 615 | |
| 616 | main.log.info( "Login Quagga CLI on host3" ) |
| 617 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 618 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 619 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 620 | main.log.info( "Add routes to Quagga on host3" ) |
| 621 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 622 | |
| 623 | main.log.info( "Login Quagga CLI on host4" ) |
| 624 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 625 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 626 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 627 | main.log.info( "Add routes to Quagga on host4" ) |
| 628 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 629 | |
| 630 | for i in range( 101, 201 ): |
| 631 | prefixesHostX = \ |
| 632 | main.QuaggaCliHost.generatePrefixes( str( i ), 10 ) |
| 633 | main.log.info( prefixesHostX ) |
| 634 | for prefix in prefixesHostX: |
| 635 | allRoutesExpected.append( |
| 636 | prefix + "/" + "192.168.40." + str( i - 100 ) ) |
| 637 | |
| 638 | routeIntentsExpectedHostX = \ |
| 639 | main.QuaggaCliHost.generateExpectedOnePeerRouteIntents( |
| 640 | prefixesHostX, "192.168.40." + str( i - 100 ), |
| 641 | "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH ) |
| 642 | routeIntentsExpected = routeIntentsExpected + \ |
| 643 | routeIntentsExpectedHostX |
| 644 | |
| 645 | main.log.info( "Login Quagga CLI on host" + str( i ) ) |
| 646 | QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) ) |
| 647 | QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) ) |
| 648 | main.log.info( |
| 649 | "Enter configuration model of Quagga CLI on host" + str( i ) ) |
| 650 | QuaggaCliHostX.enterConfig( 65000 + i - 100 ) |
| 651 | main.log.info( "Add routes to Quagga on host" + str( i ) ) |
| 652 | QuaggaCliHostX.addRoutes( prefixesHostX, 1 ) |
| 653 | |
| 654 | time.sleep( 60 ) |
| 655 | |
| 656 | # get routes inside SDN-IP |
| 657 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 658 | |
| 659 | # parse routes from ONOS CLI |
| 660 | allRoutesActual = \ |
| 661 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 662 | |
| 663 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 664 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 665 | main.step( "Check routes installed" ) |
| 666 | main.log.info( "Routes expected:" ) |
| 667 | main.log.info( allRoutesStrExpected ) |
| 668 | main.log.info( "Routes get from ONOS CLI:" ) |
| 669 | main.log.info( allRoutesStrActual ) |
| 670 | utilities.assertEquals( |
| 671 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 672 | onpass="***Routes in SDN-IP are correct!***", |
| 673 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 674 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 675 | main.log.report( |
| 676 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 677 | else: |
| 678 | main.log.report( |
| 679 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 680 | |
| 681 | time.sleep( 20 ) |
| 682 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 683 | |
| 684 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 685 | # routeIntentsExpected are generated when generating routes |
| 686 | # get rpoute intents from ONOS CLI |
| 687 | routeIntentsActual = \ |
| 688 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 689 | getIntentsResult ) |
| 690 | routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 691 | routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" ) |
| 692 | main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 693 | main.log.info( routeIntentsStrExpected ) |
| 694 | main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 695 | main.log.info( routeIntentsStrActual ) |
| 696 | utilities.assertEquals( |
| 697 | expect=True, |
| 698 | actual=eq( routeIntentsStrExpected, routeIntentsStrActual ), |
| 699 | onpass="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 700 | correct!***", |
| 701 | onfail="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 702 | wrong!***" ) |
| 703 | |
| 704 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 705 | main.log.report( |
| 706 | "***MultiPointToSinglePoint Intents before deleting routes \ |
| 707 | correct!***" ) |
| 708 | else: |
| 709 | main.log.report( |
| 710 | "***MultiPointToSinglePoint Intents before deleting routes \ |
| 711 | wrong!***" ) |
| 712 | |
| 713 | main.step( "Check BGP PointToPointIntent intents installed" ) |
| 714 | # bgp intents expected |
| 715 | bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents( |
| 716 | SDNIPJSONFILEPATH ) |
| 717 | # get BGP intents from ONOS CLI |
| 718 | bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents( |
| 719 | getIntentsResult ) |
| 720 | |
| 721 | bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" ) |
| 722 | bgpIntentsStrActual = str( bgpIntentsActual ) |
| 723 | main.log.info( "PointToPointIntent intents expected:" ) |
| 724 | main.log.info( bgpIntentsStrExpected ) |
| 725 | main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 726 | main.log.info( bgpIntentsStrActual ) |
| 727 | |
| 728 | utilities.assertEquals( |
| 729 | expect=True, |
| 730 | actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ), |
| 731 | onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 732 | onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 733 | |
| 734 | if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ): |
| 735 | main.log.report( |
| 736 | "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
| 737 | else: |
| 738 | main.log.report( |
| 739 | "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 740 | |
| 741 | #============================= Ping Test ======================== |
| 742 | # wait until all MultiPointToSinglePoint |
| 743 | time.sleep( 20 ) |
| 744 | pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh" |
| 745 | pingTestResultsFile = \ |
| 746 | "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \ |
| 747 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 748 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 749 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 750 | main.log.info( pingTestResults ) |
| 751 | time.sleep( 20 ) |
| 752 | |
| 753 | #============================= Deleting Routes ================== |
| 754 | main.step( "Check deleting routes installed" ) |
| 755 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 756 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 757 | for i in range( 101, 201 ): |
| 758 | prefixesHostX = \ |
| 759 | main.QuaggaCliHost.generatePrefixes( str( i ), 10 ) |
| 760 | main.log.info( prefixesHostX ) |
| 761 | QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) ) |
| 762 | QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 ) |
| 763 | |
| 764 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 765 | allRoutesActual = main.QuaggaCliHost3.extractActualRoutes( |
| 766 | getRoutesResult ) |
| 767 | main.log.info( "allRoutes_actual = " ) |
| 768 | main.log.info( allRoutesActual ) |
| 769 | |
| 770 | utilities.assertEquals( |
| 771 | expect="[]", actual=str( allRoutesActual ), |
| 772 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 773 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 774 | |
| 775 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 776 | main.log.report( |
| 777 | "***Routes in SDN-IP after deleting correct!***" ) |
| 778 | else: |
| 779 | main.log.report( |
| 780 | "***Routes in SDN-IP after deleting wrong!***" ) |
| 781 | |
| 782 | main.step( "Check intents after deleting routes" ) |
| 783 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 784 | routeIntentsActual = \ |
| 785 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 786 | getIntentsResult ) |
| 787 | main.log.info( "main.ONOScli.intents()= " ) |
| 788 | main.log.info( routeIntentsActual ) |
| 789 | utilities.assertEquals( |
| 790 | expect="[]", actual=str( routeIntentsActual ), |
| 791 | onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \ |
| 792 | 0, correct!***", |
| 793 | onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \ |
| 794 | 0, wrong!***" ) |
| 795 | |
| 796 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 797 | main.log.report( |
| 798 | "***MultiPointToSinglePoint Intents after deleting routes \ |
| 799 | correct!***" ) |
| 800 | else: |
| 801 | main.log.report( |
| 802 | "***MultiPointToSinglePoint Intents after deleting routes \ |
| 803 | wrong!***" ) |
| 804 | |
| 805 | time.sleep( 20 ) |
| 806 | pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh" |
| 807 | pingTestResultsFile = \ |
| 808 | "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \ |
| 809 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 810 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 811 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 812 | main.log.info( pingTestResults ) |
| 813 | time.sleep( 100 ) |
| 814 | |
| 815 | # main.step( "Test whether Mininet is started" ) |
| 816 | # main.Mininet2.handle.sendline( "xterm host1" ) |
| 817 | # main.Mininet2.handle.expect( "mininet>" ) |
| 818 | |
| 819 | def CASE1( self, main ): |
| 820 | """ |
| 821 | Test the SDN-IP functionality |
| 822 | allRoutesExpected: all expected routes for all BGP peers |
| 823 | routeIntentsExpected: all expected MultiPointToSinglePointIntent \ |
| 824 | intents |
| 825 | bgpIntentsExpected: expected PointToPointIntent intents |
| 826 | allRoutesActual: all routes from ONOS LCI |
| 827 | routeIntentsActual: actual MultiPointToSinglePointIntent intents \ |
| 828 | from ONOS CLI |
| 829 | bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI |
| 830 | """ |
| 831 | import time |
| 832 | import json |
| 833 | from operator import eq |
| 834 | # from datetime import datetime |
| 835 | from time import localtime, strftime |
| 836 | |
| 837 | main.case("The test case is to help to setup the TestON environment \ |
| 838 | and test new drivers" ) |
| 839 | SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json" |
| 840 | # all expected routes for all BGP peers |
| 841 | allRoutesExpected = [] |
| 842 | main.step( "Start to generate routes for all BGP peers" ) |
| 843 | # bgpPeerHosts = [] |
| 844 | # for i in range( 3, 5 ): |
| 845 | # bgpPeerHosts.append( "host" + str( i ) ) |
| 846 | # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts ) |
| 847 | |
| 848 | # for i in range( 3, 5 ): |
| 849 | # QuaggaCliHost = "QuaggaCliHost" + str( i ) |
| 850 | # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 ) |
| 851 | |
| 852 | # main.log.info( prefixes ) |
| 853 | # allRoutesExpected.append( prefixes ) |
| 854 | main.log.info( "Generate prefixes for host3" ) |
| 855 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 856 | main.log.info( prefixesHost3 ) |
| 857 | # generate route with next hop |
| 858 | for prefix in prefixesHost3: |
| 859 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 860 | routeIntentsExpectedHost3 = \ |
| 861 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 862 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 863 | SDNIPJSONFILEPATH ) |
| 864 | |
| 865 | main.log.info( "Generate prefixes for host4" ) |
| 866 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 867 | main.log.info( prefixesHost4 ) |
| 868 | # generate route with next hop |
| 869 | for prefix in prefixesHost4: |
| 870 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 871 | routeIntentsExpectedHost4 = \ |
| 872 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 873 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 874 | SDNIPJSONFILEPATH ) |
| 875 | |
| 876 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 877 | routeIntentsExpectedHost4 |
| 878 | |
| 879 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 880 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 881 | main.step( "Set cell for ONOS-cli environment" ) |
| 882 | main.ONOScli.setCell( cellName ) |
| 883 | verifyResult = main.ONOSbench.verifyCell() |
| 884 | main.log.report( "Removing raft logs" ) |
| 885 | main.ONOSbench.onosRemoveRaftLogs() |
| 886 | main.log.report( "Uninstalling ONOS" ) |
| 887 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 888 | main.step( "Creating ONOS package" ) |
| 889 | packageResult = main.ONOSbench.onosPackage() |
| 890 | |
| 891 | main.step( "Starting ONOS service" ) |
| 892 | # TODO: start ONOS from Mininet Script |
| 893 | # startResult = main.ONOSbench.onosStart( "127.0.0.1" ) |
| 894 | main.step( "Installing ONOS package" ) |
| 895 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 896 | options="-f", node=ONOS1Ip ) |
| 897 | |
| 898 | main.step( "Checking if ONOS is up yet" ) |
| 899 | time.sleep( 60 ) |
| 900 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 901 | if not onos1Isup: |
| 902 | main.log.report( "ONOS1 didn't start!" ) |
| 903 | |
| 904 | main.step( "Start ONOS-cli" ) |
| 905 | # TODO: change the hardcode in startOnosCli method in ONOS CLI driver |
| 906 | |
| 907 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 908 | |
| 909 | main.step( "Get devices in the network" ) |
| 910 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 911 | main.log.info( listResult ) |
| 912 | time.sleep( 10 ) |
| 913 | main.log.info( "Installing sdn-ip feature" ) |
| 914 | main.ONOScli.featureInstall( "onos-app-sdnip" ) |
| 915 | time.sleep( 10 ) |
| 916 | main.step( "Login all BGP peers and add routes into peers" ) |
| 917 | main.log.info( "Login Quagga CLI on host3" ) |
| 918 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 919 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 920 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 921 | main.log.info( "Add routes to Quagga on host3" ) |
| 922 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 923 | |
| 924 | main.log.info( "Login Quagga CLI on host4" ) |
| 925 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 926 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 927 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 928 | main.log.info( "Add routes to Quagga on host4" ) |
| 929 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 930 | time.sleep( 60 ) |
| 931 | |
| 932 | # get all routes inside SDN-IP |
| 933 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 934 | |
| 935 | # parse routes from ONOS CLI |
| 936 | allRoutesActual = \ |
| 937 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 938 | |
| 939 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 940 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 941 | main.step( "Check routes installed" ) |
| 942 | main.log.info( "Routes expected:" ) |
| 943 | main.log.info( allRoutesStrExpected ) |
| 944 | main.log.info( "Routes get from ONOS CLI:" ) |
| 945 | main.log.info( allRoutesStrActual ) |
| 946 | utilities.assertEquals( |
| 947 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 948 | onpass="***Routes in SDN-IP are correct!***", |
| 949 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 950 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 951 | main.log.report( |
| 952 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 953 | else: |
| 954 | main.log.report( |
| 955 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 956 | |
| 957 | time.sleep( 20 ) |
| 958 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 959 | |
| 960 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 961 | # routeIntentsExpected are generated when generating routes |
| 962 | # get rpoute intents from ONOS CLI |
| 963 | routeIntentsActual = \ |
| 964 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 965 | getIntentsResult ) |
| 966 | routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 967 | routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" ) |
| 968 | main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 969 | main.log.info( routeIntentsStrExpected ) |
| 970 | main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 971 | main.log.info( routeIntentsStrActual ) |
| 972 | utilities.assertEquals( |
| 973 | expect=True, |
| 974 | actual=eq( routeIntentsStrExpected, routeIntentsStrActual ), |
| 975 | onpass="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 976 | correct!***", |
| 977 | onfail="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 978 | wrong!***" ) |
| 979 | |
| 980 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 981 | main.log.report( |
| 982 | "***MultiPointToSinglePoint Intents before deleting routes \ |
| 983 | correct!***" ) |
| 984 | else: |
| 985 | main.log.report( |
| 986 | "***MultiPointToSinglePoint Intents before deleting routes \ |
| 987 | wrong!***" ) |
| 988 | |
| 989 | main.step( "Check BGP PointToPointIntent intents installed" ) |
| 990 | # bgp intents expected |
| 991 | bgpIntentsExpected = \ |
| 992 | main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH ) |
| 993 | # get BGP intents from ONOS CLI |
| 994 | bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents( |
| 995 | getIntentsResult ) |
| 996 | |
| 997 | bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" ) |
| 998 | bgpIntentsStrActual = str( bgpIntentsActual ) |
| 999 | main.log.info( "PointToPointIntent intents expected:" ) |
| 1000 | main.log.info( bgpIntentsStrExpected ) |
| 1001 | main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 1002 | main.log.info( bgpIntentsStrActual ) |
| 1003 | |
| 1004 | utilities.assertEquals( |
| 1005 | expect=True, |
| 1006 | actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ), |
| 1007 | onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 1008 | onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 1009 | |
| 1010 | if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ): |
| 1011 | main.log.report( |
| 1012 | "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
| 1013 | else: |
| 1014 | main.log.report( |
| 1015 | "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 1016 | |
| 1017 | #============================= Ping Test ======================== |
| 1018 | # wait until all MultiPointToSinglePoint |
| 1019 | time.sleep( 20 ) |
| 1020 | pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 1021 | pingTestResultsFile = \ |
| 1022 | "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \ |
| 1023 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 1024 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 1025 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 1026 | main.log.info( pingTestResults ) |
| 1027 | |
| 1028 | # ping test |
| 1029 | |
| 1030 | #============================= Deleting Routes ================== |
| 1031 | main.step( "Check deleting routes installed" ) |
| 1032 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 1033 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 1034 | |
| 1035 | # main.log.info( "main.ONOScli.get_routes_num() = " ) |
| 1036 | # main.log.info( main.ONOScli.getRoutesNum() ) |
| 1037 | # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual= |
| 1038 | # main.ONOScli.getRoutesNum(), |
| 1039 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1040 | allRoutesActual = \ |
| 1041 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1042 | main.log.info( "allRoutes_actual = " ) |
| 1043 | main.log.info( allRoutesActual ) |
| 1044 | |
| 1045 | utilities.assertEquals( |
| 1046 | expect="[]", actual=str( allRoutesActual ), |
| 1047 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 1048 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 1049 | |
| 1050 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1051 | main.log.report( |
| 1052 | "***Routes in SDN-IP after deleting correct!***" ) |
| 1053 | else: |
| 1054 | main.log.report( |
| 1055 | "***Routes in SDN-IP after deleting wrong!***" ) |
| 1056 | |
| 1057 | main.step( "Check intents after deleting routes" ) |
| 1058 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 1059 | routeIntentsActual = \ |
| 1060 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 1061 | getIntentsResult ) |
| 1062 | main.log.info( "main.ONOScli.intents()= " ) |
| 1063 | main.log.info( routeIntentsActual ) |
| 1064 | utilities.assertEquals( |
| 1065 | expect="[]", actual=str( routeIntentsActual ), |
| 1066 | onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \ |
| 1067 | 0, correct!***", |
| 1068 | onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \ |
| 1069 | 0, wrong!***" ) |
| 1070 | |
| 1071 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 1072 | main.log.report( |
| 1073 | "***MultiPointToSinglePoint Intents after deleting routes \ |
| 1074 | correct!***" ) |
| 1075 | else: |
| 1076 | main.log.report( |
| 1077 | "***MultiPointToSinglePoint Intents after deleting routes \ |
| 1078 | wrong!***" ) |
| 1079 | |
| 1080 | time.sleep( 20 ) |
| 1081 | pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 1082 | pingTestResultsFile = \ |
| 1083 | "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \ |
| 1084 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 1085 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 1086 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 1087 | main.log.info( pingTestResults ) |
| 1088 | time.sleep( 30 ) |
| 1089 | |
| 1090 | # main.step( "Test whether Mininet is started" ) |
| 1091 | # main.Mininet2.handle.sendline( "xterm host1" ) |
| 1092 | # main.Mininet2.handle.expect( "mininet>" ) |
| 1093 | |
| 1094 | def CASE2( self, main ): |
| 1095 | """ |
| 1096 | Test the SDN-IP functionality |
| 1097 | allRoutesExpected: all expected routes for all BGP peers |
| 1098 | routeIntentsExpected: all expected MultiPointToSinglePointIntent \ |
| 1099 | intents |
| 1100 | bgpIntentsExpected: expected PointToPointIntent intents |
| 1101 | allRoutesActual: all routes from ONOS LCI |
| 1102 | routeIntentsActual: actual MultiPointToSinglePointIntent intents \ |
| 1103 | from ONOS CLI |
| 1104 | bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI |
| 1105 | """ |
| 1106 | import time |
| 1107 | import json |
| 1108 | from operator import eq |
| 1109 | from time import localtime, strftime |
| 1110 | |
| 1111 | main.case( |
| 1112 | "The test case is to help to setup the TestON environment and \ |
| 1113 | test new drivers" ) |
| 1114 | SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json" |
| 1115 | # all expected routes for all BGP peers |
| 1116 | allRoutesExpected = [] |
| 1117 | main.step( "Start to generate routes for all BGP peers" ) |
| 1118 | |
| 1119 | main.log.info( "Generate prefixes for host3" ) |
| 1120 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 1121 | main.log.info( prefixesHost3 ) |
| 1122 | # generate route with next hop |
| 1123 | for prefix in prefixesHost3: |
| 1124 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1125 | routeIntentsExpectedHost3 = \ |
| 1126 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 1127 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 1128 | SDNIPJSONFILEPATH ) |
| 1129 | |
| 1130 | main.log.info( "Generate prefixes for host4" ) |
| 1131 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 1132 | main.log.info( prefixesHost4 ) |
| 1133 | # generate route with next hop |
| 1134 | for prefix in prefixesHost4: |
| 1135 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1136 | routeIntentsExpectedHost4 = \ |
| 1137 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 1138 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 1139 | SDNIPJSONFILEPATH ) |
| 1140 | |
| 1141 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 1142 | routeIntentsExpectedHost4 |
| 1143 | |
| 1144 | main.log.report( "Removing raft logs" ) |
| 1145 | main.ONOSbench.onosRemoveRaftLogs() |
| 1146 | main.log.report( "Uninstalling ONOS" ) |
| 1147 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 1148 | |
| 1149 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1150 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1151 | main.step( "Set cell for ONOS-cli environment" ) |
| 1152 | main.ONOScli.setCell( cellName ) |
| 1153 | verifyResult = main.ONOSbench.verifyCell() |
| 1154 | # main.log.report( "Removing raft logs" ) |
| 1155 | # main.ONOSbench.onosRemoveRaftLogs() |
| 1156 | # main.log.report( "Uninstalling ONOS" ) |
| 1157 | # main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 1158 | main.step( "Creating ONOS package" ) |
| 1159 | # packageResult = main.ONOSbench.onosPackage() |
| 1160 | |
| 1161 | main.step( "Installing ONOS package" ) |
| 1162 | # onos1InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 1163 | # node=ONOS1Ip ) |
| 1164 | |
| 1165 | main.step( "Checking if ONOS is up yet" ) |
| 1166 | # time.sleep( 60 ) |
| 1167 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1168 | if not onos1Isup: |
| 1169 | main.log.report( "ONOS1 didn't start!" ) |
| 1170 | |
| 1171 | main.step( "Start ONOS-cli" ) |
| 1172 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1173 | |
| 1174 | main.step( "Get devices in the network" ) |
| 1175 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1176 | main.log.info( listResult ) |
| 1177 | time.sleep( 10 ) |
| 1178 | main.log.info( "Installing sdn-ip feature" ) |
| 1179 | main.ONOScli.featureInstall( "onos-app-sdnip" ) |
| 1180 | time.sleep( 10 ) |
| 1181 | |
| 1182 | main.step( "Check BGP PointToPointIntent intents installed" ) |
| 1183 | # bgp intents expected |
| 1184 | bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents( |
| 1185 | SDNIPJSONFILEPATH ) |
| 1186 | # get BGP intents from ONOS CLI |
| 1187 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 1188 | bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents( |
| 1189 | getIntentsResult ) |
| 1190 | |
| 1191 | bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" ) |
| 1192 | bgpIntentsStrActual = str( bgpIntentsActual ) |
| 1193 | main.log.info( "PointToPointIntent intents expected:" ) |
| 1194 | main.log.info( bgpIntentsStrExpected ) |
| 1195 | main.log.info( "PointToPointIntent intents get from ONOS CLI:" ) |
| 1196 | main.log.info( bgpIntentsStrActual ) |
| 1197 | |
| 1198 | utilities.assertEquals( |
| 1199 | expect=True, |
| 1200 | actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ), |
| 1201 | onpass="***PointToPointIntent Intents in SDN-IP are correct!***", |
| 1202 | onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 1203 | |
| 1204 | if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ): |
| 1205 | main.log.report( |
| 1206 | "***PointToPointIntent Intents in SDN-IP are correct!***" ) |
| 1207 | else: |
| 1208 | main.log.report( |
| 1209 | "***PointToPointIntent Intents in SDN-IP are wrong!***" ) |
| 1210 | |
| 1211 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1212 | routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 1213 | pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 1214 | # roundNum = 0; |
| 1215 | # while( True ): |
| 1216 | for roundNum in range( 1, 6 ): |
| 1217 | # round = round + 1; |
| 1218 | main.log.report( "The Round " + str( roundNum ) + |
| 1219 | " test starts................................" ) |
| 1220 | |
| 1221 | main.step( "Login all BGP peers and add routes into peers" ) |
| 1222 | main.log.info( "Login Quagga CLI on host3" ) |
| 1223 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1224 | main.log.info( |
| 1225 | "Enter configuration model of Quagga CLI on host3" ) |
| 1226 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1227 | main.log.info( "Add routes to Quagga on host3" ) |
| 1228 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1229 | |
| 1230 | main.log.info( "Login Quagga CLI on host4" ) |
| 1231 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1232 | main.log.info( |
| 1233 | "Enter configuration model of Quagga CLI on host4" ) |
| 1234 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1235 | main.log.info( "Add routes to Quagga on host4" ) |
| 1236 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 1237 | time.sleep( 60 ) |
| 1238 | |
| 1239 | # get all routes inside SDN-IP |
| 1240 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1241 | |
| 1242 | # parse routes from ONOS CLI |
| 1243 | allRoutesActual = \ |
| 1244 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1245 | |
| 1246 | # allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1247 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1248 | main.step( "Check routes installed" ) |
| 1249 | main.log.info( "Routes expected:" ) |
| 1250 | main.log.info( allRoutesStrExpected ) |
| 1251 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1252 | main.log.info( allRoutesStrActual ) |
| 1253 | utilities.assertEquals( |
| 1254 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1255 | onpass="***Routes in SDN-IP are correct!***", |
| 1256 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1257 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1258 | main.log.report( |
| 1259 | "***Routes in SDN-IP after adding correct!***" ) |
| 1260 | else: |
| 1261 | main.log.report( |
| 1262 | "***Routes in SDN-IP after adding wrong!***" ) |
| 1263 | |
| 1264 | time.sleep( 20 ) |
| 1265 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 1266 | |
| 1267 | main.step( |
| 1268 | "Check MultiPointToSinglePointIntent intents installed" ) |
| 1269 | # routeIntentsExpected are generated when generating routes |
| 1270 | # get route intents from ONOS CLI |
| 1271 | routeIntentsActual = \ |
| 1272 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 1273 | getIntentsResult ) |
| 1274 | # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) ) |
| 1275 | routeIntentsStrActual = str( |
| 1276 | routeIntentsActual ).replace( 'u', "" ) |
| 1277 | main.log.info( "MultiPointToSinglePoint intents expected:" ) |
| 1278 | main.log.info( routeIntentsStrExpected ) |
| 1279 | main.log.info( |
| 1280 | "MultiPointToSinglePoint intents get from ONOS CLI:" ) |
| 1281 | main.log.info( routeIntentsStrActual ) |
| 1282 | utilities.assertEquals( |
| 1283 | expect=True, |
| 1284 | actual=eq( routeIntentsStrExpected, routeIntentsStrActual ), |
| 1285 | onpass="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 1286 | correct!***", |
| 1287 | onfail="***MultiPointToSinglePoint Intents in SDN-IP are \ |
| 1288 | wrong!***" ) |
| 1289 | |
| 1290 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 1291 | main.log.report( |
| 1292 | "***MultiPointToSinglePoint Intents after adding routes \ |
| 1293 | correct!***" ) |
| 1294 | else: |
| 1295 | main.log.report( |
| 1296 | "***MultiPointToSinglePoint Intents after adding routes \ |
| 1297 | wrong!***" ) |
| 1298 | |
| 1299 | #============================= Ping Test ======================== |
| 1300 | # wait until all MultiPointToSinglePoint |
| 1301 | time.sleep( 20 ) |
| 1302 | # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 1303 | pingTestResultsFile = \ |
| 1304 | "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \ |
| 1305 | + str( roundNum ) + "-ping-results-before-delete-routes-" \ |
| 1306 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 1307 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 1308 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 1309 | main.log.info( pingTestResults ) |
| 1310 | # ping test |
| 1311 | |
| 1312 | #============================= Deleting Routes ================== |
| 1313 | main.step( "Check deleting routes installed" ) |
| 1314 | main.log.info( "Delete routes to Quagga on host3" ) |
| 1315 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 1316 | main.log.info( "Delete routes to Quagga on host4" ) |
| 1317 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 1318 | |
| 1319 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1320 | allRoutesActual = \ |
| 1321 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1322 | main.log.info( "allRoutes_actual = " ) |
| 1323 | main.log.info( allRoutesActual ) |
| 1324 | |
| 1325 | utilities.assertEquals( |
| 1326 | expect="[]", actual=str( allRoutesActual ), |
| 1327 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 1328 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 1329 | |
| 1330 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1331 | main.log.report( |
| 1332 | "***Routes in SDN-IP after deleting correct!***" ) |
| 1333 | else: |
| 1334 | main.log.report( |
| 1335 | "***Routes in SDN-IP after deleting wrong!***" ) |
| 1336 | |
| 1337 | main.step( "Check intents after deleting routes" ) |
| 1338 | getIntentsResult = main.ONOScli.intents( jsonFormat=True ) |
| 1339 | routeIntentsActual = \ |
| 1340 | main.QuaggaCliHost3.extractActualRouteIntents( |
| 1341 | getIntentsResult ) |
| 1342 | main.log.info( "main.ONOScli.intents()= " ) |
| 1343 | main.log.info( routeIntentsActual ) |
| 1344 | utilities.assertEquals( |
| 1345 | expect="[]", actual=str( routeIntentsActual ), |
| 1346 | onpass= |
| 1347 | "***MultiPointToSinglePoint Intents number in SDN-IP \ |
| 1348 | is 0, correct!***", |
| 1349 | onfail="***MultiPointToSinglePoint Intents number in SDN-IP \ |
| 1350 | is 0, wrong!***" ) |
| 1351 | |
| 1352 | if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ): |
| 1353 | main.log.report( |
| 1354 | "***MultiPointToSinglePoint Intents after deleting \ |
| 1355 | routes correct!***" ) |
| 1356 | else: |
| 1357 | main.log.report( |
| 1358 | "***MultiPointToSinglePoint Intents after deleting \ |
| 1359 | routes wrong!***" ) |
| 1360 | |
| 1361 | time.sleep( 20 ) |
| 1362 | # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh" |
| 1363 | pingTestResultsFile = \ |
| 1364 | "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \ |
| 1365 | + str( roundNum ) + "-ping-results-after-delete-routes-" \ |
| 1366 | + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt" |
| 1367 | pingTestResults = main.QuaggaCliHost.pingTest( |
| 1368 | "1.168.30.100", pingTestScript, pingTestResultsFile ) |
| 1369 | main.log.info( pingTestResults ) |
| 1370 | time.sleep( 30 ) |
| 1371 | |