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 | ''' |
| 130 | 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] | 131 | result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" ) |
| 132 | result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" ) |
| 133 | result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" ) |
| 134 | |
| 135 | caseResult = result1 and result2 and result3 |
| 136 | utilities.assert_equals( expect = main.TRUE, actual = caseResult, |
| 137 | onpass = "Speaker1 ping peers successful", |
| 138 | onfail = "Speaker1 ping peers NOT successful" ) |
| 139 | |
| 140 | if caseResult == main.FALSE: |
| 141 | main.cleanup() |
| 142 | main.exit() |
pingping-lin | 0ce6062 | 2015-09-10 14:37:33 -0700 | [diff] [blame] | 143 | |
| 144 | def CASE2( self, main ): |
| 145 | ''' |
| 146 | point-to-point intents test for each BGP peer and BGP speaker pair |
| 147 | ''' |
| 148 | main.case( "This case is to check point-to-point intents" ) |
| 149 | main.log.info( "There are %s BGP peers in total " |
| 150 | % main.params[ 'config' ][ 'peerNum' ] ) |
| 151 | main.step( "Get point-to-point intents from ONOS CLI" ) |
| 152 | |
| 153 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 154 | bgpIntentsActualNum = \ |
| 155 | main.QuaggaCliSpeaker1.extractActualBgpIntentNum( getIntentsResult ) |
| 156 | bgpIntentsExpectedNum = int( main.params[ 'config' ][ 'peerNum' ] ) * 6 |
| 157 | main.log.info( "bgpIntentsExpected num is:" ) |
| 158 | main.log.info( bgpIntentsExpectedNum ) |
| 159 | main.log.info( "bgpIntentsActual num is:" ) |
| 160 | main.log.info( bgpIntentsActualNum ) |
| 161 | utilities.assertEquals( \ |
| 162 | expect = True, |
| 163 | actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ), |
| 164 | onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***", |
| 165 | onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" ) |
| 166 | |
| 167 | |
| 168 | def CASE3( self, main ): |
| 169 | ''' |
| 170 | routes and intents check to all BGP peers |
| 171 | ''' |
| 172 | main.case( "This case is to check routes and intents to all BGP peers" ) |
| 173 | |
pingping-lin | 28e7b21 | 2015-09-10 10:14:58 -0700 | [diff] [blame] | 174 | allRoutesExpected = [] |
| 175 | allRoutesExpected.append( "4.0.0.0/24" + "/" + "10.0.4.1" ) |
| 176 | allRoutesExpected.append( "5.0.0.0/24" + "/" + "10.0.5.1" ) |
| 177 | allRoutesExpected.append( "6.0.0.0/24" + "/" + "10.0.6.1" ) |
| 178 | |
| 179 | getRoutesResult = main.ONOScli.routes( jsonFormat = True ) |
| 180 | allRoutesActual = \ |
| 181 | main.QuaggaCliSpeaker1.extractActualRoutesMaster( getRoutesResult ) |
| 182 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 183 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 184 | |
| 185 | main.step( "Check routes installed" ) |
| 186 | main.log.info( "Routes expected:" ) |
| 187 | main.log.info( allRoutesStrExpected ) |
| 188 | main.log.info( "Routes get from ONOS CLI:" ) |
| 189 | main.log.info( allRoutesStrActual ) |
| 190 | utilities.assertEquals( \ |
| 191 | expect = allRoutesStrExpected, actual = allRoutesStrActual, |
| 192 | onpass = "***Routes in SDN-IP are correct!***", |
| 193 | onfail = "***Routes in SDN-IP are wrong!***" ) |
| 194 | |
| 195 | main.step( "Check MultiPointToSinglePointIntent intents installed" ) |
| 196 | getIntentsResult = main.ONOScli.intents( jsonFormat = True ) |
| 197 | routeIntentsActualNum = \ |
| 198 | main.QuaggaCliSpeaker1.extractActualRouteIntentNum( getIntentsResult ) |
| 199 | routeIntentsExpectedNum = 3 |
| 200 | |
| 201 | main.log.info( "MultiPointToSinglePoint Intent Num expected is:" ) |
| 202 | main.log.info( routeIntentsExpectedNum ) |
| 203 | main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" ) |
| 204 | main.log.info( routeIntentsActualNum ) |
| 205 | utilities.assertEquals( \ |
| 206 | expect = True, |
| 207 | actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ), |
| 208 | onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 209 | correct!***", |
| 210 | onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \ |
| 211 | wrong!***" ) |
| 212 | |