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