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" |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 256 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 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 | |
| 322 | main.step( "Installing ONOS package" ) |
| 323 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 324 | options="-f", node=ONOS1Ip ) |
| 325 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 326 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 327 | if not onos1Isup: |
| 328 | main.log.report( "ONOS1 didn't start!" ) |
| 329 | |
| 330 | main.step( "Start ONOS-cli" ) |
| 331 | |
| 332 | main.ONOScli.startOnosCli( ONOS1Ip ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 333 | main.step( "Get devices in the network" ) |
| 334 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 335 | main.log.info( listResult ) |
| 336 | time.sleep( 10 ) |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 337 | main.log.info( "Installing bgprouter feature" ) |
sanghoshin | a96f1e7 | 2015-02-27 09:30:56 -0800 | [diff] [blame] | 338 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 339 | time.sleep( 10 ) |
| 340 | main.step( "Login all BGP peers and add routes into peers" ) |
| 341 | |
| 342 | main.log.info( "Login Quagga CLI on host3" ) |
| 343 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 344 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 345 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 346 | main.log.info( "Add routes to Quagga on host3" ) |
| 347 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 348 | |
| 349 | main.log.info( "Login Quagga CLI on host4" ) |
| 350 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 351 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 352 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 353 | main.log.info( "Add routes to Quagga on host4" ) |
| 354 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 355 | |
| 356 | main.log.info( "Login Quagga CLI on host5" ) |
| 357 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 358 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 359 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 360 | main.log.info( "Add routes to Quagga on host5" ) |
| 361 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 362 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 363 | time.sleep( 30 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 364 | |
| 365 | # get routes inside SDN-IP |
| 366 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 367 | |
| 368 | # parse routes from ONOS CLI |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 369 | allRoutesActual = \ |
| 370 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 371 | |
| 372 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 373 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 374 | main.step( "Check routes installed" ) |
| 375 | main.log.info( "Routes expected:" ) |
| 376 | main.log.info( allRoutesStrExpected ) |
| 377 | main.log.info( "Routes get from ONOS CLI:" ) |
| 378 | main.log.info( allRoutesStrActual ) |
| 379 | utilities.assertEquals( |
| 380 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 381 | onpass="***Routes in SDN-IP are correct!***", |
| 382 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 383 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 384 | main.log.report( |
| 385 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 386 | else: |
| 387 | main.log.report( |
| 388 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 389 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame^] | 390 | time.sleep(20) |
| 391 | |
| 392 | #============================= Ping Test ======================== |
| 393 | pingTestResults = main.TRUE |
| 394 | for m in range( 3, 6 ): |
| 395 | for n in range( 1, 10 ): |
| 396 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 397 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 398 | if r == main.FALSE: |
| 399 | pingTestResults = main.FALSE |
| 400 | |
| 401 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 402 | onpass="Default connectivity check PASS", |
| 403 | onfail="Default connectivity check FAIL") |
| 404 | |
| 405 | time.sleep(20) |
| 406 | #============================= Deleting Routes ================== |
| 407 | main.step( "Check deleting routes installed" ) |
| 408 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 409 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 410 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 411 | |
| 412 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 413 | allRoutesActual = \ |
| 414 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 415 | |
| 416 | main.log.info( "allRoutes_actual = " ) |
| 417 | main.log.info( allRoutesActual ) |
| 418 | |
| 419 | utilities.assertEquals( |
| 420 | expect="[]", actual=str( allRoutesActual ), |
| 421 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 422 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 423 | |
| 424 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 425 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 426 | else: |
| 427 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 428 | |
| 429 | time.sleep(10) |
| 430 | #============================= Ping Test ======================== |
| 431 | pingTestResults = main.TRUE |
| 432 | for m in range( 4, 6 ): |
| 433 | for n in range( 1, 10 ): |
| 434 | hostIp = str( m ) + ".0." + str( n ) + ".1" |
| 435 | r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp) |
| 436 | if r == main.TRUE: |
| 437 | pingTestResults = main.FALSE |
| 438 | |
| 439 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 440 | onpass="disconnect check PASS", |
| 441 | onfail="disconnect check FAIL") |
| 442 | |
| 443 | main.ONOScli.logout() |
| 444 | main.ONOSbench.onosStop(ONOS1Ip); |
| 445 | main.Mininet.stopNet() |
| 446 | time.sleep(10) |
| 447 | |
| 448 | |
| 449 | def CASE7( self, main ): |
| 450 | import time |
| 451 | import json |
| 452 | from operator import eq |
| 453 | # from datetime import datetime |
| 454 | from time import localtime, strftime |
| 455 | |
| 456 | main.case("The test case is to help to setup the TestON environment \ |
| 457 | and test new drivers" ) |
| 458 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 459 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet" |
| 460 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 461 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 462 | |
| 463 | # Copy the json files to config dir |
| 464 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 465 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 466 | |
| 467 | # Launch mininet topology for this case |
| 468 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py" |
| 469 | main.step( "Launch mininet" ) |
| 470 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 471 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 472 | time.sleep(20) |
| 473 | main.step( "Test whether Mininet is started" ) |
| 474 | main.log.info( "Login Quagga CLI on host3" ) |
| 475 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 476 | # all expected routes for all BGP peers |
| 477 | allRoutesExpected = [] |
| 478 | main.step( "Start to generate routes for all BGP peers" ) |
| 479 | |
| 480 | main.log.info( "Generate prefixes for host3" ) |
| 481 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 255 ) |
| 482 | main.log.info( prefixesHost3 ) |
| 483 | # generate route with next hop |
| 484 | for prefix in prefixesHost3: |
| 485 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 486 | routeIntentsExpectedHost3 = \ |
| 487 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 488 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 489 | SDNIPJSONFILEPATH ) |
| 490 | main.log.info( "Generate prefixes for host4" ) |
| 491 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 255 ) |
| 492 | main.log.info( prefixesHost4 ) |
| 493 | # generate route with next hop |
| 494 | for prefix in prefixesHost4: |
| 495 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 496 | routeIntentsExpectedHost4 = \ |
| 497 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 498 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 499 | SDNIPJSONFILEPATH ) |
| 500 | |
| 501 | main.log.info( "Generate prefixes for host5" ) |
| 502 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 255 ) |
| 503 | main.log.info( prefixesHost5 ) |
| 504 | for prefix in prefixesHost5: |
| 505 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 506 | routeIntentsExpectedHost5 = \ |
| 507 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 508 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 509 | SDNIPJSONFILEPATH ) |
| 510 | |
| 511 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 512 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 513 | |
| 514 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 515 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 516 | main.step( "Set cell for ONOS-cli environment" ) |
| 517 | main.ONOScli.setCell( cellName ) |
| 518 | verifyResult = main.ONOSbench.verifyCell() |
| 519 | |
| 520 | main.log.report( "Removing raft logs" ) |
| 521 | main.ONOSbench.onosRemoveRaftLogs() |
| 522 | main.log.report( "Uninstalling ONOS" ) |
| 523 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 524 | |
| 525 | main.step( "Installing ONOS package" ) |
| 526 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 527 | options="-f", node=ONOS1Ip ) |
| 528 | |
| 529 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 530 | if not onos1Isup: |
| 531 | main.log.report( "ONOS1 didn't start!" ) |
| 532 | |
| 533 | main.step( "Start ONOS-cli" ) |
| 534 | |
| 535 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 536 | main.step( "Get devices in the network" ) |
| 537 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 538 | main.log.info( listResult ) |
| 539 | time.sleep( 10 ) |
| 540 | main.log.info( "Installing bgprouter feature" ) |
| 541 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 542 | time.sleep( 10 ) |
| 543 | main.step( "Login all BGP peers and add routes into peers" ) |
| 544 | |
| 545 | main.log.info( "Login Quagga CLI on host3" ) |
| 546 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 547 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 548 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 549 | main.log.info( "Add routes to Quagga on host3" ) |
| 550 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 551 | |
| 552 | main.log.info( "Login Quagga CLI on host4" ) |
| 553 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 554 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 555 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 556 | main.log.info( "Add routes to Quagga on host4" ) |
| 557 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 558 | |
| 559 | main.log.info( "Login Quagga CLI on host5" ) |
| 560 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 561 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 562 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 563 | main.log.info( "Add routes to Quagga on host5" ) |
| 564 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 565 | |
| 566 | time.sleep( 30 ) |
| 567 | |
| 568 | # get routes inside SDN-IP |
| 569 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 570 | |
| 571 | # parse routes from ONOS CLI |
| 572 | allRoutesActual = \ |
| 573 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 574 | |
| 575 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 576 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 577 | main.step( "Check routes installed" ) |
| 578 | main.log.info( "Routes expected:" ) |
| 579 | main.log.info( allRoutesStrExpected ) |
| 580 | main.log.info( "Routes get from ONOS CLI:" ) |
| 581 | main.log.info( allRoutesStrActual ) |
| 582 | utilities.assertEquals( |
| 583 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 584 | onpass="***Routes in SDN-IP are correct!***", |
| 585 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 586 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 587 | main.log.report( |
| 588 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 589 | else: |
| 590 | main.log.report( |
| 591 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 592 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 593 | #============================= Ping Test ======================== |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 594 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 595 | main.log.info("Ping test result") |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 596 | if pingTestResults: |
| 597 | main.log.info("Test succeeded") |
| 598 | else: |
| 599 | main.log.info("Test failed") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 600 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 601 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 602 | onpass="Default connectivity check PASS", |
| 603 | onfail="Default connectivity check FAIL") |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame^] | 604 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 605 | #============================= Deleting Routes ================== |
| 606 | main.step( "Check deleting routes installed" ) |
| 607 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 608 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 609 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 610 | |
| 611 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 612 | allRoutesActual = \ |
| 613 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
sanghoshin | 29e6a47 | 2015-02-27 12:55:06 -0800 | [diff] [blame] | 614 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 615 | main.log.info( "allRoutes_actual = " ) |
| 616 | main.log.info( allRoutesActual ) |
| 617 | |
| 618 | utilities.assertEquals( |
| 619 | expect="[]", actual=str( allRoutesActual ), |
| 620 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 621 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 622 | |
| 623 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 624 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 625 | else: |
| 626 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 627 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 628 | #============================= Ping Test ======================== |
| 629 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 630 | main.log.info("Ping test result") |
| 631 | if pingTestResults: |
| 632 | main.log.info("Test succeeded") |
| 633 | else: |
| 634 | main.log.info("Test failed") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 635 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 636 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 637 | onpass="disconnect check PASS", |
| 638 | onfail="disconnect check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 639 | |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 640 | main.ONOScli.logout() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 641 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 3de9027 | 2015-03-03 16:10:04 -0800 | [diff] [blame] | 642 | main.Mininet.stopNet() |
| 643 | time.sleep(10) |
| 644 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 645 | |
sanghoshin | b3500fa | 2015-03-06 12:51:29 -0800 | [diff] [blame^] | 646 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 647 | # Route convergence and connectivity test |
| 648 | def CASE21( self, main): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 649 | import time |
| 650 | import json |
| 651 | from operator import eq |
| 652 | # from datetime import datetime |
| 653 | from time import localtime, strftime |
| 654 | |
| 655 | main.case("The test case is to help to setup the TestON environment \ |
| 656 | and test new drivers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 657 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 658 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet" |
| 659 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json" |
| 660 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 661 | |
| 662 | # Copy the json files to config dir |
| 663 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/") |
| 664 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/") |
| 665 | |
| 666 | # Launch mininet topology for this case |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 667 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py" |
| 668 | main.step( "Launch mininet" ) |
| 669 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 670 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 671 | time.sleep(20) |
| 672 | main.step( "Test whether Mininet is started" ) |
| 673 | main.log.info( "Login Quagga CLI on host3" ) |
| 674 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 675 | # all expected routes for all BGP peers |
| 676 | allRoutesExpected = [] |
| 677 | main.step( "Start to generate routes for all BGP peers" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 678 | main.log.info( "Generate prefixes for host3" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 679 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 680 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 681 | main.log.info( prefixesHost3 ) |
| 682 | # generate route with next hop |
| 683 | for prefix in prefixesHost3: |
| 684 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 685 | routeIntentsExpectedHost3 = \ |
| 686 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 687 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 688 | SDNIPJSONFILEPATH ) |
| 689 | |
| 690 | main.log.info( "Generate prefixes for host4" ) |
| 691 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 692 | main.log.info( prefixesHost4 ) |
| 693 | # generate route with next hop |
| 694 | for prefix in prefixesHost4: |
| 695 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 696 | routeIntentsExpectedHost4 = \ |
| 697 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 698 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 699 | SDNIPJSONFILEPATH ) |
| 700 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 701 | main.log.info( "Generate prefixes for host5" ) |
| 702 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 703 | main.log.info( prefixesHost5 ) |
| 704 | for prefix in prefixesHost5: |
| 705 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 706 | routeIntentsExpectedHost5 = \ |
| 707 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 708 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 709 | SDNIPJSONFILEPATH ) |
| 710 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 711 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 712 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 713 | |
| 714 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 715 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 716 | main.step( "Set cell for ONOS-cli environment" ) |
| 717 | main.ONOScli.setCell( cellName ) |
| 718 | verifyResult = main.ONOSbench.verifyCell() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 719 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 720 | main.log.report( "Removing raft logs" ) |
| 721 | main.ONOSbench.onosRemoveRaftLogs() |
| 722 | main.log.report( "Uninstalling ONOS" ) |
| 723 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 724 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 725 | main.step( "Installing ONOS package" ) |
| 726 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 727 | options="-f", node=ONOS1Ip ) |
| 728 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 729 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 730 | if not onos1Isup: |
| 731 | main.log.report( "ONOS1 didn't start!" ) |
| 732 | |
| 733 | main.step( "Start ONOS-cli" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 734 | |
| 735 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 736 | |
| 737 | main.step( "Get devices in the network" ) |
| 738 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 739 | main.log.info( listResult ) |
| 740 | time.sleep( 10 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 741 | main.log.info( "Installing gbprouter feature" ) |
| 742 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 743 | time.sleep( 10 ) |
| 744 | main.step( "Login all BGP peers and add routes into peers" ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 745 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 746 | main.log.info( "Login Quagga CLI on host3" ) |
| 747 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 748 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 749 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 750 | main.log.info( "Add routes to Quagga on host3" ) |
| 751 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 752 | |
| 753 | main.log.info( "Login Quagga CLI on host4" ) |
| 754 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 755 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 756 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 757 | main.log.info( "Add routes to Quagga on host4" ) |
| 758 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 759 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 760 | main.log.info( "Login Quagga CLI on host5" ) |
| 761 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 762 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 763 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 764 | main.log.info( "Add routes to Quagga on host5" ) |
| 765 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 766 | |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 767 | time.sleep( 30 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 768 | |
| 769 | # get routes inside SDN-IP |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 770 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 771 | |
| 772 | # parse routes from ONOS CLI |
| 773 | allRoutesActual = \ |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 774 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 775 | |
| 776 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 777 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 778 | main.step( "Check routes installed" ) |
| 779 | main.log.info( "Routes expected:" ) |
| 780 | main.log.info( allRoutesStrExpected ) |
| 781 | main.log.info( "Routes get from ONOS CLI:" ) |
| 782 | main.log.info( allRoutesStrActual ) |
| 783 | utilities.assertEquals( |
| 784 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 785 | onpass="***Routes in SDN-IP are correct!***", |
| 786 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 787 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 788 | main.log.report( |
| 789 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 790 | else: |
| 791 | main.log.report( |
| 792 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 793 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 794 | #============================= Ping Test ======================== |
| 795 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 796 | main.log.info("Ping test result") |
| 797 | if pingTestResults: |
| 798 | main.log.info("Test succeeded") |
| 799 | else: |
| 800 | main.log.info("Test failed") |
| 801 | |
| 802 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 803 | onpass="Default connectivity check PASS", |
| 804 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 805 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 806 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 807 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 808 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 809 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 810 | time.sleep(150) |
| 811 | # get routes inside SDN-IP |
| 812 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 813 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 814 | |
| 815 | # parse routes from ONOS CLI |
| 816 | newAllRoutesActual = \ |
| 817 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 818 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 819 | |
| 820 | # Expected routes with changed next hop |
| 821 | newAllRoutesExpected = [] |
| 822 | for prefix in prefixesHost3: |
| 823 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 824 | for prefix in prefixesHost4: |
| 825 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 826 | for prefix in prefixesHost5: |
| 827 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 828 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 829 | main.step( "Check routes installed after convergence-1" ) |
| 830 | main.log.info( "Routes expected:" ) |
| 831 | main.log.info( newAllRoutesStrExpected ) |
| 832 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 833 | main.log.info( newAllRoutesStrActual ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 834 | utilities.assertEquals( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 835 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 836 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 837 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 838 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 839 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 840 | "***Routes in SDN-IP after convergence are correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 841 | else: |
| 842 | main.log.report( |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 843 | "***Routes in SDN-IP after convergence are wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 844 | |
| 845 | #============================= Ping Test ======================== |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 846 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 847 | main.log.info("Ping test result") |
| 848 | if pingTestResults: |
| 849 | main.log.info("Test succeeded") |
| 850 | else: |
| 851 | main.log.info("Test failed") |
| 852 | |
| 853 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 854 | onpass="Default connectivity check PASS", |
| 855 | onfail="Default connectivity check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 856 | |
Srikanth Vavilapalli | 43f3a1d | 2015-03-04 11:09:44 -0800 | [diff] [blame] | 857 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 858 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 859 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 860 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 861 | time.sleep(150) |
| 862 | # get routes inside SDN-IP |
| 863 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 864 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 865 | |
| 866 | # parse routes from ONOS CLI |
| 867 | newAllRoutesActual = \ |
| 868 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 869 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 870 | |
| 871 | # Expected routes with changed next hop |
| 872 | newAllRoutesExpected = [] |
| 873 | for prefix in prefixesHost3: |
| 874 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 875 | for prefix in prefixesHost4: |
| 876 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 877 | for prefix in prefixesHost5: |
| 878 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 879 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 880 | main.step( "Check routes installed after convergence-2" ) |
| 881 | main.log.info( "Routes expected:" ) |
| 882 | main.log.info( newAllRoutesStrExpected ) |
| 883 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 884 | main.log.info( newAllRoutesStrActual ) |
| 885 | utilities.assertEquals( |
| 886 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 887 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 888 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 889 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 890 | main.log.report( |
| 891 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 892 | else: |
| 893 | main.log.report( |
| 894 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 895 | |
| 896 | #============================= Ping Test ======================== |
| 897 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 898 | main.log.info("Ping test result") |
| 899 | if pingTestResults: |
| 900 | main.log.info("Test succeeded") |
| 901 | else: |
| 902 | main.log.info("Test failed") |
| 903 | |
| 904 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 905 | onpass="Default connectivity check PASS", |
| 906 | onfail="Default connectivity check FAIL") |
| 907 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 908 | #============================= Deleting Routes ================== |
| 909 | main.step( "Check deleting routes installed" ) |
| 910 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 911 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 912 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 913 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 914 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 915 | allRoutesActual = \ |
| 916 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 917 | |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 918 | main.log.info( "allRoutes_actual = " ) |
| 919 | main.log.info( allRoutesActual ) |
| 920 | |
| 921 | utilities.assertEquals( |
| 922 | expect="[]", actual=str( allRoutesActual ), |
| 923 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 924 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 925 | |
| 926 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 927 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 928 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 929 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 930 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 931 | #============================= Ping Test ======================== |
| 932 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 933 | main.log.info("Ping test result") |
| 934 | if pingTestResults: |
| 935 | main.log.info("Test succeeded") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 936 | else: |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 937 | main.log.info("Test failed") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 938 | |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 939 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 940 | onpass="disconnect check PASS", |
| 941 | onfail="disconnect check FAIL") |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 942 | |
sanghoshin | c59d6c5 | 2015-03-03 10:01:07 -0800 | [diff] [blame] | 943 | main.ONOScli.logout() |
Srikanth Vavilapalli | cf584ff | 2015-03-01 14:12:44 -0800 | [diff] [blame] | 944 | main.ONOSbench.onosStop(ONOS1Ip); |
sanghoshin | 43dbcfb | 2015-03-02 12:02:40 -0800 | [diff] [blame] | 945 | main.Mininet.stopNet() |
| 946 | time.sleep(10) |
Srikanth Vavilapalli | 0abf3f6 | 2015-02-24 21:27:43 -0800 | [diff] [blame] | 947 | |
Srikanth Vavilapalli | e538821 | 2015-03-05 13:55:53 -0800 | [diff] [blame] | 948 | # Route convergence and connectivity test with Route Server |
| 949 | def CASE22( self, main): |
| 950 | import time |
| 951 | import json |
| 952 | from operator import eq |
| 953 | # from datetime import datetime |
| 954 | from time import localtime, strftime |
| 955 | |
| 956 | main.case("The test case is to help to setup the TestON environment \ |
| 957 | and test new drivers" ) |
| 958 | TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ] |
| 959 | TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet" |
| 960 | SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json" |
| 961 | main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH) |
| 962 | |
| 963 | # Copy the json files to config dir |
| 964 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/") |
| 965 | main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/") |
| 966 | |
| 967 | # Launch mininet topology for this case |
| 968 | MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py" |
| 969 | main.step( "Launch mininet" ) |
| 970 | main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH) |
| 971 | main.step("waiting 20 secs for all switches and quagga instances to comeup") |
| 972 | time.sleep(20) |
| 973 | main.step( "Test whether Mininet is started" ) |
| 974 | main.log.info( "Login Quagga CLI on host3" ) |
| 975 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 976 | # all expected routes for all BGP peers |
| 977 | allRoutesExpected = [] |
| 978 | main.step( "Start to generate routes for all BGP peers" ) |
| 979 | main.log.info( "Generate prefixes for host3" ) |
| 980 | |
| 981 | prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 ) |
| 982 | main.log.info( prefixesHost3 ) |
| 983 | # generate route with next hop |
| 984 | for prefix in prefixesHost3: |
| 985 | allRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 986 | routeIntentsExpectedHost3 = \ |
| 987 | main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents( |
| 988 | prefixesHost3, "192.168.20.1", "00:00:00:00:02:02", |
| 989 | SDNIPJSONFILEPATH ) |
| 990 | |
| 991 | main.log.info( "Generate prefixes for host4" ) |
| 992 | prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 ) |
| 993 | main.log.info( prefixesHost4 ) |
| 994 | # generate route with next hop |
| 995 | for prefix in prefixesHost4: |
| 996 | allRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 997 | routeIntentsExpectedHost4 = \ |
| 998 | main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents( |
| 999 | prefixesHost4, "192.168.30.1", "00:00:00:00:03:01", |
| 1000 | SDNIPJSONFILEPATH ) |
| 1001 | |
| 1002 | main.log.info( "Generate prefixes for host5" ) |
| 1003 | prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 ) |
| 1004 | main.log.info( prefixesHost5 ) |
| 1005 | for prefix in prefixesHost5: |
| 1006 | allRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1007 | routeIntentsExpectedHost5 = \ |
| 1008 | main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents( |
| 1009 | prefixesHost5, "192.168.60.1", "00:00:00:00:06:02", |
| 1010 | SDNIPJSONFILEPATH ) |
| 1011 | |
| 1012 | routeIntentsExpected = routeIntentsExpectedHost3 + \ |
| 1013 | routeIntentsExpectedHost4 + routeIntentsExpectedHost5 |
| 1014 | |
| 1015 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 1016 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 1017 | main.step( "Set cell for ONOS-cli environment" ) |
| 1018 | main.ONOScli.setCell( cellName ) |
| 1019 | verifyResult = main.ONOSbench.verifyCell() |
| 1020 | |
| 1021 | main.log.report( "Removing raft logs" ) |
| 1022 | main.ONOSbench.onosRemoveRaftLogs() |
| 1023 | main.log.report( "Uninstalling ONOS" ) |
| 1024 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 1025 | |
| 1026 | main.step( "Installing ONOS package" ) |
| 1027 | onos1InstallResult = main.ONOSbench.onosInstall( |
| 1028 | options="-f", node=ONOS1Ip ) |
| 1029 | |
| 1030 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 1031 | if not onos1Isup: |
| 1032 | main.log.report( "ONOS1 didn't start!" ) |
| 1033 | |
| 1034 | main.step( "Start ONOS-cli" ) |
| 1035 | |
| 1036 | main.ONOScli.startOnosCli( ONOS1Ip ) |
| 1037 | |
| 1038 | main.step( "Get devices in the network" ) |
| 1039 | listResult = main.ONOScli.devices( jsonFormat=False ) |
| 1040 | main.log.info( listResult ) |
| 1041 | time.sleep( 10 ) |
| 1042 | main.log.info( "Installing gbprouter feature" ) |
| 1043 | main.ONOScli.featureInstall( "onos-app-bgprouter" ) |
| 1044 | time.sleep( 10 ) |
| 1045 | main.step( "Login all BGP peers and add routes into peers" ) |
| 1046 | |
| 1047 | main.log.info( "Login Quagga CLI on host3" ) |
| 1048 | main.QuaggaCliHost3.loginQuagga( "1.168.30.2" ) |
| 1049 | main.log.info( "Enter configuration model of Quagga CLI on host3" ) |
| 1050 | main.QuaggaCliHost3.enterConfig( 64514 ) |
| 1051 | main.log.info( "Add routes to Quagga on host3" ) |
| 1052 | main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 ) |
| 1053 | |
| 1054 | main.log.info( "Login Quagga CLI on host4" ) |
| 1055 | main.QuaggaCliHost4.loginQuagga( "1.168.30.3" ) |
| 1056 | main.log.info( "Enter configuration model of Quagga CLI on host4" ) |
| 1057 | main.QuaggaCliHost4.enterConfig( 64516 ) |
| 1058 | main.log.info( "Add routes to Quagga on host4" ) |
| 1059 | main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 ) |
| 1060 | |
| 1061 | main.log.info( "Login Quagga CLI on host5" ) |
| 1062 | main.QuaggaCliHost5.loginQuagga( "1.168.30.5" ) |
| 1063 | main.log.info( "Enter configuration model of Quagga CLI on host5" ) |
| 1064 | main.QuaggaCliHost5.enterConfig( 64521 ) |
| 1065 | main.log.info( "Add routes to Quagga on host5" ) |
| 1066 | main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 ) |
| 1067 | |
| 1068 | time.sleep( 60 ) |
| 1069 | |
| 1070 | # get routes inside SDN-IP |
| 1071 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1072 | |
| 1073 | # parse routes from ONOS CLI |
| 1074 | allRoutesActual = \ |
| 1075 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1076 | |
| 1077 | allRoutesStrExpected = str( sorted( allRoutesExpected ) ) |
| 1078 | allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" ) |
| 1079 | main.step( "Check routes installed" ) |
| 1080 | main.log.info( "Routes expected:" ) |
| 1081 | main.log.info( allRoutesStrExpected ) |
| 1082 | main.log.info( "Routes get from ONOS CLI:" ) |
| 1083 | main.log.info( allRoutesStrActual ) |
| 1084 | utilities.assertEquals( |
| 1085 | expect=allRoutesStrExpected, actual=allRoutesStrActual, |
| 1086 | onpass="***Routes in SDN-IP are correct!***", |
| 1087 | onfail="***Routes in SDN-IP are wrong!***" ) |
| 1088 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1089 | main.log.report( |
| 1090 | "***Routes in SDN-IP after adding routes are correct!***" ) |
| 1091 | else: |
| 1092 | main.log.report( |
| 1093 | "***Routes in SDN-IP after adding routes are wrong!***" ) |
| 1094 | |
| 1095 | #============================= Ping Test ======================== |
| 1096 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1097 | main.log.info("Ping test result") |
| 1098 | if pingTestResults: |
| 1099 | main.log.info("Test succeeded") |
| 1100 | else: |
| 1101 | main.log.info("Test failed") |
| 1102 | |
| 1103 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1104 | onpass="Default connectivity check PASS", |
| 1105 | onfail="Default connectivity check FAIL") |
| 1106 | |
| 1107 | #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1108 | main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1109 | main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" ) |
| 1110 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1111 | time.sleep(150) |
| 1112 | # get routes inside SDN-IP |
| 1113 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1114 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1115 | |
| 1116 | # parse routes from ONOS CLI |
| 1117 | newAllRoutesActual = \ |
| 1118 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1119 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1120 | |
| 1121 | # Expected routes with changed next hop |
| 1122 | newAllRoutesExpected = [] |
| 1123 | for prefix in prefixesHost3: |
| 1124 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1125 | for prefix in prefixesHost4: |
| 1126 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1127 | for prefix in prefixesHost5: |
| 1128 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1129 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1130 | main.step( "Check routes installed after convergence-1" ) |
| 1131 | main.log.info( "Routes expected:" ) |
| 1132 | main.log.info( newAllRoutesStrExpected ) |
| 1133 | main.log.info( "Routes got from ONOS CLI after convergence-1:" ) |
| 1134 | main.log.info( newAllRoutesStrActual ) |
| 1135 | utilities.assertEquals( |
| 1136 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1137 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1138 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1139 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1140 | main.log.report( |
| 1141 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1142 | else: |
| 1143 | main.log.report( |
| 1144 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1145 | |
| 1146 | #============================= Ping Test ======================== |
| 1147 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1148 | main.log.info("Ping test result") |
| 1149 | if pingTestResults: |
| 1150 | main.log.info("Test succeeded") |
| 1151 | else: |
| 1152 | main.log.info("Test failed") |
| 1153 | |
| 1154 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1155 | onpass="Default connectivity check PASS", |
| 1156 | onfail="Default connectivity check FAIL") |
| 1157 | |
| 1158 | #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ================== |
| 1159 | main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" ) |
| 1160 | main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" ) |
| 1161 | main.log.info( "Sleeping for 150 seconds for network to converge" ) |
| 1162 | time.sleep(150) |
| 1163 | # get routes inside SDN-IP |
| 1164 | main.log.info( "Getting Routes from ONOS CLI" ) |
| 1165 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1166 | |
| 1167 | # parse routes from ONOS CLI |
| 1168 | newAllRoutesActual = \ |
| 1169 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1170 | newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" ) |
| 1171 | |
| 1172 | # Expected routes with changed next hop |
| 1173 | newAllRoutesExpected = [] |
| 1174 | for prefix in prefixesHost3: |
| 1175 | newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" ) |
| 1176 | for prefix in prefixesHost4: |
| 1177 | newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" ) |
| 1178 | for prefix in prefixesHost5: |
| 1179 | newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" ) |
| 1180 | newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) ) |
| 1181 | main.step( "Check routes installed after convergence-2" ) |
| 1182 | main.log.info( "Routes expected:" ) |
| 1183 | main.log.info( newAllRoutesStrExpected ) |
| 1184 | main.log.info( "Routes got from ONOS CLI after convergence-2:" ) |
| 1185 | main.log.info( newAllRoutesStrActual ) |
| 1186 | utilities.assertEquals( |
| 1187 | expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual, |
| 1188 | onpass="***Routes in SDN-IP are correct after convergence!***", |
| 1189 | onfail="***Routes in SDN-IP are wrong after convergence!***" ) |
| 1190 | if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ): |
| 1191 | main.log.report( |
| 1192 | "***Routes in SDN-IP after convergence are correct!***" ) |
| 1193 | else: |
| 1194 | main.log.report( |
| 1195 | "***Routes in SDN-IP after convergence are wrong!***" ) |
| 1196 | |
| 1197 | #============================= Ping Test ======================== |
| 1198 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" ) |
| 1199 | main.log.info("Ping test result") |
| 1200 | if pingTestResults: |
| 1201 | main.log.info("Test succeeded") |
| 1202 | else: |
| 1203 | main.log.info("Test failed") |
| 1204 | |
| 1205 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1206 | onpass="Default connectivity check PASS", |
| 1207 | onfail="Default connectivity check FAIL") |
| 1208 | |
| 1209 | #============================= Deleting Routes ================== |
| 1210 | main.step( "Check deleting routes installed" ) |
| 1211 | main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 ) |
| 1212 | main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 ) |
| 1213 | main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 ) |
| 1214 | |
| 1215 | getRoutesResult = main.ONOScli.routes( jsonFormat=True ) |
| 1216 | allRoutesActual = \ |
| 1217 | main.QuaggaCliHost3.extractActualRoutes( getRoutesResult ) |
| 1218 | |
| 1219 | main.log.info( "allRoutes_actual = " ) |
| 1220 | main.log.info( allRoutesActual ) |
| 1221 | |
| 1222 | utilities.assertEquals( |
| 1223 | expect="[]", actual=str( allRoutesActual ), |
| 1224 | onpass="***Route number in SDN-IP is 0, correct!***", |
| 1225 | onfail="***Routes number in SDN-IP is not 0, wrong!***" ) |
| 1226 | |
| 1227 | if( eq( allRoutesStrExpected, allRoutesStrActual ) ): |
| 1228 | main.log.report( "***Routes in SDN-IP after deleting correct!***" ) |
| 1229 | else: |
| 1230 | main.log.report( "***Routes in SDN-IP after deleting wrong!***" ) |
| 1231 | |
| 1232 | #============================= Ping Test ======================== |
| 1233 | pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" ) |
| 1234 | main.log.info("Ping test result") |
| 1235 | if pingTestResults: |
| 1236 | main.log.info("Test succeeded") |
| 1237 | else: |
| 1238 | main.log.info("Test failed") |
| 1239 | |
| 1240 | utilities.assert_equals(expect=main.TRUE,actual=pingTestResults, |
| 1241 | onpass="disconnect check PASS", |
| 1242 | onfail="disconnect check FAIL") |
| 1243 | |
| 1244 | main.ONOScli.logout() |
| 1245 | main.ONOSbench.onosStop(ONOS1Ip); |
| 1246 | main.Mininet.stopNet() |
| 1247 | time.sleep(10) |
| 1248 | |