Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1 | # from cupshelpers.config import prefix |
| 2 | |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 3 | # Testing the basic functionality of SDN-IP |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 4 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 5 | class PeeringRouterTest: |
| 6 | |
| 7 | def __init__( self ): |
| 8 | self.default = '' |
| 9 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 10 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 11 | def CASE6 ( self, main): |
| 12 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 13 | import time |
| 14 | import json |
| 15 | from operator import eq |
| 16 | # from datetime import datetime |
| 17 | from time import localtime, strftime |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 18 | |
| 19 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 20 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet" |
| 21 | # Launch mininet topology for this case |
| 22 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py" |
| 23 | main.step( "Launch mininet" ) |
| 24 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 25 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 26 | time.sleep(20) |
| 27 | main.step( "Test whether Mininet is started" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 28 | |
| 29 | #============================= Ping Test ======================== |
| 30 | main.log.info("Start ping test") |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 31 | |
| 32 | for m in range( 3, 6 ): |
| 33 | for n in range( 1, 11 ): |
| 34 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 35 | pingTestResults = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 36 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 37 | if pingTestResults: |
| 38 | main.log.info("Test succeeded") |
| 39 | else: |
| 40 | main.log.info("Test failed") |
| 41 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 42 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 43 | onpass="Default connectivity check PASS", |
| 44 | onfail="Default connectivity check FAIL") |
| 45 | |
| 46 | |
| 47 | def CASE4( self, main): |
| 48 | import time |
| 49 | import json |
| 50 | from operator import eq |
| 51 | # from datetime import datetime |
| 52 | from time import localtime, strftime |
| 53 | |
| 54 | main.case("The test case is to help to setup the TestON environment \ |
| 55 | and test new drivers" ) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 56 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 57 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet" |
| 58 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 59 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 60 | |
| 61 | # Copy the json files to config dir |
| 62 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 63 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 64 | |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 65 | # Launch mininet topology for this case |
| 66 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py" |
| 67 | main.step( "Launch mininet" ) |
| 68 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 69 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 70 | time.sleep(20) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 71 | main.step( "Test whether Mininet is started" ) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 72 | main.log.info( "Login Quagga CLI on host3" ) |
| 73 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 74 | # all expected routes for all BGP peers |
| 75 | allRoutesExpected = [] |
| 76 | main.step( "Start to generate routes for all BGP peers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 77 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 78 | main.log.info( "Generate prefixes for host3" ) |
| 79 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 80 | main.log.info( prefixesHost3 ) |
| 81 | # generate route with next hop |
| 82 | for prefix in prefixesHost3: |
| 83 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 84 | routeIntentsExpectedHost3 = \ |
| 85 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 86 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 87 | SDNIPJSONFILEPATH ) |
| 88 | |
| 89 | main.log.info( "Generate prefixes for host4" ) |
| 90 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 91 | main.log.info( prefixesHost4 ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 92 | # generate route with next hop |
| 93 | for prefix in prefixesHost4: |
| 94 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 95 | routeIntentsExpectedHost4 = \ |
| 96 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 97 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 98 | SDNIPJSONFILEPATH ) |
| 99 | |
| 100 | main.log.info( "Generate prefixes for host5" ) |
| 101 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 102 | main.log.info( prefixesHost5 ) |
| 103 | for prefix in prefixesHost5: |
| 104 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 105 | routeIntentsExpectedHost5 = \ |
| 106 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 107 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 108 | SDNIPJSONFILEPATH ) |
| 109 | |
| 110 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 111 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 112 | |
| 113 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 114 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 115 | main.step( "Set cell for ONOS-cli environment" ) |
| 116 | main.ONOScli.setCell( cellName ) |
| 117 | verifyResult = main.ONOSbench.verifyCell() |
| 118 | |
| 119 | main.log.report( "Removing raft logs" ) |
| 120 | main.ONOSbench.onosRemoveRaftLogs() |
| 121 | main.log.report( "Uninstalling ONOS" ) |
| 122 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 123 | |
| 124 | main.step( "Installing ONOS package" ) |
| 125 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 126 | options="-f", node=ONOS1Ip ) |
| 127 | |
| 128 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 129 | if not onos1Isup: |
| 130 | main.log.report( "ONOS1 didn't start!" ) |
| 131 | |
| 132 | main.step( "Start ONOS-cli" ) |
| 133 | |
| 134 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 135 | |
| 136 | main.step( "Get devices in the network" ) |
| 137 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 138 | main.log.info( listResult ) |
| 139 | time.sleep( 10 ) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 140 | main.log.info( "Installing bgprouter feature" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 141 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 142 | time.sleep( 10 ) |
| 143 | main.step( "Login all BGP peers and add routes into peers" ) |
| 144 | |
| 145 | main.log.info( "Login Quagga CLI on host3" ) |
| 146 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 147 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 148 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 149 | main.log.info( "Add routes to Quagga on host3" ) |
| 150 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 151 | |
| 152 | main.log.info( "Login Quagga CLI on host4" ) |
| 153 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 154 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 155 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 156 | main.log.info( "Add routes to Quagga on host4" ) |
| 157 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 158 | |
| 159 | main.log.info( "Login Quagga CLI on host5" ) |
| 160 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 161 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 162 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 163 | main.log.info( "Add routes to Quagga on host5" ) |
| 164 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 165 | |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 166 | time.sleep( 30 ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 167 | |
| 168 | # get routes inside SDN-IP |
| 169 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 170 | |
| 171 | # parse routes from ONOS CLI |
sanghoshin | e35a8a5 | 2015-02-27 20:47:26 -0800 | [diff] [blame] | 172 | allRoutesActual = \ |
| 173 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 174 | |
| 175 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 176 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 177 | main.step( "Check routes installed" ) |
| 178 | main.log.info( "Routes expected:" ) |
| 179 | main.log.info( allRoutesStrExpected ) |
| 180 | main.log.info( "Routes get from ONOS CLI:" ) |
| 181 | main.log.info( allRoutesStrActual ) |
| 182 | utilities.assertEquals( |
| 183 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 184 | onpass="***Routes in SDN-IP are correct!***", |
| 185 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 186 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 187 | main.log.report( |
| 188 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 189 | else: |
| 190 | main.log.report( |
| 191 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 192 | |
| 193 | #============================= Ping Test ======================== |
| 194 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 195 | main.log.info("Ping test result") |
| 196 | if pingTestResults: |
| 197 | main.log.info("Test succeeded") |
| 198 | else: |
| 199 | main.log.info("Test failed") |
| 200 | |
| 201 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 202 | onpass="Default connectivity check PASS", |
| 203 | onfail="Default connectivity check FAIL") |
| 204 | |
| 205 | #============================= Deleting Routes ================== |
| 206 | main.step( "Check deleting routes installed" ) |
| 207 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 208 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 209 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 210 | |
| 211 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
sanghoshin | e35a8a5 | 2015-02-27 20:47:26 -0800 | [diff] [blame] | 212 | allRoutesActual = \ |
| 213 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 214 | |
| 215 | main.log.info( "allRoutes_actual = " ) |
| 216 | main.log.info( allRoutesActual ) |
| 217 | |
| 218 | utilities.assertEquals( |
| 219 | expect="[]", actual=str( allRoutesActual ), |
| 220 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 221 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 222 | |
| 223 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 224 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 225 | else: |
| 226 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 227 | |
| 228 | #============================= Ping Test ======================== |
| 229 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 230 | main.log.info("Ping test result") |
| 231 | if pingTestResults: |
| 232 | main.log.info("Test succeeded") |
| 233 | else: |
| 234 | main.log.info("Test failed") |
| 235 | |
| 236 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 237 | onpass="disconnect check PASS", |
| 238 | onfail="disconnect check FAIL") |
| 239 | |
sanghoshin | c59d6c5 | 2015-03-03 10:01:07 -0800 | [diff] [blame] | 240 | main.ONOScli.logout() |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 241 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 242 | main.Mininet.stopNet() |
| 243 | time.sleep(10) |
Srikanth Vavilapalli | cf1cd5b | 2015-02-27 17:19:12 -0800 | [diff] [blame] | 244 | |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 245 | def CASE5( self, main ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 246 | import time |
| 247 | import json |
| 248 | from operator import eq |
| 249 | # from datetime import datetime |
| 250 | from time import localtime, strftime |
| 251 | |
| 252 | main.case("The test case is to help to setup the TestON environment \ |
| 253 | and test new drivers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 254 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
sanghoshin | 5f3e7cb | 2015-03-04 18:07:21 -0800 | [diff] [blame] | 255 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet" |
sanghoshin | 017a960 | 2015-03-06 13:11:10 -0800 | [diff] [blame] | 256 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json" |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 257 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 258 | |
| 259 | # Copy the json files to config dir |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 260 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/") |
| 261 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/") |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 262 | |
| 263 | # Launch mininet topology for this case |
| 264 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py" |
| 265 | main.step( "Launch mininet" ) |
| 266 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 267 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 268 | time.sleep(20) |
| 269 | main.step( "Test whether Mininet is started" ) |
| 270 | main.log.info( "Login Quagga CLI on host3" ) |
| 271 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 272 | # all expected routes for all BGP peers |
| 273 | allRoutesExpected = [] |
| 274 | main.step( "Start to generate routes for all BGP peers" ) |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 275 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 276 | main.log.info( "Generate prefixes for host3" ) |
| 277 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 278 | main.log.info( prefixesHost3 ) |
| 279 | # generate route with next hop |
| 280 | for prefix in prefixesHost3: |
| 281 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 282 | routeIntentsExpectedHost3 = \ |
| 283 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 284 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 285 | SDNIPJSONFILEPATH ) |
| 286 | |
| 287 | main.log.info( "Generate prefixes for host4" ) |
| 288 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 289 | main.log.info( prefixesHost4 ) |
| 290 | # generate route with next hop |
| 291 | for prefix in prefixesHost4: |
| 292 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 293 | routeIntentsExpectedHost4 = \ |
| 294 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 295 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 296 | SDNIPJSONFILEPATH ) |
| 297 | |
| 298 | main.log.info( "Generate prefixes for host5" ) |
| 299 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 300 | main.log.info( prefixesHost5 ) |
| 301 | for prefix in prefixesHost5: |
| 302 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 303 | routeIntentsExpectedHost5 = \ |
| 304 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 305 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 306 | SDNIPJSONFILEPATH ) |
| 307 | |
| 308 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 309 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 310 | |
| 311 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 312 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 313 | main.step( "Set cell for ONOS-cli environment" ) |
| 314 | main.ONOScli.setCell( cellName ) |
| 315 | verifyResult = main.ONOSbench.verifyCell() |
| 316 | |
| 317 | main.log.report( "Removing raft logs" ) |
| 318 | main.ONOSbench.onosRemoveRaftLogs() |
| 319 | main.log.report( "Uninstalling ONOS" ) |
| 320 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 321 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 322 | # Copy the cfg files to config dir |
| 323 | main.log.info("Copying two cfg files to onos etc folder") |
| 324 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 325 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 326 | main.step( "Creating ONOS package" ) |
| 327 | packageResult = main.ONOSbench.onosPackage() |
| 328 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 329 | main.step( "Installing ONOS package" ) |
| 330 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 331 | options="-f", node=ONOS1Ip ) |
| 332 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 333 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 334 | if not onos1Isup: |
| 335 | main.log.report( "ONOS1 didn't start!" ) |
| 336 | |
| 337 | main.step( "Start ONOS-cli" ) |
| 338 | |
| 339 | main.ONOScli.startOnosCli( ONOS1Ip ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 340 | main.step( "Get devices in the network" ) |
| 341 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 342 | main.log.info( listResult ) |
| 343 | time.sleep( 10 ) |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 344 | main.log.info( "Installing bgprouter feature" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 345 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 346 | time.sleep( 10 ) |
| 347 | main.step( "Login all BGP peers and add routes into peers" ) |
| 348 | |
| 349 | main.log.info( "Login Quagga CLI on host3" ) |
| 350 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 351 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 352 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 353 | main.log.info( "Add routes to Quagga on host3" ) |
| 354 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 355 | |
| 356 | main.log.info( "Login Quagga CLI on host4" ) |
| 357 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 358 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 359 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 360 | main.log.info( "Add routes to Quagga on host4" ) |
| 361 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 362 | |
| 363 | main.log.info( "Login Quagga CLI on host5" ) |
| 364 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 365 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 366 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 367 | main.log.info( "Add routes to Quagga on host5" ) |
| 368 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 369 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 370 | time.sleep( 30 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 371 | |
| 372 | # get routes inside SDN-IP |
| 373 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 374 | |
| 375 | # parse routes from ONOS CLI |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 376 | allRoutesActual = \ |
| 377 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 378 | |
| 379 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 380 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 381 | main.step( "Check routes installed" ) |
| 382 | main.log.info( "Routes expected:" ) |
| 383 | main.log.info( allRoutesStrExpected ) |
| 384 | main.log.info( "Routes get from ONOS CLI:" ) |
| 385 | main.log.info( allRoutesStrActual ) |
| 386 | utilities.assertEquals( |
| 387 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 388 | onpass="***Routes in SDN-IP are correct!***", |
| 389 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 390 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 391 | main.log.report( |
| 392 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 393 | else: |
| 394 | main.log.report( |
| 395 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 396 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 397 | time.sleep(20) |
| 398 | |
| 399 | #============================= Ping Test ======================== |
| 400 | pingTestResults = main.TRUE |
sanghoshin | 51f0819 | 2015-03-09 15:24:21 -0700 | [diff] [blame] | 401 | sources = ["as2host", "as3host", "as6host"] |
| 402 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 403 | for source in sources: |
| 404 | for target in targets: |
| 405 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 406 | if r == main.FALSE: |
| 407 | pingTestResults = main.FALSE |
| 408 | |
| 409 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 410 | onpass="Router connectivity check PASS", |
| 411 | onfail="Router connectivity check FAIL") |
| 412 | |
| 413 | pingTestResults = main.TRUE |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 414 | for m in range( 3, 6 ): |
| 415 | for n in range( 1, 10 ): |
| 416 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 417 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 418 | if r == main.FALSE: |
| 419 | pingTestResults = main.FALSE |
| 420 | |
| 421 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 422 | onpass="Default connectivity check PASS", |
| 423 | onfail="Default connectivity check FAIL") |
| 424 | |
| 425 | time.sleep(20) |
| 426 | #============================= Deleting Routes ================== |
| 427 | main.step( "Check deleting routes installed" ) |
| 428 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 429 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 430 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 431 | |
| 432 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 433 | allRoutesActual = \ |
| 434 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 435 | |
| 436 | main.log.info( "allRoutes_actual = " ) |
| 437 | main.log.info( allRoutesActual ) |
| 438 | |
| 439 | utilities.assertEquals( |
| 440 | expect="[]", actual=str( allRoutesActual ), |
| 441 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 442 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 443 | |
| 444 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 445 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 446 | else: |
| 447 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 448 | |
| 449 | time.sleep(10) |
| 450 | #============================= Ping Test ======================== |
| 451 | pingTestResults = main.TRUE |
| 452 | for m in range( 4, 6 ): |
| 453 | for n in range( 1, 10 ): |
| 454 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 455 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 456 | if r == main.TRUE: |
| 457 | pingTestResults = main.FALSE |
| 458 | |
| 459 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 460 | onpass="disconnect check PASS", |
| 461 | onfail="disconnect check FAIL") |
| 462 | |
sanghoshin | 51f0819 | 2015-03-09 15:24:21 -0700 | [diff] [blame] | 463 | |
| 464 | time.sleep(20); |
| 465 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 466 | main.ONOScli.logout() |
sanghoshin | 51f0819 | 2015-03-09 15:24:21 -0700 | [diff] [blame] | 467 | main.log.info("ONOS cli logout") |
| 468 | time.sleep(20); |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 469 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 51f0819 | 2015-03-09 15:24:21 -0700 | [diff] [blame] | 470 | main.log.info("onos stop") |
| 471 | time.sleep(20); |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 472 | main.Mininet.stopNet() |
sanghoshin | 51f0819 | 2015-03-09 15:24:21 -0700 | [diff] [blame] | 473 | main.log.info("mininet stop") |
| 474 | time.sleep(20) |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 475 | |
| 476 | |
| 477 | def CASE7( self, main ): |
| 478 | import time |
| 479 | import json |
| 480 | from operator import eq |
| 481 | # from datetime import datetime |
| 482 | from time import localtime, strftime |
| 483 | |
| 484 | main.case("The test case is to help to setup the TestON environment \ |
| 485 | and test new drivers" ) |
| 486 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 487 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet" |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 488 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json" |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 489 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 490 | |
| 491 | # Copy the json files to config dir |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 492 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/") |
| 493 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/") |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 494 | |
| 495 | # Launch mininet topology for this case |
| 496 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py" |
| 497 | main.step( "Launch mininet" ) |
| 498 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 499 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 500 | time.sleep(20) |
| 501 | main.step( "Test whether Mininet is started" ) |
| 502 | main.log.info( "Login Quagga CLI on host3" ) |
| 503 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 504 | # all expected routes for all BGP peers |
| 505 | allRoutesExpected = [] |
| 506 | main.step( "Start to generate routes for all BGP peers" ) |
| 507 | |
| 508 | main.log.info( "Generate prefixes for host3" ) |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 509 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 3500 ) |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 510 | main.log.info( prefixesHost3 ) |
| 511 | # generate route with next hop |
| 512 | for prefix in prefixesHost3: |
| 513 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 514 | routeIntentsExpectedHost3 = \ |
| 515 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 516 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 517 | SDNIPJSONFILEPATH ) |
| 518 | main.log.info( "Generate prefixes for host4" ) |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 519 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 3500 ) |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 520 | main.log.info( prefixesHost4 ) |
| 521 | # generate route with next hop |
| 522 | for prefix in prefixesHost4: |
| 523 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 524 | routeIntentsExpectedHost4 = \ |
| 525 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 526 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 527 | SDNIPJSONFILEPATH ) |
| 528 | |
| 529 | main.log.info( "Generate prefixes for host5" ) |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 530 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 3500 ) |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 531 | main.log.info( prefixesHost5 ) |
| 532 | for prefix in prefixesHost5: |
| 533 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 534 | routeIntentsExpectedHost5 = \ |
| 535 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 536 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 537 | SDNIPJSONFILEPATH ) |
| 538 | |
| 539 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 540 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 541 | |
| 542 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 543 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 544 | main.step( "Set cell for ONOS-cli environment" ) |
| 545 | main.ONOScli.setCell( cellName ) |
| 546 | verifyResult = main.ONOSbench.verifyCell() |
| 547 | |
| 548 | main.log.report( "Removing raft logs" ) |
| 549 | main.ONOSbench.onosRemoveRaftLogs() |
| 550 | main.log.report( "Uninstalling ONOS" ) |
| 551 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 552 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 553 | # Copy the cfg files to config dir |
| 554 | main.log.info("Copying two cfg files to onos etc folder") |
| 555 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 556 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 557 | main.step( "Creating ONOS package" ) |
| 558 | packageResult = main.ONOSbench.onosPackage() |
| 559 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 560 | main.step( "Installing ONOS package" ) |
| 561 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 562 | options="-f", node=ONOS1Ip ) |
| 563 | |
| 564 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 565 | if not onos1Isup: |
| 566 | main.log.report( "ONOS1 didn't start!" ) |
| 567 | |
| 568 | main.step( "Start ONOS-cli" ) |
| 569 | |
| 570 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 571 | main.step( "Get devices in the network" ) |
| 572 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 573 | main.log.info( listResult ) |
| 574 | time.sleep( 10 ) |
| 575 | main.log.info( "Installing bgprouter feature" ) |
| 576 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 577 | time.sleep( 10 ) |
| 578 | main.step( "Login all BGP peers and add routes into peers" ) |
| 579 | |
| 580 | main.log.info( "Login Quagga CLI on host3" ) |
| 581 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 582 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 583 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 584 | main.log.info( "Add routes to Quagga on host3" ) |
| 585 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 586 | |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 587 | time.sleep(20) |
| 588 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 589 | main.log.info( "Login Quagga CLI on host4" ) |
| 590 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 591 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 592 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 593 | main.log.info( "Add routes to Quagga on host4" ) |
| 594 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 595 | |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 596 | time.sleep(20) |
| 597 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 598 | main.log.info( "Login Quagga CLI on host5" ) |
| 599 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 600 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 601 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 602 | main.log.info( "Add routes to Quagga on host5" ) |
| 603 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 604 | |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 605 | time.sleep(60) |
| 606 | |
| 607 | # get routes inside SDN-IP |
| 608 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 609 | |
| 610 | # parse routes from ONOS CLI |
| 611 | allRoutesActual = \ |
| 612 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 613 | |
| 614 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 615 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 616 | |
| 617 | # get routes inside SDN-IP |
| 618 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 619 | |
| 620 | # parse routes from ONOS CLI |
| 621 | allRoutesActual = \ |
| 622 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 623 | |
| 624 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 625 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 626 | main.step( "Check routes installed" ) |
| 627 | main.log.info( "Routes expected:" ) |
| 628 | main.log.info( allRoutesStrExpected ) |
| 629 | main.log.info( "Routes get from ONOS CLI:" ) |
| 630 | main.log.info( allRoutesStrActual ) |
| 631 | utilities.assertEquals( |
| 632 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 633 | onpass="***Routes in SDN-IP are correct!***", |
| 634 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 635 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 636 | main.log.report( |
| 637 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 638 | else: |
| 639 | main.log.report( |
| 640 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 641 | |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 642 | time.sleep(20) |
| 643 | |
| 644 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 645 | #============================= Ping Test ======================== |
sanghoshin | 7050200 | 2015-03-11 10:21:14 -0700 | [diff] [blame] | 646 | pingTestResults = main.TRUE |
| 647 | for m in range( 3, 6 ): |
| 648 | for n in range( 1, 10 ): |
| 649 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 650 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 651 | if r == main.FALSE: |
| 652 | pingTestResults = main.FALSE |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 653 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 654 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 655 | onpass="Default connectivity check PASS", |
| 656 | onfail="Default connectivity check FAIL") |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame] | 657 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 658 | time.sleep(10) |
| 659 | |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 660 | main.ONOScli.logout() |
| 661 | main.log.info("ONOS cli logout") |
| 662 | time.sleep(20); |
| 663 | main.ONOSbench.onosStop(ONOS1Ip); |
| 664 | main.log.info("onos stop") |
| 665 | time.sleep(20); |
| 666 | main.Mininet.stopNet() |
| 667 | main.log.info("mininet stop") |
| 668 | time.sleep(20) |
| 669 | |
| 670 | # Route flap test (Add a route and detele it very fast 20 times) in VLAN configuration |
| 671 | def CASE8( self, main ): |
| 672 | import time |
| 673 | import json |
| 674 | from operator import eq |
| 675 | # from datetime import datetime |
| 676 | from time import localtime, strftime |
| 677 | |
| 678 | main.case("The test case is to help to setup the TestON environment \ |
| 679 | and test new drivers" ) |
| 680 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 681 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet" |
| 682 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json" |
| 683 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 684 | |
| 685 | # Copy the json files to config dir |
| 686 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/") |
| 687 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/") |
| 688 | |
| 689 | # Launch mininet topology for this case |
| 690 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py" |
| 691 | main.step( "Launch mininet" ) |
| 692 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 693 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 694 | time.sleep(20) |
| 695 | main.step( "Test whether Mininet is started" ) |
| 696 | main.log.info( "Login Quagga CLI on host3" ) |
| 697 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 698 | # all expected routes for all BGP peers |
| 699 | allRoutesExpected = [] |
| 700 | main.step( "Start to generate routes for all BGP peers" ) |
| 701 | |
| 702 | main.log.info( "Generate prefixes for host3" ) |
| 703 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 1 ) |
| 704 | main.log.info( prefixesHost3 ) |
| 705 | # generate route with next hop |
| 706 | for prefix in prefixesHost3: |
| 707 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 708 | routeIntentsExpectedHost3 = \ |
| 709 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 710 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 711 | SDNIPJSONFILEPATH ) |
| 712 | |
| 713 | main.log.info( "Generate prefixes for host5" ) |
| 714 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 1 ) |
| 715 | main.log.info( prefixesHost5 ) |
| 716 | for prefix in prefixesHost5: |
| 717 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 718 | routeIntentsExpectedHost5 = \ |
| 719 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 720 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 721 | SDNIPJSONFILEPATH ) |
| 722 | |
| 723 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 724 | routeIntentsExpectedHost5 |
| 725 | |
| 726 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 727 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 728 | main.step( "Set cell for ONOS-cli environment" ) |
| 729 | main.ONOScli.setCell( cellName ) |
| 730 | verifyResult = main.ONOSbench.verifyCell() |
| 731 | |
| 732 | main.log.report( "Removing raft logs" ) |
| 733 | main.ONOSbench.onosRemoveRaftLogs() |
| 734 | main.log.report( "Uninstalling ONOS" ) |
| 735 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 736 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 737 | # Copy the cfg files to config dir |
| 738 | main.log.info("Copying two cfg files to onos etc folder") |
| 739 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 740 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 741 | main.step( "Creating ONOS package" ) |
| 742 | packageResult = main.ONOSbench.onosPackage() |
| 743 | |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 744 | main.step( "Installing ONOS package" ) |
| 745 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 746 | options="-f", node=ONOS1Ip ) |
| 747 | |
| 748 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 749 | if not onos1Isup: |
| 750 | main.log.report( "ONOS1 didn't start!" ) |
| 751 | |
| 752 | main.step( "Start ONOS-cli" ) |
| 753 | |
| 754 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 755 | main.step( "Get devices in the network" ) |
| 756 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 757 | main.log.info( listResult ) |
| 758 | time.sleep( 10 ) |
| 759 | main.log.info( "Installing bgprouter feature" ) |
| 760 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 761 | time.sleep( 10 ) |
| 762 | main.step( "Login all BGP peers and add routes into peers" ) |
| 763 | |
| 764 | main.log.info( "Login Quagga CLI on host5" ) |
| 765 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 766 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 767 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 768 | main.log.info( "Add routes to Quagga on host5" ) |
| 769 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 770 | |
| 771 | main.log.info( "Login Quagga CLI on host3" ) |
| 772 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 773 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 774 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 775 | main.log.info( "Add and delete a route to Quagga on host3 20 times" ) |
| 776 | for i in range(0, 20): |
| 777 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 778 | main.log.info("Add a route %s times", i) |
| 779 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 780 | main.log.info("Delete the route") |
| 781 | time.sleep(0.1) |
| 782 | |
| 783 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 784 | main.log.info("Add the route finally and wait for 10 sec") |
| 785 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 786 | #============================= Ping Test ======================== |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 787 | for j in range(0, 30): |
| 788 | r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1") |
| 789 | |
| 790 | utilities.assert_equals(expect=main.TRUE,actual=r, |
| 791 | onpass="Default connectivity check PASS", |
| 792 | onfail="Default connectivity check FAIL") |
| 793 | |
| 794 | #time.sleep(20) |
| 795 | |
| 796 | # get routes inside SDN-IP |
| 797 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 798 | |
| 799 | # parse routes from ONOS CLI |
| 800 | allRoutesActual = \ |
| 801 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 802 | |
| 803 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 804 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 805 | |
| 806 | # get routes inside SDN-IP |
| 807 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 808 | |
| 809 | # parse routes from ONOS CLI |
| 810 | allRoutesActual = \ |
| 811 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 812 | |
| 813 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 814 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 815 | main.step( "Check routes installed" ) |
| 816 | main.log.info( "Routes expected:" ) |
| 817 | main.log.info( allRoutesStrExpected ) |
| 818 | main.log.info( "Routes get from ONOS CLI:" ) |
| 819 | main.log.info( allRoutesStrActual ) |
| 820 | utilities.assertEquals( |
| 821 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 822 | onpass="***Routes in SDN-IP are correct!***", |
| 823 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 824 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 825 | main.log.report( |
| 826 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 827 | else: |
| 828 | main.log.report( |
| 829 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 830 | |
| 831 | main.log.info( "Login Quagga CLI on host3" ) |
| 832 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 833 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 834 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 835 | main.log.info( "Add and delete a route to Quagga on host3 20 times" ) |
| 836 | for i in range(0, 20): |
| 837 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 838 | main.log.info("Add a route %s times", i) |
| 839 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 840 | main.log.info("Delete the route") |
| 841 | time.sleep(0.1) |
| 842 | |
| 843 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 844 | |
| 845 | # get routes inside SDN-IP |
| 846 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 847 | |
| 848 | # parse routes from ONOS CLI |
| 849 | allRoutesActual = \ |
| 850 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 851 | |
| 852 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 853 | |
| 854 | # get routes inside SDN-IP |
| 855 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 856 | |
| 857 | # parse routes from ONOS CLI |
| 858 | allRoutesActual = \ |
| 859 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 860 | |
| 861 | allRoutesStrExpected = [] |
| 862 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 863 | main.step( "Check routes installed" ) |
| 864 | main.log.info( "Routes expected:" ) |
| 865 | main.log.info( allRoutesStrExpected ) |
| 866 | main.log.info( "Routes get from ONOS CLI:" ) |
| 867 | main.log.info( allRoutesStrActual ) |
| 868 | utilities.assertEquals( |
| 869 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 870 | onpass="***Routes in SDN-IP are correct!***", |
| 871 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 872 | |
| 873 | for j in range(0, 5): |
| 874 | r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1") |
| 875 | |
| 876 | utilities.assert_equals(expect=main.FALSE,actual=r, |
| 877 | onpass="disconnectivity check PASS", |
| 878 | onfail="disconnectivity check FAIL") |
| 879 | |
| 880 | main.ONOScli.logout() |
| 881 | main.log.info("ONOS cli logout") |
| 882 | time.sleep(20); |
| 883 | main.ONOSbench.onosStop(ONOS1Ip); |
| 884 | main.log.info("onos stop") |
| 885 | time.sleep(20); |
| 886 | main.Mininet.stopNet() |
| 887 | main.log.info("mininet stop") |
| 888 | time.sleep(20) |
| 889 | |
| 890 | # Route flap test (change the next-hop very fast 20 times) in VLAN configuration |
| 891 | def CASE9( self, main): |
| 892 | import time |
| 893 | import json |
| 894 | from operator import eq |
| 895 | # from datetime import datetime |
| 896 | from time import localtime, strftime |
| 897 | |
| 898 | main.case("The test case is to help to setup the TestON environment \ |
| 899 | and test new drivers" ) |
| 900 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 901 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet" |
| 902 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json" |
| 903 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 904 | |
| 905 | # Copy the json files to config dir |
| 906 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/") |
| 907 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/") |
| 908 | |
| 909 | # Launch mininet topology for this case |
| 910 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py" |
| 911 | main.step( "Launch mininet" ) |
| 912 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 913 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 914 | time.sleep(20) |
| 915 | main.step( "Test whether Mininet is started" ) |
| 916 | main.log.info( "Login Quagga CLI on host3" ) |
| 917 | result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 918 | #if result is not main.TRUE: |
| 919 | # main.log.report("Mininet is not started...Aborting") |
| 920 | # main.Mininet.stopNet() |
| 921 | # main.cleanup() |
| 922 | # main.exit() |
| 923 | # all expected routes for all BGP peers |
| 924 | allRoutesExpected = [] |
| 925 | main.step( "Start to generate routes for all BGP peers" ) |
| 926 | main.log.info( "Generate prefixes for host3" ) |
| 927 | |
| 928 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 929 | main.log.info( prefixesHost3 ) |
| 930 | # generate route with next hop |
| 931 | for prefix in prefixesHost3: |
| 932 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 933 | routeIntentsExpectedHost3 = \ |
| 934 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 935 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 936 | SDNIPJSONFILEPATH ) |
| 937 | |
| 938 | main.log.info( "Generate prefixes for host4" ) |
| 939 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 940 | main.log.info( prefixesHost4 ) |
| 941 | # generate route with next hop |
| 942 | for prefix in prefixesHost4: |
| 943 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 944 | routeIntentsExpectedHost4 = \ |
| 945 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 946 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 947 | SDNIPJSONFILEPATH ) |
| 948 | |
| 949 | main.log.info( "Generate prefixes for host5" ) |
| 950 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 951 | main.log.info( prefixesHost5 ) |
| 952 | for prefix in prefixesHost5: |
| 953 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 954 | routeIntentsExpectedHost5 = \ |
| 955 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 956 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 957 | SDNIPJSONFILEPATH ) |
| 958 | |
| 959 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 960 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 961 | |
| 962 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 963 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 964 | main.step( "Set cell for ONOS-cli environment" ) |
| 965 | main.ONOScli.setCell( cellName ) |
| 966 | verifyResult = main.ONOSbench.verifyCell() |
| 967 | utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...") |
| 968 | |
| 969 | main.log.report( "Removing raft logs" ) |
| 970 | main.ONOSbench.onosRemoveRaftLogs() |
| 971 | main.log.report( "Uninstalling ONOS" ) |
| 972 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 973 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 974 | # Copy the cfg files to config dir |
| 975 | main.log.info("Copying two cfg files to onos etc folder") |
| 976 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 977 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 978 | main.step( "Creating ONOS package" ) |
| 979 | packageResult = main.ONOSbench.onosPackage() |
| 980 | |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 981 | main.step( "Installing ONOS package" ) |
| 982 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 983 | options="-f", node=ONOS1Ip ) |
| 984 | if onos1InstallResult is not main.TRUE: |
| 985 | main.log.report("ONOS is not installed...Aborting") |
| 986 | main.Mininet.stopNet() |
| 987 | main.cleanup() |
| 988 | main.exit() |
| 989 | |
| 990 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 991 | if onos1Isup is not main.TRUE: |
| 992 | main.log.report("ONOS1 didn't start!...Aborting" ) |
| 993 | main.Mininet.stopNet() |
| 994 | main.ONOSbench.onosStop(ONOS1Ip); |
| 995 | main.cleanup() |
| 996 | main.exit() |
| 997 | |
| 998 | main.step( "Start ONOS-cli" ) |
| 999 | |
| 1000 | result = main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1001 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...") |
| 1002 | if result is not main.TRUE: |
| 1003 | main.log.report("ONOS1 didn't start!...Aborting" ) |
| 1004 | main.Mininet.stopNet() |
| 1005 | main.ONOScli.logout() |
| 1006 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1007 | main.cleanup() |
| 1008 | main.exit() |
| 1009 | |
| 1010 | |
| 1011 | main.step( "Get devices in the network" ) |
| 1012 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1013 | main.log.info( listResult ) |
| 1014 | time.sleep( 10 ) |
| 1015 | main.log.info( "Installing bgprouter feature" ) |
| 1016 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 1017 | time.sleep( 10 ) |
| 1018 | main.step( "Login all BGP peers and add routes into peers" ) |
| 1019 | |
| 1020 | main.log.info( "Login Quagga CLI on host3" ) |
| 1021 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1022 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 1023 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1024 | main.log.info( "Add routes to Quagga on host3" ) |
| 1025 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1026 | |
| 1027 | main.log.info( "Login Quagga CLI on host4" ) |
| 1028 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1029 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 1030 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1031 | main.log.info( "Add routes to Quagga on host4" ) |
| 1032 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 1033 | |
| 1034 | main.log.info( "Login Quagga CLI on host5" ) |
| 1035 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 1036 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 1037 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 1038 | main.log.info( "Add routes to Quagga on host5" ) |
| 1039 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 1040 | |
| 1041 | time.sleep( 30 ) |
| 1042 | |
| 1043 | # get routes inside SDN-IP |
| 1044 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1045 | |
| 1046 | # parse routes from ONOS CLI |
| 1047 | allRoutesActual = \ |
| 1048 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1049 | |
| 1050 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1051 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1052 | main.step( "Check routes installed" ) |
| 1053 | main.log.info( "Routes expected:" ) |
| 1054 | main.log.info( allRoutesStrExpected ) |
| 1055 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1056 | main.log.info( allRoutesStrActual ) |
| 1057 | utilities.assertEquals( |
| 1058 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1059 | onpass="***Routes in SDN-IP are correct!***", |
| 1060 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1061 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1062 | main.log.report( |
| 1063 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 1064 | else: |
| 1065 | main.log.report( |
| 1066 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 1067 | |
| 1068 | #============= Flap the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1069 | main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1070 | for i in range(0, 20): |
| 1071 | main.log.info("Disable it %s times", i) |
| 1072 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513") |
| 1073 | main.log.info("Enable it again") |
| 1074 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 1075 | time.sleep(0.1) |
| 1076 | main.log.info("Disable it finally") |
| 1077 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513") |
| 1078 | |
| 1079 | main.log.info( "Sleeping for 30 seconds for network to converge" ) |
| 1080 | time.sleep(30) |
| 1081 | # get routes inside SDN-IP |
| 1082 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1083 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1084 | |
| 1085 | # parse routes from ONOS CLI |
| 1086 | newAllRoutesActual = \ |
| 1087 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1088 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1089 | |
| 1090 | # Expected routes with changed next hop |
| 1091 | newAllRoutesExpected = [] |
| 1092 | for prefix in prefixesHost3: |
| 1093 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1094 | for prefix in prefixesHost4: |
| 1095 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1096 | for prefix in prefixesHost5: |
| 1097 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1098 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1099 | main.step( "Check routes installed after convergence-1" ) |
| 1100 | main.log.info( "Routes expected:" ) |
| 1101 | main.log.info( newAllRoutesStrExpected ) |
| 1102 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 1103 | main.log.info( newAllRoutesStrActual ) |
| 1104 | utilities.assertEquals( |
| 1105 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1106 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1107 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1108 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1109 | main.log.report( |
| 1110 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1111 | else: |
| 1112 | main.log.report( |
| 1113 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1114 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1115 | #============================= Ping Test ======================== |
| 1116 | pingTestResults = main.TRUE |
| 1117 | for m in range( 3, 6 ): |
| 1118 | for n in range( 1, 10 ): |
| 1119 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 1120 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 1121 | if r == main.FALSE: |
| 1122 | pingTestResults = main.FALSE |
| 1123 | |
| 1124 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1125 | onpass="Default connectivity check PASS", |
| 1126 | onfail="Default connectivity check FAIL") |
| 1127 | |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 1128 | #============= Flap the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1129 | main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1130 | for i in range(0, 20): |
| 1131 | main.log.info("Disable it %s times", i) |
| 1132 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513") |
| 1133 | main.log.info("Enable it again") |
| 1134 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 1135 | time.sleep(0.1) |
| 1136 | |
| 1137 | main.log.info( "Sleeping for 30 seconds for network to converge" ) |
| 1138 | time.sleep(30) |
| 1139 | |
| 1140 | # get routes inside SDN-IP |
| 1141 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1142 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1143 | |
| 1144 | # parse routes from ONOS CLI |
| 1145 | newAllRoutesActual = \ |
| 1146 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1147 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1148 | |
| 1149 | # Expected routes with changed next hop |
| 1150 | newAllRoutesExpected = [] |
| 1151 | for prefix in prefixesHost3: |
| 1152 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1153 | for prefix in prefixesHost4: |
| 1154 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1155 | for prefix in prefixesHost5: |
| 1156 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1157 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1158 | main.step( "Check routes installed after convergence-2" ) |
| 1159 | main.log.info( "Routes expected:" ) |
| 1160 | main.log.info( newAllRoutesStrExpected ) |
| 1161 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 1162 | main.log.info( newAllRoutesStrActual ) |
| 1163 | utilities.assertEquals( |
| 1164 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1165 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1166 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1167 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1168 | main.log.report( |
| 1169 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1170 | else: |
| 1171 | main.log.report( |
| 1172 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1173 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1174 | #============================= Ping Test ======================== |
| 1175 | pingTestResults = main.TRUE |
| 1176 | for m in range( 3, 6 ): |
| 1177 | for n in range( 1, 10 ): |
| 1178 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 1179 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 1180 | if r == main.FALSE: |
| 1181 | pingTestResults = main.FALSE |
| 1182 | |
| 1183 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1184 | onpass="Default connectivity check PASS", |
| 1185 | onfail="Default connectivity check FAIL") |
| 1186 | |
sanghoshin | 37e2762 | 2015-03-17 10:11:04 -0700 | [diff] [blame] | 1187 | main.ONOScli.logout() |
| 1188 | main.log.info("ONOS cli logout") |
| 1189 | time.sleep(20); |
| 1190 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1191 | main.log.info("onos stop") |
| 1192 | time.sleep(20); |
| 1193 | main.Mininet.stopNet() |
| 1194 | main.log.info("mininet stop") |
| 1195 | time.sleep(20) |
| 1196 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1197 | # Route convergence and connectivity test |
| 1198 | def CASE21( self, main): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1199 | import time |
| 1200 | import json |
| 1201 | from operator import eq |
| 1202 | # from datetime import datetime |
| 1203 | from time import localtime, strftime |
| 1204 | |
| 1205 | main.case("The test case is to help to setup the TestON environment \ |
| 1206 | and test new drivers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1207 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 1208 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet" |
| 1209 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 1210 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 1211 | |
| 1212 | # Copy the json files to config dir |
| 1213 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 1214 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 1215 | |
| 1216 | # Launch mininet topology for this case |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1217 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py" |
| 1218 | main.step( "Launch mininet" ) |
| 1219 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 1220 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 1221 | time.sleep(20) |
| 1222 | main.step( "Test whether Mininet is started" ) |
| 1223 | main.log.info( "Login Quagga CLI on host3" ) |
| 1224 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1225 | # all expected routes for all BGP peers |
| 1226 | allRoutesExpected = [] |
| 1227 | main.step( "Start to generate routes for all BGP peers" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1228 | main.log.info( "Generate prefixes for host3" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1229 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1230 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 1231 | main.log.info( prefixesHost3 ) |
| 1232 | # generate route with next hop |
| 1233 | for prefix in prefixesHost3: |
| 1234 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1235 | routeIntentsExpectedHost3 = \ |
| 1236 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 1237 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 1238 | SDNIPJSONFILEPATH ) |
| 1239 | |
| 1240 | main.log.info( "Generate prefixes for host4" ) |
| 1241 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 1242 | main.log.info( prefixesHost4 ) |
| 1243 | # generate route with next hop |
| 1244 | for prefix in prefixesHost4: |
| 1245 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1246 | routeIntentsExpectedHost4 = \ |
| 1247 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 1248 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 1249 | SDNIPJSONFILEPATH ) |
| 1250 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1251 | main.log.info( "Generate prefixes for host5" ) |
| 1252 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 1253 | main.log.info( prefixesHost5 ) |
| 1254 | for prefix in prefixesHost5: |
| 1255 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1256 | routeIntentsExpectedHost5 = \ |
| 1257 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 1258 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 1259 | SDNIPJSONFILEPATH ) |
| 1260 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1261 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1262 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1263 | |
| 1264 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1265 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1266 | main.step( "Set cell for ONOS-cli environment" ) |
| 1267 | main.ONOScli.setCell( cellName ) |
| 1268 | verifyResult = main.ONOSbench.verifyCell() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1269 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1270 | main.log.report( "Removing raft logs" ) |
| 1271 | main.ONOSbench.onosRemoveRaftLogs() |
| 1272 | main.log.report( "Uninstalling ONOS" ) |
| 1273 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1274 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1275 | # Copy the cfg files to config dir |
| 1276 | main.log.info("Copying two cfg files to onos etc folder") |
| 1277 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1278 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1279 | main.step( "Creating ONOS package" ) |
| 1280 | packageResult = main.ONOSbench.onosPackage() |
| 1281 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1282 | main.step( "Installing ONOS package" ) |
| 1283 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 1284 | options="-f", node=ONOS1Ip ) |
| 1285 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1286 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1287 | if not onos1Isup: |
| 1288 | main.log.report( "ONOS1 didn't start!" ) |
| 1289 | |
| 1290 | main.step( "Start ONOS-cli" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1291 | |
| 1292 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1293 | |
| 1294 | main.step( "Get devices in the network" ) |
| 1295 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1296 | main.log.info( listResult ) |
| 1297 | time.sleep( 10 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1298 | main.log.info( "Installing gbprouter feature" ) |
| 1299 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1300 | time.sleep( 10 ) |
| 1301 | main.step( "Login all BGP peers and add routes into peers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1302 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1303 | main.log.info( "Login Quagga CLI on host3" ) |
| 1304 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1305 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 1306 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1307 | main.log.info( "Add routes to Quagga on host3" ) |
| 1308 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1309 | |
| 1310 | main.log.info( "Login Quagga CLI on host4" ) |
| 1311 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1312 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 1313 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1314 | main.log.info( "Add routes to Quagga on host4" ) |
| 1315 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1316 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1317 | main.log.info( "Login Quagga CLI on host5" ) |
| 1318 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 1319 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 1320 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 1321 | main.log.info( "Add routes to Quagga on host5" ) |
| 1322 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 1323 | |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 1324 | time.sleep( 30 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1325 | |
| 1326 | # get routes inside SDN-IP |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1327 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1328 | |
| 1329 | # parse routes from ONOS CLI |
| 1330 | allRoutesActual = \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1331 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1332 | |
| 1333 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1334 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1335 | main.step( "Check routes installed" ) |
| 1336 | main.log.info( "Routes expected:" ) |
| 1337 | main.log.info( allRoutesStrExpected ) |
| 1338 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1339 | main.log.info( allRoutesStrActual ) |
| 1340 | utilities.assertEquals( |
| 1341 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1342 | onpass="***Routes in SDN-IP are correct!***", |
| 1343 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1344 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1345 | main.log.report( |
| 1346 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 1347 | else: |
| 1348 | main.log.report( |
| 1349 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 1350 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1351 | #============================= Ping Test ======================== |
| 1352 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1353 | main.log.info("Ping test result") |
| 1354 | if pingTestResults: |
| 1355 | main.log.info("Test succeeded") |
| 1356 | else: |
| 1357 | main.log.info("Test failed") |
| 1358 | |
| 1359 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1360 | onpass="Default connectivity check PASS", |
| 1361 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1362 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1363 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1364 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1365 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 1366 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1367 | time.sleep(150) |
| 1368 | # get routes inside SDN-IP |
| 1369 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1370 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1371 | |
| 1372 | # parse routes from ONOS CLI |
| 1373 | newAllRoutesActual = \ |
| 1374 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1375 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1376 | |
| 1377 | # Expected routes with changed next hop |
| 1378 | newAllRoutesExpected = [] |
| 1379 | for prefix in prefixesHost3: |
| 1380 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1381 | for prefix in prefixesHost4: |
| 1382 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1383 | for prefix in prefixesHost5: |
| 1384 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1385 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1386 | main.step( "Check routes installed after convergence-1" ) |
| 1387 | main.log.info( "Routes expected:" ) |
| 1388 | main.log.info( newAllRoutesStrExpected ) |
| 1389 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 1390 | main.log.info( newAllRoutesStrActual ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1391 | utilities.assertEquals( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1392 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1393 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1394 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1395 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1396 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1397 | "***Routes in SDN-IP after convergence are correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1398 | else: |
| 1399 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1400 | "***Routes in SDN-IP after convergence are wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1401 | |
| 1402 | #============================= Ping Test ======================== |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1403 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1404 | main.log.info("Ping test result") |
| 1405 | if pingTestResults: |
| 1406 | main.log.info("Test succeeded") |
| 1407 | else: |
| 1408 | main.log.info("Test failed") |
| 1409 | |
| 1410 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1411 | onpass="Default connectivity check PASS", |
| 1412 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1413 | |
Srikanth Vavilapalli | 43f3a1d | 2015-03-04 11:09:44 -0800 | [diff] [blame] | 1414 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1415 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1416 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 1417 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1418 | time.sleep(150) |
| 1419 | # get routes inside SDN-IP |
| 1420 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1421 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1422 | |
| 1423 | # parse routes from ONOS CLI |
| 1424 | newAllRoutesActual = \ |
| 1425 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1426 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1427 | |
| 1428 | # Expected routes with changed next hop |
| 1429 | newAllRoutesExpected = [] |
| 1430 | for prefix in prefixesHost3: |
| 1431 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1432 | for prefix in prefixesHost4: |
| 1433 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1434 | for prefix in prefixesHost5: |
| 1435 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1436 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1437 | main.step( "Check routes installed after convergence-2" ) |
| 1438 | main.log.info( "Routes expected:" ) |
| 1439 | main.log.info( newAllRoutesStrExpected ) |
| 1440 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 1441 | main.log.info( newAllRoutesStrActual ) |
| 1442 | utilities.assertEquals( |
| 1443 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1444 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1445 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1446 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1447 | main.log.report( |
| 1448 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1449 | else: |
| 1450 | main.log.report( |
| 1451 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1452 | |
| 1453 | #============================= Ping Test ======================== |
| 1454 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1455 | main.log.info("Ping test result") |
| 1456 | if pingTestResults: |
| 1457 | main.log.info("Test succeeded") |
| 1458 | else: |
| 1459 | main.log.info("Test failed") |
| 1460 | |
| 1461 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1462 | onpass="Default connectivity check PASS", |
| 1463 | onfail="Default connectivity check FAIL") |
| 1464 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1465 | #============================= Deleting Routes ================== |
| 1466 | main.step( "Check deleting routes installed" ) |
| 1467 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 1468 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1469 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1470 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1471 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1472 | allRoutesActual = \ |
| 1473 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1474 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1475 | main.log.info( "allRoutes_actual = " ) |
| 1476 | main.log.info( allRoutesActual ) |
| 1477 | |
| 1478 | utilities.assertEquals( |
| 1479 | expect="[]", actual=str( allRoutesActual ), |
| 1480 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 1481 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 1482 | |
| 1483 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1484 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1485 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1486 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1487 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1488 | #============================= Ping Test ======================== |
| 1489 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 1490 | main.log.info("Ping test result") |
| 1491 | if pingTestResults: |
| 1492 | main.log.info("Test succeeded") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1493 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1494 | main.log.info("Test failed") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1495 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1496 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1497 | onpass="disconnect check PASS", |
| 1498 | onfail="disconnect check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1499 | |
sanghoshin | c59d6c5 | 2015-03-03 10:01:07 -0800 | [diff] [blame] | 1500 | main.ONOScli.logout() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 1501 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 1502 | main.Mininet.stopNet() |
| 1503 | time.sleep(10) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 1504 | |
Srikanth Vavilapalli | e538821 | 2015-03-05 13:55:53 -0800 | [diff] [blame] | 1505 | # Route convergence and connectivity test with Route Server |
| 1506 | def CASE22( self, main): |
| 1507 | import time |
| 1508 | import json |
| 1509 | from operator import eq |
| 1510 | # from datetime import datetime |
| 1511 | from time import localtime, strftime |
| 1512 | |
| 1513 | main.case("The test case is to help to setup the TestON environment \ |
| 1514 | and test new drivers" ) |
| 1515 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 1516 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet" |
| 1517 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json" |
| 1518 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 1519 | |
| 1520 | # Copy the json files to config dir |
| 1521 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/") |
| 1522 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/") |
| 1523 | |
| 1524 | # Launch mininet topology for this case |
| 1525 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py" |
| 1526 | main.step( "Launch mininet" ) |
| 1527 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 1528 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 1529 | time.sleep(20) |
| 1530 | main.step( "Test whether Mininet is started" ) |
| 1531 | main.log.info( "Login Quagga CLI on host3" ) |
| 1532 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1533 | # all expected routes for all BGP peers |
| 1534 | allRoutesExpected = [] |
| 1535 | main.step( "Start to generate routes for all BGP peers" ) |
| 1536 | main.log.info( "Generate prefixes for host3" ) |
| 1537 | |
| 1538 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 1539 | main.log.info( prefixesHost3 ) |
| 1540 | # generate route with next hop |
| 1541 | for prefix in prefixesHost3: |
| 1542 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1543 | routeIntentsExpectedHost3 = \ |
| 1544 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 1545 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 1546 | SDNIPJSONFILEPATH ) |
| 1547 | |
| 1548 | main.log.info( "Generate prefixes for host4" ) |
| 1549 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 1550 | main.log.info( prefixesHost4 ) |
| 1551 | # generate route with next hop |
| 1552 | for prefix in prefixesHost4: |
| 1553 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1554 | routeIntentsExpectedHost4 = \ |
| 1555 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 1556 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 1557 | SDNIPJSONFILEPATH ) |
| 1558 | |
| 1559 | main.log.info( "Generate prefixes for host5" ) |
| 1560 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 1561 | main.log.info( prefixesHost5 ) |
| 1562 | for prefix in prefixesHost5: |
| 1563 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1564 | routeIntentsExpectedHost5 = \ |
| 1565 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 1566 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 1567 | SDNIPJSONFILEPATH ) |
| 1568 | |
| 1569 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 1570 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 1571 | |
| 1572 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1573 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1574 | main.step( "Set cell for ONOS-cli environment" ) |
| 1575 | main.ONOScli.setCell( cellName ) |
| 1576 | verifyResult = main.ONOSbench.verifyCell() |
| 1577 | |
| 1578 | main.log.report( "Removing raft logs" ) |
| 1579 | main.ONOSbench.onosRemoveRaftLogs() |
| 1580 | main.log.report( "Uninstalling ONOS" ) |
| 1581 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 1582 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1583 | # Copy the cfg files to config dir |
| 1584 | main.log.info("Copying two cfg files to onos etc folder") |
| 1585 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1586 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1587 | main.step( "Creating ONOS package" ) |
| 1588 | packageResult = main.ONOSbench.onosPackage() |
| 1589 | |
Srikanth Vavilapalli | e538821 | 2015-03-05 13:55:53 -0800 | [diff] [blame] | 1590 | main.step( "Installing ONOS package" ) |
| 1591 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 1592 | options="-f", node=ONOS1Ip ) |
| 1593 | |
| 1594 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1595 | if not onos1Isup: |
| 1596 | main.log.report( "ONOS1 didn't start!" ) |
| 1597 | |
| 1598 | main.step( "Start ONOS-cli" ) |
| 1599 | |
| 1600 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1601 | |
| 1602 | main.step( "Get devices in the network" ) |
| 1603 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1604 | main.log.info( listResult ) |
| 1605 | time.sleep( 10 ) |
| 1606 | main.log.info( "Installing gbprouter feature" ) |
| 1607 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 1608 | time.sleep( 10 ) |
| 1609 | main.step( "Login all BGP peers and add routes into peers" ) |
| 1610 | |
| 1611 | main.log.info( "Login Quagga CLI on host3" ) |
| 1612 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1613 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 1614 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1615 | main.log.info( "Add routes to Quagga on host3" ) |
| 1616 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1617 | |
| 1618 | main.log.info( "Login Quagga CLI on host4" ) |
| 1619 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1620 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 1621 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1622 | main.log.info( "Add routes to Quagga on host4" ) |
| 1623 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 1624 | |
| 1625 | main.log.info( "Login Quagga CLI on host5" ) |
| 1626 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 1627 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 1628 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 1629 | main.log.info( "Add routes to Quagga on host5" ) |
| 1630 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 1631 | |
| 1632 | time.sleep( 60 ) |
| 1633 | |
| 1634 | # get routes inside SDN-IP |
| 1635 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1636 | |
| 1637 | # parse routes from ONOS CLI |
| 1638 | allRoutesActual = \ |
| 1639 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1640 | |
| 1641 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1642 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1643 | main.step( "Check routes installed" ) |
| 1644 | main.log.info( "Routes expected:" ) |
| 1645 | main.log.info( allRoutesStrExpected ) |
| 1646 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1647 | main.log.info( allRoutesStrActual ) |
| 1648 | utilities.assertEquals( |
| 1649 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1650 | onpass="***Routes in SDN-IP are correct!***", |
| 1651 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1652 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1653 | main.log.report( |
| 1654 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 1655 | else: |
| 1656 | main.log.report( |
| 1657 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 1658 | |
| 1659 | #============================= Ping Test ======================== |
| 1660 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1661 | main.log.info("Ping test result") |
| 1662 | if pingTestResults: |
| 1663 | main.log.info("Test succeeded") |
| 1664 | else: |
| 1665 | main.log.info("Test failed") |
| 1666 | |
| 1667 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1668 | onpass="Default connectivity check PASS", |
| 1669 | onfail="Default connectivity check FAIL") |
| 1670 | |
| 1671 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1672 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1673 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 1674 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1675 | time.sleep(150) |
| 1676 | # get routes inside SDN-IP |
| 1677 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1678 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1679 | |
| 1680 | # parse routes from ONOS CLI |
| 1681 | newAllRoutesActual = \ |
| 1682 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1683 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1684 | |
| 1685 | # Expected routes with changed next hop |
| 1686 | newAllRoutesExpected = [] |
| 1687 | for prefix in prefixesHost3: |
| 1688 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1689 | for prefix in prefixesHost4: |
| 1690 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1691 | for prefix in prefixesHost5: |
| 1692 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1693 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1694 | main.step( "Check routes installed after convergence-1" ) |
| 1695 | main.log.info( "Routes expected:" ) |
| 1696 | main.log.info( newAllRoutesStrExpected ) |
| 1697 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 1698 | main.log.info( newAllRoutesStrActual ) |
| 1699 | utilities.assertEquals( |
| 1700 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1701 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1702 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1703 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1704 | main.log.report( |
| 1705 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1706 | else: |
| 1707 | main.log.report( |
| 1708 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1709 | |
| 1710 | #============================= Ping Test ======================== |
| 1711 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1712 | main.log.info("Ping test result") |
| 1713 | if pingTestResults: |
| 1714 | main.log.info("Test succeeded") |
| 1715 | else: |
| 1716 | main.log.info("Test failed") |
| 1717 | |
| 1718 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1719 | onpass="Default connectivity check PASS", |
| 1720 | onfail="Default connectivity check FAIL") |
| 1721 | |
| 1722 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1723 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1724 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 1725 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1726 | time.sleep(150) |
| 1727 | # get routes inside SDN-IP |
| 1728 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1729 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1730 | |
| 1731 | # parse routes from ONOS CLI |
| 1732 | newAllRoutesActual = \ |
| 1733 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1734 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1735 | |
| 1736 | # Expected routes with changed next hop |
| 1737 | newAllRoutesExpected = [] |
| 1738 | for prefix in prefixesHost3: |
| 1739 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1740 | for prefix in prefixesHost4: |
| 1741 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1742 | for prefix in prefixesHost5: |
| 1743 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1744 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1745 | main.step( "Check routes installed after convergence-2" ) |
| 1746 | main.log.info( "Routes expected:" ) |
| 1747 | main.log.info( newAllRoutesStrExpected ) |
| 1748 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 1749 | main.log.info( newAllRoutesStrActual ) |
| 1750 | utilities.assertEquals( |
| 1751 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1752 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1753 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1754 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1755 | main.log.report( |
| 1756 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1757 | else: |
| 1758 | main.log.report( |
| 1759 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1760 | |
| 1761 | #============================= Ping Test ======================== |
| 1762 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1763 | main.log.info("Ping test result") |
| 1764 | if pingTestResults: |
| 1765 | main.log.info("Test succeeded") |
| 1766 | else: |
| 1767 | main.log.info("Test failed") |
| 1768 | |
| 1769 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1770 | onpass="Default connectivity check PASS", |
| 1771 | onfail="Default connectivity check FAIL") |
| 1772 | |
| 1773 | #============================= Deleting Routes ================== |
| 1774 | main.step( "Check deleting routes installed" ) |
| 1775 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 1776 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 1777 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 1778 | |
| 1779 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1780 | allRoutesActual = \ |
| 1781 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1782 | |
| 1783 | main.log.info( "allRoutes_actual = " ) |
| 1784 | main.log.info( allRoutesActual ) |
| 1785 | |
| 1786 | utilities.assertEquals( |
| 1787 | expect="[]", actual=str( allRoutesActual ), |
| 1788 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 1789 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 1790 | |
| 1791 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1792 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 1793 | else: |
| 1794 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 1795 | |
| 1796 | #============================= Ping Test ======================== |
| 1797 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 1798 | main.log.info("Ping test result") |
| 1799 | if pingTestResults: |
| 1800 | main.log.info("Test succeeded") |
| 1801 | else: |
| 1802 | main.log.info("Test failed") |
| 1803 | |
| 1804 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1805 | onpass="disconnect check PASS", |
| 1806 | onfail="disconnect check FAIL") |
| 1807 | |
| 1808 | main.ONOScli.logout() |
| 1809 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1810 | main.Mininet.stopNet() |
| 1811 | time.sleep(10) |
| 1812 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 1813 | # Route convergence and connectivity test in VLAN configuration |
| 1814 | def CASE31( self, main): |
| 1815 | import time |
| 1816 | import json |
| 1817 | from operator import eq |
| 1818 | # from datetime import datetime |
| 1819 | from time import localtime, strftime |
| 1820 | |
| 1821 | main.case("The test case is to help to setup the TestON environment \ |
| 1822 | and test new drivers" ) |
| 1823 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 1824 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet" |
| 1825 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json" |
| 1826 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 1827 | |
| 1828 | # Copy the json files to config dir |
| 1829 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/") |
| 1830 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/") |
| 1831 | |
| 1832 | # Launch mininet topology for this case |
| 1833 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py" |
| 1834 | main.step( "Launch mininet" ) |
| 1835 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 1836 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 1837 | time.sleep(20) |
| 1838 | main.step( "Test whether Mininet is started" ) |
| 1839 | main.log.info( "Login Quagga CLI on host3" ) |
| 1840 | result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1841 | #if result is not main.TRUE: |
| 1842 | # main.log.report("Mininet is not started...Aborting") |
| 1843 | # main.Mininet.stopNet() |
| 1844 | # main.cleanup() |
| 1845 | # main.exit() |
| 1846 | # all expected routes for all BGP peers |
| 1847 | allRoutesExpected = [] |
| 1848 | main.step( "Start to generate routes for all BGP peers" ) |
| 1849 | main.log.info( "Generate prefixes for host3" ) |
| 1850 | |
| 1851 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 1852 | main.log.info( prefixesHost3 ) |
| 1853 | # generate route with next hop |
| 1854 | for prefix in prefixesHost3: |
| 1855 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1856 | routeIntentsExpectedHost3 = \ |
| 1857 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 1858 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 1859 | SDNIPJSONFILEPATH ) |
| 1860 | |
| 1861 | main.log.info( "Generate prefixes for host4" ) |
| 1862 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 1863 | main.log.info( prefixesHost4 ) |
| 1864 | # generate route with next hop |
| 1865 | for prefix in prefixesHost4: |
| 1866 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1867 | routeIntentsExpectedHost4 = \ |
| 1868 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 1869 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 1870 | SDNIPJSONFILEPATH ) |
| 1871 | |
| 1872 | main.log.info( "Generate prefixes for host5" ) |
| 1873 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 1874 | main.log.info( prefixesHost5 ) |
| 1875 | for prefix in prefixesHost5: |
| 1876 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1877 | routeIntentsExpectedHost5 = \ |
| 1878 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 1879 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 1880 | SDNIPJSONFILEPATH ) |
| 1881 | |
| 1882 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 1883 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 1884 | |
| 1885 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1886 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1887 | main.step( "Set cell for ONOS-cli environment" ) |
| 1888 | main.ONOScli.setCell( cellName ) |
| 1889 | verifyResult = main.ONOSbench.verifyCell() |
| 1890 | utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...") |
| 1891 | |
| 1892 | main.log.report( "Removing raft logs" ) |
| 1893 | main.ONOSbench.onosRemoveRaftLogs() |
| 1894 | main.log.report( "Uninstalling ONOS" ) |
| 1895 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 1896 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1897 | # Copy the cfg files to config dir |
| 1898 | main.log.info("Copying two cfg files to onos etc folder") |
| 1899 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1900 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 1901 | main.step( "Creating ONOS package" ) |
| 1902 | packageResult = main.ONOSbench.onosPackage() |
| 1903 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 1904 | main.step( "Installing ONOS package" ) |
| 1905 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 1906 | options="-f", node=ONOS1Ip ) |
| 1907 | if onos1InstallResult is not main.TRUE: |
| 1908 | main.log.report("ONOS is not installed...Aborting") |
| 1909 | main.Mininet.stopNet() |
| 1910 | main.cleanup() |
| 1911 | main.exit() |
| 1912 | |
| 1913 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1914 | if onos1Isup is not main.TRUE: |
| 1915 | main.log.report("ONOS1 didn't start!...Aborting" ) |
| 1916 | main.Mininet.stopNet() |
| 1917 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1918 | main.cleanup() |
| 1919 | main.exit() |
| 1920 | |
| 1921 | main.step( "Start ONOS-cli" ) |
| 1922 | |
| 1923 | result = main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1924 | utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...") |
| 1925 | if result is not main.TRUE: |
| 1926 | main.log.report("ONOS1 didn't start!...Aborting" ) |
| 1927 | main.Mininet.stopNet() |
| 1928 | main.ONOScli.logout() |
| 1929 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1930 | main.cleanup() |
| 1931 | main.exit() |
| 1932 | |
| 1933 | |
| 1934 | main.step( "Get devices in the network" ) |
| 1935 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1936 | main.log.info( listResult ) |
| 1937 | time.sleep( 10 ) |
| 1938 | main.log.info( "Installing bgprouter feature" ) |
| 1939 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 1940 | time.sleep( 10 ) |
| 1941 | main.step( "Login all BGP peers and add routes into peers" ) |
| 1942 | |
| 1943 | main.log.info( "Login Quagga CLI on host3" ) |
| 1944 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1945 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 1946 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1947 | main.log.info( "Add routes to Quagga on host3" ) |
| 1948 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1949 | |
| 1950 | main.log.info( "Login Quagga CLI on host4" ) |
| 1951 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1952 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 1953 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1954 | main.log.info( "Add routes to Quagga on host4" ) |
| 1955 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 1956 | |
| 1957 | main.log.info( "Login Quagga CLI on host5" ) |
| 1958 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 1959 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 1960 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 1961 | main.log.info( "Add routes to Quagga on host5" ) |
| 1962 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 1963 | |
| 1964 | time.sleep( 30 ) |
| 1965 | |
| 1966 | # get routes inside SDN-IP |
| 1967 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1968 | |
| 1969 | # parse routes from ONOS CLI |
| 1970 | allRoutesActual = \ |
| 1971 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1972 | |
| 1973 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1974 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1975 | main.step( "Check routes installed" ) |
| 1976 | main.log.info( "Routes expected:" ) |
| 1977 | main.log.info( allRoutesStrExpected ) |
| 1978 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1979 | main.log.info( allRoutesStrActual ) |
| 1980 | utilities.assertEquals( |
| 1981 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1982 | onpass="***Routes in SDN-IP are correct!***", |
| 1983 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1984 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1985 | main.log.report( |
| 1986 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 1987 | else: |
| 1988 | main.log.report( |
| 1989 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 1990 | |
| 1991 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 1992 | pingTestResults = main.TRUE |
| 1993 | sources = ["as2host", "as3host", "as6host"] |
| 1994 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 1995 | for source in sources: |
| 1996 | for target in targets: |
| 1997 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 1998 | if r == main.FALSE: |
| 1999 | pingTestResults = main.FALSE |
| 2000 | |
| 2001 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2002 | onpass="Router connectivity check PASS", |
| 2003 | onfail="Router connectivity check FAIL") |
| 2004 | |
| 2005 | pingTestResults = main.TRUE |
| 2006 | for m in range( 3, 6 ): |
| 2007 | for n in range( 1, 10 ): |
| 2008 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2009 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2010 | if r == main.FALSE: |
| 2011 | pingTestResults = main.FALSE |
| 2012 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2013 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2014 | onpass="Default connectivity check PASS", |
| 2015 | onfail="Default connectivity check FAIL") |
| 2016 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2017 | time.sleep(20) |
| 2018 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2019 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 2020 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 2021 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 2022 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 2023 | time.sleep(150) |
| 2024 | # get routes inside SDN-IP |
| 2025 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 2026 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2027 | |
| 2028 | # parse routes from ONOS CLI |
| 2029 | newAllRoutesActual = \ |
| 2030 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2031 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 2032 | |
| 2033 | # Expected routes with changed next hop |
| 2034 | newAllRoutesExpected = [] |
| 2035 | for prefix in prefixesHost3: |
| 2036 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 2037 | for prefix in prefixesHost4: |
| 2038 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2039 | for prefix in prefixesHost5: |
| 2040 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2041 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 2042 | main.step( "Check routes installed after convergence-1" ) |
| 2043 | main.log.info( "Routes expected:" ) |
| 2044 | main.log.info( newAllRoutesStrExpected ) |
| 2045 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 2046 | main.log.info( newAllRoutesStrActual ) |
| 2047 | utilities.assertEquals( |
| 2048 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 2049 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 2050 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 2051 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 2052 | main.log.report( |
| 2053 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 2054 | else: |
| 2055 | main.log.report( |
| 2056 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 2057 | |
| 2058 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2059 | pingTestResults = main.TRUE |
| 2060 | sources = ["as2host", "as3host", "as6host"] |
| 2061 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 2062 | for source in sources: |
| 2063 | for target in targets: |
| 2064 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 2065 | if r == main.FALSE: |
| 2066 | pingTestResults = main.FALSE |
| 2067 | |
| 2068 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2069 | onpass="Router connectivity check PASS", |
| 2070 | onfail="Router connectivity check FAIL") |
| 2071 | |
| 2072 | pingTestResults = main.TRUE |
| 2073 | for m in range( 3, 6 ): |
| 2074 | for n in range( 1, 10 ): |
| 2075 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2076 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2077 | if r == main.FALSE: |
| 2078 | pingTestResults = main.FALSE |
| 2079 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2080 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2081 | onpass="Default connectivity check PASS", |
| 2082 | onfail="Default connectivity check FAIL") |
| 2083 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2084 | time.sleep(20) |
| 2085 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2086 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 2087 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 2088 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 2089 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 2090 | time.sleep(150) |
| 2091 | # get routes inside SDN-IP |
| 2092 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 2093 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2094 | |
| 2095 | # parse routes from ONOS CLI |
| 2096 | newAllRoutesActual = \ |
| 2097 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2098 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 2099 | |
| 2100 | # Expected routes with changed next hop |
| 2101 | newAllRoutesExpected = [] |
| 2102 | for prefix in prefixesHost3: |
| 2103 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 2104 | for prefix in prefixesHost4: |
| 2105 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 2106 | for prefix in prefixesHost5: |
| 2107 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2108 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 2109 | main.step( "Check routes installed after convergence-2" ) |
| 2110 | main.log.info( "Routes expected:" ) |
| 2111 | main.log.info( newAllRoutesStrExpected ) |
| 2112 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 2113 | main.log.info( newAllRoutesStrActual ) |
| 2114 | utilities.assertEquals( |
| 2115 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 2116 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 2117 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 2118 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 2119 | main.log.report( |
| 2120 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 2121 | else: |
| 2122 | main.log.report( |
| 2123 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 2124 | |
| 2125 | #============================= Ping Test ======================== |
| 2126 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 2127 | main.log.info("Ping test result") |
| 2128 | if pingTestResults: |
| 2129 | main.log.info("Test succeeded") |
| 2130 | else: |
| 2131 | main.log.info("Test failed") |
| 2132 | |
| 2133 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2134 | onpass="Default connectivity check PASS", |
| 2135 | onfail="Default connectivity check FAIL") |
| 2136 | |
| 2137 | #============================= Deleting Routes ================== |
| 2138 | main.step( "Check deleting routes installed" ) |
| 2139 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 2140 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 2141 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 2142 | |
| 2143 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2144 | allRoutesActual = \ |
| 2145 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2146 | |
| 2147 | main.log.info( "allRoutes_actual = " ) |
| 2148 | main.log.info( allRoutesActual ) |
| 2149 | |
| 2150 | utilities.assertEquals( |
| 2151 | expect="[]", actual=str( allRoutesActual ), |
| 2152 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 2153 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 2154 | |
| 2155 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 2156 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 2157 | else: |
| 2158 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 2159 | |
| 2160 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2161 | pingTestResults = main.TRUE |
| 2162 | for m in range( 4, 6 ): |
| 2163 | for n in range( 1, 10 ): |
| 2164 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2165 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2166 | if r == main.TRUE: |
| 2167 | pingTestResults = main.FALSE |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2168 | |
| 2169 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2170 | onpass="disconnect check PASS", |
| 2171 | onfail="disconnect check FAIL") |
| 2172 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2173 | time.sleep(20); |
| 2174 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2175 | main.ONOScli.logout() |
| 2176 | main.ONOSbench.onosStop(ONOS1Ip); |
| 2177 | main.Mininet.stopNet() |
| 2178 | time.sleep(10) |
| 2179 | |
| 2180 | # Route convergence and connectivity test with Route Server in VLAN tagged network |
| 2181 | def CASE32( self, main): |
| 2182 | import time |
| 2183 | import json |
| 2184 | from operator import eq |
| 2185 | # from datetime import datetime |
| 2186 | from time import localtime, strftime |
| 2187 | |
| 2188 | main.case("The test case is to help to setup the TestON environment \ |
| 2189 | and test new drivers" ) |
| 2190 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 2191 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/mininet" |
| 2192 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json" |
| 2193 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 2194 | |
| 2195 | # Copy the json files to config dir |
| 2196 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/addresses.json ~/onos/tools/package/config/") |
| 2197 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json ~/onos/tools/package/config/") |
| 2198 | |
| 2199 | # Launch mininet topology for this case |
| 2200 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerVlanMininet.py" |
| 2201 | main.step( "Launch mininet" ) |
| 2202 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 2203 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 2204 | time.sleep(20) |
| 2205 | main.step( "Test whether Mininet is started" ) |
| 2206 | main.log.info( "Login Quagga CLI on host3" ) |
| 2207 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 2208 | # all expected routes for all BGP peers |
| 2209 | allRoutesExpected = [] |
| 2210 | main.step( "Start to generate routes for all BGP peers" ) |
| 2211 | main.log.info( "Generate prefixes for host3" ) |
| 2212 | |
| 2213 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 2214 | main.log.info( prefixesHost3 ) |
| 2215 | # generate route with next hop |
| 2216 | for prefix in prefixesHost3: |
| 2217 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 2218 | routeIntentsExpectedHost3 = \ |
| 2219 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 2220 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 2221 | SDNIPJSONFILEPATH ) |
| 2222 | |
| 2223 | main.log.info( "Generate prefixes for host4" ) |
| 2224 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 2225 | main.log.info( prefixesHost4 ) |
| 2226 | # generate route with next hop |
| 2227 | for prefix in prefixesHost4: |
| 2228 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 2229 | routeIntentsExpectedHost4 = \ |
| 2230 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 2231 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 2232 | SDNIPJSONFILEPATH ) |
| 2233 | |
| 2234 | main.log.info( "Generate prefixes for host5" ) |
| 2235 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 2236 | main.log.info( prefixesHost5 ) |
| 2237 | for prefix in prefixesHost5: |
| 2238 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2239 | routeIntentsExpectedHost5 = \ |
| 2240 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 2241 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 2242 | SDNIPJSONFILEPATH ) |
| 2243 | |
| 2244 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 2245 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 2246 | |
| 2247 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 2248 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 2249 | main.step( "Set cell for ONOS-cli environment" ) |
| 2250 | main.ONOScli.setCell( cellName ) |
| 2251 | verifyResult = main.ONOSbench.verifyCell() |
| 2252 | |
| 2253 | main.log.report( "Removing raft logs" ) |
| 2254 | main.ONOSbench.onosRemoveRaftLogs() |
| 2255 | main.log.report( "Uninstalling ONOS" ) |
| 2256 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 2257 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2258 | # Copy the cfg files to config dir |
| 2259 | main.log.info("Copying two cfg files to onos etc folder") |
| 2260 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 2261 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/org.onosproject.openflow.controller.impl.OpenFlowControllerImpl.cfg ~/onos/tools/package/etc/") |
| 2262 | main.step( "Creating ONOS package" ) |
| 2263 | packageResult = main.ONOSbench.onosPackage() |
| 2264 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2265 | main.step( "Installing ONOS package" ) |
| 2266 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 2267 | options="-f", node=ONOS1Ip ) |
| 2268 | |
| 2269 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 2270 | if not onos1Isup: |
| 2271 | main.log.report( "ONOS1 didn't start!" ) |
| 2272 | |
| 2273 | main.step( "Start ONOS-cli" ) |
| 2274 | |
| 2275 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 2276 | |
| 2277 | main.step( "Get devices in the network" ) |
| 2278 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 2279 | main.log.info( listResult ) |
| 2280 | time.sleep( 10 ) |
| 2281 | main.log.info( "Installing gbprouter feature" ) |
| 2282 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 2283 | time.sleep( 10 ) |
| 2284 | main.step( "Login all BGP peers and add routes into peers" ) |
| 2285 | |
| 2286 | main.log.info( "Login Quagga CLI on host3" ) |
| 2287 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 2288 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 2289 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 2290 | main.log.info( "Add routes to Quagga on host3" ) |
| 2291 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 2292 | |
| 2293 | main.log.info( "Login Quagga CLI on host4" ) |
| 2294 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 2295 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 2296 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 2297 | main.log.info( "Add routes to Quagga on host4" ) |
| 2298 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 2299 | |
| 2300 | main.log.info( "Login Quagga CLI on host5" ) |
| 2301 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 2302 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 2303 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 2304 | main.log.info( "Add routes to Quagga on host5" ) |
| 2305 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 2306 | |
| 2307 | time.sleep( 60 ) |
| 2308 | |
| 2309 | # get routes inside SDN-IP |
| 2310 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2311 | |
| 2312 | # parse routes from ONOS CLI |
| 2313 | allRoutesActual = \ |
| 2314 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2315 | |
| 2316 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 2317 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 2318 | main.step( "Check routes installed" ) |
| 2319 | main.log.info( "Routes expected:" ) |
| 2320 | main.log.info( allRoutesStrExpected ) |
| 2321 | main.log.info( "Routes get from ONOS CLI:" ) |
| 2322 | main.log.info( allRoutesStrActual ) |
| 2323 | utilities.assertEquals( |
| 2324 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 2325 | onpass="***Routes in SDN-IP are correct!***", |
| 2326 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 2327 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 2328 | main.log.report( |
| 2329 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 2330 | else: |
| 2331 | main.log.report( |
| 2332 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 2333 | |
| 2334 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2335 | pingTestResults = main.TRUE |
| 2336 | sources = ["as2host", "as3host", "as6host"] |
| 2337 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 2338 | for source in sources: |
| 2339 | for target in targets: |
| 2340 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 2341 | if r == main.FALSE: |
| 2342 | pingTestResults = main.FALSE |
| 2343 | |
| 2344 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2345 | onpass="Router connectivity check PASS", |
| 2346 | onfail="Router connectivity check FAIL") |
| 2347 | |
| 2348 | pingTestResults = main.TRUE |
| 2349 | for m in range( 3, 6 ): |
| 2350 | for n in range( 1, 10 ): |
| 2351 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2352 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2353 | if r == main.FALSE: |
| 2354 | pingTestResults = main.FALSE |
| 2355 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2356 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2357 | onpass="Default connectivity check PASS", |
| 2358 | onfail="Default connectivity check FAIL") |
| 2359 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2360 | time.sleep(20) |
| 2361 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2362 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 2363 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 2364 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 2365 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 2366 | time.sleep(150) |
| 2367 | # get routes inside SDN-IP |
| 2368 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 2369 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2370 | |
| 2371 | # parse routes from ONOS CLI |
| 2372 | newAllRoutesActual = \ |
| 2373 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2374 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 2375 | |
| 2376 | # Expected routes with changed next hop |
| 2377 | newAllRoutesExpected = [] |
| 2378 | for prefix in prefixesHost3: |
| 2379 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 2380 | for prefix in prefixesHost4: |
| 2381 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2382 | for prefix in prefixesHost5: |
| 2383 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2384 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 2385 | main.step( "Check routes installed after convergence-1" ) |
| 2386 | main.log.info( "Routes expected:" ) |
| 2387 | main.log.info( newAllRoutesStrExpected ) |
| 2388 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 2389 | main.log.info( newAllRoutesStrActual ) |
| 2390 | utilities.assertEquals( |
| 2391 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 2392 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 2393 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 2394 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 2395 | main.log.report( |
| 2396 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 2397 | else: |
| 2398 | main.log.report( |
| 2399 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 2400 | |
| 2401 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2402 | pingTestResults = main.TRUE |
| 2403 | sources = ["as2host", "as3host", "as6host"] |
| 2404 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 2405 | for source in sources: |
| 2406 | for target in targets: |
| 2407 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 2408 | if r == main.FALSE: |
| 2409 | pingTestResults = main.FALSE |
| 2410 | |
| 2411 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2412 | onpass="Router connectivity check PASS", |
| 2413 | onfail="Router connectivity check FAIL") |
| 2414 | |
| 2415 | pingTestResults = main.TRUE |
| 2416 | for m in range( 3, 6 ): |
| 2417 | for n in range( 1, 10 ): |
| 2418 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2419 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2420 | if r == main.FALSE: |
| 2421 | pingTestResults = main.FALSE |
| 2422 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2423 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2424 | onpass="Default connectivity check PASS", |
| 2425 | onfail="Default connectivity check FAIL") |
| 2426 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2427 | time.sleep(20) |
| 2428 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2429 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 2430 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 2431 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 2432 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 2433 | time.sleep(150) |
| 2434 | # get routes inside SDN-IP |
| 2435 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 2436 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2437 | |
| 2438 | # parse routes from ONOS CLI |
| 2439 | newAllRoutesActual = \ |
| 2440 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2441 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 2442 | |
| 2443 | # Expected routes with changed next hop |
| 2444 | newAllRoutesExpected = [] |
| 2445 | for prefix in prefixesHost3: |
| 2446 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 2447 | for prefix in prefixesHost4: |
| 2448 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 2449 | for prefix in prefixesHost5: |
| 2450 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 2451 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 2452 | main.step( "Check routes installed after convergence-2" ) |
| 2453 | main.log.info( "Routes expected:" ) |
| 2454 | main.log.info( newAllRoutesStrExpected ) |
| 2455 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 2456 | main.log.info( newAllRoutesStrActual ) |
| 2457 | utilities.assertEquals( |
| 2458 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 2459 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 2460 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 2461 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 2462 | main.log.report( |
| 2463 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 2464 | else: |
| 2465 | main.log.report( |
| 2466 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 2467 | |
| 2468 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2469 | pingTestResults = main.TRUE |
| 2470 | sources = ["as2host", "as3host", "as6host"] |
| 2471 | targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"] |
| 2472 | for source in sources: |
| 2473 | for target in targets: |
| 2474 | r = main.Mininet.pingHost(SRC=source, TARGET=target) |
| 2475 | if r == main.FALSE: |
| 2476 | pingTestResults = main.FALSE |
| 2477 | |
| 2478 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2479 | onpass="Router connectivity check PASS", |
| 2480 | onfail="Router connectivity check FAIL") |
| 2481 | |
| 2482 | pingTestResults = main.TRUE |
| 2483 | for m in range( 3, 6 ): |
| 2484 | for n in range( 1, 10 ): |
| 2485 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2486 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2487 | if r == main.FALSE: |
| 2488 | pingTestResults = main.FALSE |
| 2489 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2490 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2491 | onpass="Default connectivity check PASS", |
| 2492 | onfail="Default connectivity check FAIL") |
| 2493 | |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2494 | time.sleep(20) |
| 2495 | |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2496 | #============================= Deleting Routes ================== |
| 2497 | main.step( "Check deleting routes installed" ) |
| 2498 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 2499 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 2500 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 2501 | |
| 2502 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 2503 | allRoutesActual = \ |
| 2504 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 2505 | |
| 2506 | main.log.info( "allRoutes_actual = " ) |
| 2507 | main.log.info( allRoutesActual ) |
| 2508 | |
| 2509 | utilities.assertEquals( |
| 2510 | expect="[]", actual=str( allRoutesActual ), |
| 2511 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 2512 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 2513 | |
| 2514 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 2515 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 2516 | else: |
| 2517 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 2518 | |
| 2519 | #============================= Ping Test ======================== |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2520 | pingTestResults = main.TRUE |
| 2521 | for m in range( 4, 6 ): |
| 2522 | for n in range( 1, 10 ): |
| 2523 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 2524 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 2525 | if r == main.TRUE: |
| 2526 | pingTestResults = main.FALSE |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2527 | |
| 2528 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 2529 | onpass="disconnect check PASS", |
| 2530 | onfail="disconnect check FAIL") |
sanghoshin | 5361c28 | 2015-03-20 15:31:16 -0700 | [diff] [blame] | 2531 | time.sleep(20) |
Srikanth Vavilapalli | da0b4e5 | 2015-03-09 16:09:15 -0700 | [diff] [blame] | 2532 | |
| 2533 | main.ONOScli.logout() |
| 2534 | main.ONOSbench.onosStop(ONOS1Ip); |
| 2535 | main.Mininet.stopNet() |
| 2536 | time.sleep(10) |
| 2537 | |