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