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