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