pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 1 | # Testing the functionality of SDN-IP with single ONOS instance |
| 2 | class USECASE_SdnipI2: |
| 3 | |
| 4 | def __init__( self ): |
| 5 | self.default = '' |
| 6 | global branchName |
| 7 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 8 | # This case is to setup Mininet testbed |
| 9 | def CASE100( self, main ): |
| 10 | """ |
| 11 | Start mininet |
| 12 | """ |
| 13 | import os |
| 14 | main.log.case( "Start Mininet topology" ) |
| 15 | main.dependencyPath = main.testDir + \ |
| 16 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 17 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 18 | |
| 19 | main.step( "Starting Mininet Topology" ) |
| 20 | topology = main.dependencyPath + main.topology |
| 21 | topoResult = main.Mininet.startNet( topoFile = topology ) |
| 22 | stepResult = topoResult |
| 23 | utilities.assert_equals( expect = main.TRUE, |
| 24 | actual = stepResult, |
| 25 | onpass = "Successfully loaded topology", |
| 26 | onfail = "Failed to load topology" ) |
| 27 | # Exit if topology did not load properly |
| 28 | if not topoResult: |
| 29 | main.cleanup() |
| 30 | main.exit() |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 31 | |
| 32 | # This case is to setup ONOS |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 33 | def CASE101( self, main ): |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 34 | """ |
| 35 | CASE100 is to compile ONOS and install it |
| 36 | Startup sequence: |
| 37 | cell <name> |
| 38 | onos-verify-cell |
| 39 | git pull |
| 40 | mvn clean install |
| 41 | onos-package |
| 42 | onos-install -f |
| 43 | onos-wait-for-start |
| 44 | """ |
| 45 | import json |
| 46 | import time |
| 47 | from operator import eq |
| 48 | |
| 49 | main.case( "Setting up test environment" ) |
| 50 | |
| 51 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 52 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 53 | |
| 54 | main.step( "Applying cell variable to environment" ) |
| 55 | cellResult = main.ONOSbench.setCell( cellName ) |
| 56 | verifyResult = main.ONOSbench.verifyCell() |
| 57 | |
| 58 | branchName = main.ONOSbench.getBranchName() |
| 59 | main.log.info( "ONOS is on branch: " + branchName ) |
| 60 | |
| 61 | main.log.report( "Uninstalling ONOS" ) |
| 62 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 63 | |
| 64 | # cleanInstallResult = main.TRUE |
| 65 | # gitPullResult = main.TRUE |
| 66 | |
| 67 | main.step( "Git pull" ) |
| 68 | gitPullResult = main.ONOSbench.gitPull() |
| 69 | |
| 70 | main.step( "Using mvn clean install" ) |
| 71 | if gitPullResult == main.TRUE: |
| 72 | cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 ) |
| 73 | else: |
| 74 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 75 | "clean install" ) |
| 76 | cleanInstallResult = main.TRUE |
| 77 | |
| 78 | main.ONOSbench.getVersion( report = True ) |
| 79 | |
| 80 | main.step( "Creating ONOS package" ) |
| 81 | packageResult = main.ONOSbench.onosPackage( opTimeout = 500 ) |
| 82 | |
| 83 | main.step( "Installing ONOS package" ) |
| 84 | onos1InstallResult = main.ONOSbench.onosInstall( options = "-f", |
| 85 | node = ONOS1Ip ) |
| 86 | |
| 87 | main.step( "Checking if ONOS is up yet" ) |
| 88 | for i in range( 2 ): |
| 89 | onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 ) |
| 90 | if onos1Isup: |
| 91 | break |
| 92 | if not onos1Isup: |
| 93 | main.log.report( "ONOS1 didn't start!" ) |
| 94 | |
| 95 | cliResult = main.ONOScli.startOnosCli( ONOS1Ip, |
| 96 | commandlineTimeout = 100, onosStartTimeout = 600 ) |
| 97 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 98 | caseResult = ( cleanInstallResult and packageResult and |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 99 | cellResult and verifyResult and |
| 100 | onos1InstallResult and |
| 101 | onos1Isup and cliResult ) |
| 102 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 103 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 104 | onpass = "ONOS startup successful", |
| 105 | onfail = "ONOS startup NOT successful" ) |
| 106 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 107 | if caseResult == main.FALSE: |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 108 | main.cleanup() |
| 109 | main.exit() |
| 110 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 111 | main.step( "Get links in the network" ) |
| 112 | listResult = main.ONOScli.links( jsonFormat = False ) |
| 113 | main.log.info( listResult ) |
| 114 | main.log.info( "Activate sdn-ip application" ) |
| 115 | main.ONOScli.activateApp( "org.onosproject.sdnip" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 116 | |
| 117 | main.log.info( "Wait sdn-ip to finish installing connectivity intents, \ |
| 118 | and the BGP paths in data plane are ready..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 119 | time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 120 | main.log.info( "Wait Quagga to finish delivery all routes to each \ |
| 121 | other and to sdn-ip, plus finish installing all intents..." ) |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 122 | time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) ) |
| 123 | time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) ) |
| 124 | |
| 125 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 126 | def CASE1( self, main ): |
| 127 | ''' |
| 128 | ping test from 3 bgp peers to BGP speaker |
| 129 | ''' |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame^] | 130 | |
| 131 | m2SIntentsNumberActual = main.ONOScli.m2SIntentInstalledNumber() |
| 132 | main.log.info( "MultiPointToSinglePoint intent number actual is:" ) |
| 133 | main.log.info( m2SIntentsNumberActual ) |
| 134 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 135 | main.case( "This case is to check ping between BGP peers and speakers" ) |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 136 | result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 137 | result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 138 | result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 139 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame^] | 140 | |
pingping-lin | b702c60 | 2015-09-10 17:00:29 -0700 | [diff] [blame] | 141 | caseResult = result1 and result2 and result3 |
| 142 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 143 | onpass = "Speaker1 ping peers successful", |
| 144 | onfail = "Speaker1 ping peers NOT successful" ) |
| 145 | |
| 146 | if caseResult == main.FALSE: |
| 147 | main.cleanup() |
| 148 | main.exit() |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 149 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame^] | 150 | |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 151 | def CASE2( self, main ): |
| 152 | ''' |
| 153 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 154 | ''' |
| 155 | main.case( "This case is to check point-to-point intents" ) |
| 156 | main.log.info( "There are %s BGP peers in total " |
| 157 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 158 | main.step( "Get point-to-point intents from ONOS CLI" ) |
| 159 | |
| 160 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 161 | bgpIntentsActualNum = \ |
| 162 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 163 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
| 164 | main.log.info( "bgpIntentsExpected num is:" ) |
| 165 | main.log.info( bgpIntentsExpectedNum ) |
| 166 | main.log.info( "bgpIntentsActual num is:" ) |
| 167 | main.log.info( bgpIntentsActualNum ) |
| 168 | utilities.assertEquals( \ |
| 169 | expect = True, |
| 170 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 171 | onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***", |
| 172 | onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" ) |
| 173 | |
| 174 | |
| 175 | def CASE3( self, main ): |
| 176 | ''' |
| 177 | routes and intents check to all BGP peers |
| 178 | ''' |
| 179 | main.case( "This case is to check routes and intents to all BGP peers" ) |
| 180 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 181 | allRoutesExpected = [] |
| 182 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 183 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 184 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 185 | |
| 186 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 187 | allRoutesActual = \ |
| 188 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 189 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 190 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 191 | |
| 192 | main.step( "Check routes installed" ) |
| 193 | main.log.info( "Routes expected:" ) |
| 194 | main.log.info( allRoutesStrExpected ) |
| 195 | main.log.info( "Routes get from ONOS CLI:" ) |
| 196 | main.log.info( allRoutesStrActual ) |
| 197 | utilities.assertEquals( \ |
| 198 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 199 | onpass = "***Routes in SDN-IP are correct!***", |
| 200 | onfail = "***Routes in SDN-IP are wrong!***" ) |
| 201 | |
| 202 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 203 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 204 | routeIntentsActualNum = \ |
| 205 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 206 | routeIntentsExpectedNum = 3 |
| 207 | |
| 208 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 209 | main.log.info( routeIntentsExpectedNum ) |
| 210 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 211 | main.log.info( routeIntentsActualNum ) |
| 212 | utilities.assertEquals( \ |
| 213 | expect = True, |
| 214 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 215 | onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 216 | correct!***", |
| 217 | onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 218 | wrong!***" ) |
| 219 | |
pingping-lin | 950b50d | 2015-09-14 12:00:08 -0700 | [diff] [blame^] | 220 | |
| 221 | def CASE4( self, main ): |
| 222 | ''' |
| 223 | Ping test in data plane for each route |
| 224 | ''' |
| 225 | main.case( "This case is to check ping for each route" ) |
| 226 | result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" ) |
| 227 | result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" ) |
| 228 | result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" ) |
| 229 | |
| 230 | caseResult = result1 and result2 and result3 |
| 231 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 232 | onpass = "Ping test for each route successful", |
| 233 | onfail = "Ping test for each route NOT successful" ) |
| 234 | |
| 235 | if caseResult == main.FALSE: |
| 236 | main.cleanup() |
| 237 | main.exit() |