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