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