shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1 | |
| 2 | #Testing the basic functionality of ONOS Next |
| 3 | #For sanity and driver functionality excercises only. |
| 4 | |
| 5 | import time |
| 6 | import sys |
| 7 | import os |
| 8 | import re |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 9 | import json |
| 10 | |
| 11 | time.sleep(1) |
| 12 | class ProdFunc13: |
| 13 | def __init__(self): |
| 14 | self.default = '' |
| 15 | |
| 16 | def CASE1(self, main): |
| 17 | ''' |
| 18 | Startup sequence: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 19 | cell <name> |
| 20 | onos-verify-cell |
| 21 | onos-remove-raft-log |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 22 | git pull |
| 23 | mvn clean install |
| 24 | onos-package |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 25 | onos-install -f |
| 26 | onos-wait-for-start |
| 27 | ''' |
| 28 | |
| 29 | cell_name = main.params['ENV']['cellName'] |
| 30 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 31 | ONOS1_port = main.params['CTRL']['port1'] |
| 32 | |
| 33 | main.case("Setting up test environment") |
| 34 | main.log.report("This testcase is testing setting up test environment") |
| 35 | main.log.report("__________________________________") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 36 | |
| 37 | main.step("Applying cell variable to environment") |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 38 | cell_result = main.ONOSbench.set_cell(cell_name) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 39 | verify_result = main.ONOSbench.verify_cell() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 40 | |
| 41 | main.step("Removing raft logs before a clen installation of ONOS") |
| 42 | main.ONOSbench.onos_remove_raft_logs() |
| 43 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 44 | main.step("Git checkout and pull master and get version") |
| 45 | main.ONOSbench.git_checkout("master") |
| 46 | git_pull_result = main.ONOSbench.git_pull() |
| 47 | print "git_pull_result = ", git_pull_result |
| 48 | version_result = main.ONOSbench.get_version(report=True) |
| 49 | |
| 50 | if git_pull_result == 1: |
| 51 | main.step("Using mvn clean & install") |
| 52 | clean_install_result = main.ONOSbench.clean_install() |
| 53 | #clean_install_result = main.TRUE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 54 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 55 | main.step("Creating ONOS package") |
| 56 | package_result = main.ONOSbench.onos_package() |
| 57 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 58 | |
| 59 | main.step("Installing ONOS package") |
| 60 | onos_install_result = main.ONOSbench.onos_install() |
| 61 | if onos_install_result == main.TRUE: |
| 62 | main.log.report("Installing ONOS package successful") |
| 63 | else: |
| 64 | main.log.report("Installing ONOS package failed") |
| 65 | |
| 66 | onos1_isup = main.ONOSbench.isup() |
| 67 | if onos1_isup == main.TRUE: |
| 68 | main.log.report("ONOS instance is up and ready") |
| 69 | else: |
| 70 | main.log.report("ONOS instance may not be up") |
| 71 | |
| 72 | main.step("Starting ONOS service") |
| 73 | start_result = main.ONOSbench.onos_start(ONOS1_ip) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 74 | |
| 75 | main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 76 | |
| 77 | case1_result = (package_result and\ |
| 78 | cell_result and verify_result and onos_install_result and\ |
| 79 | onos1_isup and start_result ) |
| 80 | utilities.assert_equals(expect=main.TRUE, actual=case1_result, |
| 81 | onpass="Test startup successful", |
| 82 | onfail="Test startup NOT successful") |
| 83 | |
| 84 | def CASE11(self, main): |
| 85 | ''' |
| 86 | Cleanup sequence: |
| 87 | onos-service <node_ip> stop |
| 88 | onos-uninstall |
| 89 | |
| 90 | TODO: Define rest of cleanup |
| 91 | |
| 92 | ''' |
| 93 | |
| 94 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 95 | |
| 96 | main.case("Cleaning up test environment") |
| 97 | |
| 98 | main.step("Testing ONOS kill function") |
| 99 | kill_result = main.ONOSbench.onos_kill(ONOS1_ip) |
| 100 | |
| 101 | main.step("Stopping ONOS service") |
| 102 | stop_result = main.ONOSbench.onos_stop(ONOS1_ip) |
| 103 | |
| 104 | main.step("Uninstalling ONOS service") |
| 105 | uninstall_result = main.ONOSbench.onos_uninstall() |
| 106 | |
| 107 | def CASE3(self, main): |
| 108 | ''' |
| 109 | Test 'onos' command and its functionality in driver |
| 110 | ''' |
| 111 | |
| 112 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 113 | |
| 114 | main.case("Testing 'onos' command") |
| 115 | |
| 116 | main.step("Sending command 'onos -w <onos-ip> system:name'") |
| 117 | cmdstr1 = "system:name" |
| 118 | cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) |
| 119 | main.log.info("onos command returned: "+cmd_result1) |
| 120 | |
| 121 | main.step("Sending command 'onos -w <onos-ip> onos:topology'") |
| 122 | cmdstr2 = "onos:topology" |
| 123 | cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2) |
| 124 | main.log.info("onos command returned: "+cmd_result2) |
| 125 | |
| 126 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 127 | def CASE20(self): |
| 128 | ''' |
| 129 | Exit from mininet cli |
| 130 | reinstall ONOS |
| 131 | ''' |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 132 | cell_name = main.params['ENV']['cellName'] |
| 133 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 134 | ONOS1_port = main.params['CTRL']['port1'] |
| 135 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 136 | main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology") |
| 137 | main.log.report("_____________________________________________") |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 138 | main.case("Disconnecting mininet and restarting ONOS") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 139 | main.step("Disconnecting mininet and restarting ONOS") |
| 140 | mininet_disconnect = main.Mininet1.disconnect() |
| 141 | |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 142 | main.step("Removing raft logs before a clen installation of ONOS") |
| 143 | main.ONOSbench.onos_remove_raft_logs() |
| 144 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 145 | main.step("Applying cell variable to environment") |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 146 | cell_result = main.ONOSbench.set_cell(cell_name) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 147 | verify_result = main.ONOSbench.verify_cell() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 148 | |
| 149 | onos_install_result = main.ONOSbench.onos_install() |
| 150 | if onos_install_result == main.TRUE: |
| 151 | main.log.report("Installing ONOS package successful") |
| 152 | else: |
| 153 | main.log.report("Installing ONOS package failed") |
| 154 | |
| 155 | onos1_isup = main.ONOSbench.isup() |
| 156 | if onos1_isup == main.TRUE: |
| 157 | main.log.report("ONOS instance is up and ready") |
| 158 | else: |
| 159 | main.log.report("ONOS instance may not be up") |
| 160 | |
| 161 | main.step("Starting ONOS service") |
| 162 | start_result = main.ONOSbench.onos_start(ONOS1_ip) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 163 | |
| 164 | main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 165 | print "mininet_disconnect =", mininet_disconnect |
| 166 | print "onos_install_result =", onos_install_result |
| 167 | print "onos1_isup =", onos1_isup |
| 168 | print "start_result =", start_result |
| 169 | |
| 170 | case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result |
| 171 | utilities.assert_equals(expect=main.TRUE, actual=case20_result, |
| 172 | onpass="Exiting functionality mininet topology and reinstalling ONOS successful", |
| 173 | onfail="Exiting functionality mininet topology and reinstalling ONOS failed") |
| 174 | |
| 175 | def CASE21(self, main): |
| 176 | import time |
| 177 | ''' |
| 178 | On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg |
| 179 | which starts the rest and copies the links json file to the onos instance |
| 180 | Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt |
| 181 | from the json config file |
| 182 | ''' |
| 183 | main.log.report("This testcase starts the packet layer topology and REST") |
| 184 | main.log.report("_____________________________________________") |
| 185 | main.case("Starting LINC-OE and other components") |
| 186 | main.step("Starting LINC-OE and other components") |
| 187 | start_console_result = main.LincOE1.start_console() |
| 188 | optical_mn_script = main.LincOE2.run_optical_mn_script() |
| 189 | onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile']) |
| 190 | |
| 191 | print "start_console_result =",start_console_result |
| 192 | print "optical_mn_script = ",optical_mn_script |
| 193 | print "onos_topo_cfg_result =",onos_topo_cfg_result |
| 194 | |
| 195 | case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result |
| 196 | utilities.assert_equals(expect=main.TRUE, actual=case21_result, |
| 197 | onpass="Packet optical topology spawned successsfully", |
| 198 | onfail="Packet optical topology spawning failed") |
| 199 | |
| 200 | |
| 201 | def CASE22(self, main): |
| 202 | ''' |
| 203 | Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host. |
| 204 | Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2 |
| 205 | and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed |
| 206 | ''' |
| 207 | |
| 208 | main.log.report("This testcase compares the optical+packet topology against what is expected") |
| 209 | main.case("Topology comparision") |
| 210 | main.step("Topology comparision") |
| 211 | main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) |
| 212 | devices_result = main.ONOS3.devices(json_format = False) |
| 213 | |
| 214 | print "devices_result = ", devices_result |
| 215 | devices_linewise = devices_result.split("\n") |
| 216 | devices_linewise = devices_linewise[1:-1] |
| 217 | roadmCount = 0 |
| 218 | packetLayerSWCount = 0 |
| 219 | for line in devices_linewise: |
| 220 | components = line.split(",") |
| 221 | availability = components[1].split("=")[1] |
| 222 | type = components[3].split("=")[1] |
| 223 | if availability == 'true' and type == 'ROADM': |
| 224 | roadmCount += 1 |
| 225 | elif availability == 'true' and type =='SWITCH': |
| 226 | packetLayerSWCount += 1 |
| 227 | if roadmCount == 4: |
| 228 | print "Number of Optical Switches = %d and is correctly detected" %roadmCount |
| 229 | main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected") |
| 230 | opticalSW_result = main.TRUE |
| 231 | else: |
| 232 | print "Number of Optical Switches = %d and is wrong" %roadCount |
| 233 | main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong") |
| 234 | opticalSW_result = main.FALSE |
| 235 | |
| 236 | if packetLayerSWCount == 2: |
| 237 | print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount |
| 238 | main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected") |
| 239 | packetSW_result = main.TRUE |
| 240 | else: |
| 241 | print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount |
| 242 | main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong") |
| 243 | packetSW_result = main.FALSE |
| 244 | print "_________________________________" |
| 245 | |
| 246 | links_result = main.ONOS3.links(json_format = False) |
| 247 | print "links_result = ", links_result |
| 248 | print "_________________________________" |
| 249 | |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 250 | #NOTE:Since only point intents are added, there is no requirement to discover the hosts |
| 251 | #Therfore, the below portion of the code is commented. |
| 252 | ''' |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 253 | #Discover hosts using pingall |
| 254 | pingall_result = main.LincOE2.pingall() |
| 255 | |
| 256 | hosts_result = main.ONOS3.hosts(json_format = False) |
| 257 | main.log.info("hosts_result = "+hosts_result) |
| 258 | main.log.info("_________________________________") |
| 259 | hosts_linewise = hosts_result.split("\n") |
| 260 | hosts_linewise = hosts_linewise[1:-1] |
| 261 | hostCount = 0 |
| 262 | for line in hosts_linewise: |
| 263 | hostid = line.split(",")[0].split("=")[1] |
| 264 | hostCount +=1 |
| 265 | if hostCount ==2: |
| 266 | print "Number of hosts = %d and is correctly detected" %hostCount |
| 267 | main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected") |
| 268 | hostDiscovery = main.TRUE |
| 269 | else: |
| 270 | print "Number of hosts = %d and is wrong" %hostCount |
| 271 | main.log.info("Number of hosts = " + str(hostCount) +" and is wrong") |
| 272 | hostDiscovery = main.FALSE |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 273 | ''' |
| 274 | |
| 275 | case22_result = opticalSW_result and packetSW_result |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 276 | utilities.assert_equals(expect=main.TRUE, actual=case22_result, |
| 277 | onpass="Packet optical topology discovery successful", |
| 278 | onfail="Packet optical topology discovery failed") |
| 279 | |
| 280 | def CASE23(self, main): |
| 281 | import time |
| 282 | ''' |
| 283 | Add bidirectional point intents between 2 packet layer(mininet) devices and |
| 284 | ping mininet hosts |
| 285 | ''' |
| 286 | main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts") |
| 287 | main.case("Topology comparision") |
| 288 | main.step("Adding point intents") |
| 289 | ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1") |
| 290 | if ptp_intent_result == main.TRUE: |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 291 | get_intent_result = main.ONOS3.intents(json_format = False) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 292 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 293 | |
| 294 | ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1") |
| 295 | if ptp_intent_result == main.TRUE: |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 296 | get_intent_result = main.ONOS3.intents(json_format = False) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 297 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 298 | |
| 299 | time.sleep(10) |
| 300 | flowHandle = main.ONOS3.flows() |
| 301 | main.log.info("flows :" + flowHandle) |
| 302 | |
| 303 | # Sleep for 30 seconds to provide time for the intent state to change |
| 304 | time.sleep(30) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 305 | intentHandle = main.ONOS3.intents(json_format = False) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 306 | main.log.info("intents :" + intentHandle) |
| 307 | |
| 308 | Ping_Result = main.TRUE |
| 309 | count = 1 |
| 310 | main.log.info("\n\nh1 is Pinging h2") |
| 311 | ping = main.LincOE2.pingHostOptical(src="h1", target="h2") |
| 312 | #ping = main.LincOE2.pinghost() |
| 313 | if ping == main.FALSE and count<5: |
| 314 | count+=1 |
| 315 | Ping_Result = main.FALSE |
| 316 | main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds") |
| 317 | time.sleep(2) |
| 318 | ping = main.LincOE2.pingHostOptical(src="h1", target="h2") |
| 319 | #ping = main.LincOE2.pinghost() |
| 320 | elif ping==main.FALSE: |
| 321 | main.log.info("All ping attempts between h1 and h2 have failed") |
| 322 | Ping_Result = main.FALSE |
| 323 | elif ping==main.TRUE: |
| 324 | main.log.info("Ping test between h1 and h2 passed!") |
| 325 | Ping_Result = main.TRUE |
| 326 | else: |
| 327 | main.log.info("Unknown error") |
| 328 | Ping_Result = main.ERROR |
| 329 | |
| 330 | if Ping_Result==main.FALSE: |
| 331 | main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up") |
| 332 | if Ping_Result==main.TRUE: |
| 333 | main.log.report("Point Intents for packet optical have been installed correctly") |
| 334 | |
| 335 | case23_result = Ping_Result |
| 336 | utilities.assert_equals(expect=main.TRUE, actual=case23_result, |
| 337 | onpass="Point intents addition for packet optical and Pingall Test successful", |
| 338 | onfail="Point intents addition for packet optical and Pingall Test NOT successful") |
| 339 | |
| 340 | |
| 341 | |
| 342 | def CASE24(self, main): |
| 343 | import time |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 344 | import json |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 345 | ''' |
| 346 | Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive |
| 347 | and do a ping test. If rerouting is successful, ping should pass. also check the flows |
| 348 | ''' |
| 349 | main.log.report("This testcase tests rerouting and pings mininet hosts") |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 350 | main.case("Test rerouting and pings mininet hosts") |
| 351 | main.step("Bring a port down and verify the link state") |
| 352 | main.LincOE1.port_down(sw_id="1", pt_id="22") |
| 353 | links_nonjson = main.ONOS3.links(json_format = False) |
| 354 | main.log.info("links = " +links_nonjson) |
| 355 | |
| 356 | links = main.ONOS3.links() |
| 357 | main.log.info("links = " +links) |
| 358 | |
| 359 | links_result = json.loads(links) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 360 | links_state_result = main.FALSE |
| 361 | for item in links_result: |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 362 | if item['src']['device'] == "of:0000ffffffffff01" and item['src']['port'] == "22": |
| 363 | if item['dst']['device'] == "of:0000ffffffffff04" and item['dst']['port'] == "30": |
| 364 | links_state = item['state'] |
| 365 | if links_state == "INACTIVE": |
| 366 | main.log.info("Links state is inactive as expected due to one of the ports being down") |
| 367 | main.log.report("Links state is inactive as expected due to one of the ports being down") |
| 368 | links_state_result = main.TRUE |
| 369 | break |
| 370 | else: |
| 371 | main.log.info("Links state is not inactive as expected") |
| 372 | main.log.report("Links state is not inactive as expected") |
| 373 | links_state_result = main.FALSE |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 374 | |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 375 | print "links_state_result = ", links_state_result |
| 376 | time.sleep(10) |
| 377 | flowHandle = main.ONOS3.flows() |
| 378 | main.log.info("flows :" + flowHandle) |
| 379 | |
| 380 | main.step("Verify Rerouting by a ping test") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 381 | Ping_Result = main.TRUE |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 382 | count = 1 |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 383 | main.log.info("\n\nh1 is Pinging h2") |
| 384 | ping = main.LincOE2.pingHostOptical(src="h1", target="h2") |
| 385 | #ping = main.LincOE2.pinghost() |
| 386 | if ping == main.FALSE and count<5: |
| 387 | count+=1 |
| 388 | Ping_Result = main.FALSE |
| 389 | main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds") |
| 390 | time.sleep(2) |
| 391 | ping = main.LincOE2.pingHostOptical(src="h1", target="h2") |
| 392 | #ping = main.LincOE2.pinghost() |
| 393 | elif ping==main.FALSE: |
| 394 | main.log.info("All ping attempts between h1 and h2 have failed") |
| 395 | Ping_Result = main.FALSE |
| 396 | elif ping==main.TRUE: |
| 397 | main.log.info("Ping test between h1 and h2 passed!") |
| 398 | Ping_Result = main.TRUE |
| 399 | else: |
| 400 | main.log.info("Unknown error") |
| 401 | Ping_Result = main.ERROR |
| 402 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 403 | if Ping_Result==main.TRUE: |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 404 | main.log.report("Ping test successful ") |
| 405 | if Ping_Result==main.FALSE: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 406 | main.log.report("Ping test failed") |
| 407 | |
| 408 | case24_result = Ping_Result and links_state_result |
| 409 | utilities.assert_equals(expect=main.TRUE, actual=case24_result, |
| 410 | onpass="Packet optical rerouting successful", |
| 411 | onfail="Packet optical rerouting failed") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 412 | |
| 413 | def CASE4(self, main): |
| 414 | import re |
| 415 | import time |
| 416 | main.log.report("This testcase is testing the assignment of all the switches to all the controllers and discovering the hosts in reactive mode") |
| 417 | main.log.report("__________________________________") |
| 418 | main.case("Pingall Test") |
| 419 | main.step("Assigning switches to controllers") |
| 420 | for i in range(1,29): |
| 421 | if i ==1: |
| 422 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 423 | elif i>=2 and i<5: |
| 424 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 425 | elif i>=5 and i<8: |
| 426 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 427 | elif i>=8 and i<18: |
| 428 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 429 | elif i>=18 and i<28: |
| 430 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 431 | else: |
| 432 | main.Mininet1.assign_sw_controller(sw=str(i),ip1=ONOS1_ip,port1=ONOS1_port) |
| 433 | Switch_Mastership = main.TRUE |
| 434 | for i in range (1,29): |
| 435 | if i==1: |
| 436 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 437 | print("Response is " + str(response)) |
| 438 | if re.search("tcp:"+ONOS1_ip,response): |
| 439 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 440 | else: |
| 441 | Switch_Mastership = main.FALSE |
| 442 | elif i>=2 and i<5: |
| 443 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 444 | print("Response is " + str(response)) |
| 445 | if re.search("tcp:"+ONOS1_ip,response): |
| 446 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 447 | else: |
| 448 | Switch_Mastership = main.FALSE |
| 449 | elif i>=5 and i<8: |
| 450 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 451 | print("Response is " + str(response)) |
| 452 | if re.search("tcp:"+ONOS1_ip,response): |
| 453 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 454 | else: |
| 455 | Switch_Mastership = main.FALSE |
| 456 | elif i>=8 and i<18: |
| 457 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 458 | print("Response is " + str(response)) |
| 459 | if re.search("tcp:"+ONOS1_ip,response): |
| 460 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 461 | else: |
| 462 | Switch_Mastership = main.FALSE |
| 463 | elif i>=18 and i<28: |
| 464 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 465 | print("Response is " + str(response)) |
| 466 | if re.search("tcp:"+ONOS1_ip,response): |
| 467 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 468 | else: |
| 469 | Switch_Mastership = main.FALSE |
| 470 | else: |
| 471 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 472 | print("Response is" + str(response)) |
| 473 | if re.search("tcp:" +ONOS1_ip,response): |
| 474 | Switch_Mastership = Switch_Mastership and main.TRUE |
| 475 | else: |
| 476 | Switch_Mastership = main.FALSE |
| 477 | |
| 478 | if Switch_Mastership == main.TRUE: |
| 479 | main.log.report("Controller assignmnet successful") |
| 480 | else: |
| 481 | main.log.report("Controller assignmnet failed") |
| 482 | utilities.assert_equals(expect = main.TRUE,actual=Switch_Mastership, |
| 483 | onpass="MasterControllers assigned correctly") |
| 484 | ''' |
| 485 | for i in range (1,29): |
| 486 | main.Mininet1.assign_sw_controller(sw=str(i),count=5, |
| 487 | ip1=ONOS1_ip,port1=ONOS1_port, |
| 488 | ip2=ONOS2_ip,port2=ONOS2_port, |
| 489 | ip3=ONOS3_ip,port3=ONOS3_port, |
| 490 | ip4=ONOS4_ip,port4=ONOS4_port, |
| 491 | ip5=ONOS5_ip,port5=ONOS5_port) |
| 492 | ''' |
| 493 | #REACTIVE FWD test |
| 494 | |
| 495 | main.step("Get list of hosts from Mininet") |
| 496 | host_list = main.Mininet1.get_hosts() |
| 497 | main.log.info(host_list) |
| 498 | |
| 499 | main.step("Get host list in ONOS format") |
| 500 | host_onos_list = main.ONOS2.get_hosts_id(host_list) |
| 501 | main.log.info(host_onos_list) |
| 502 | #time.sleep(5) |
| 503 | |
| 504 | main.step("Pingall") |
| 505 | ping_result = main.FALSE |
| 506 | while ping_result == main.FALSE: |
| 507 | time1 = time.time() |
| 508 | ping_result = main.Mininet1.pingall() |
| 509 | time2 = time.time() |
| 510 | print "Time for pingall: %2f seconds" % (time2 - time1) |
| 511 | |
| 512 | #Start onos cli again because u might have dropped out of onos prompt to the shell prompt |
| 513 | #if there was no activity |
| 514 | main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) |
| 515 | |
| 516 | case4_result = Switch_Mastership and ping_result |
| 517 | if ping_result == main.TRUE: |
| 518 | main.log.report("Pingall Test in reactive mode to discover the hosts successful") |
| 519 | else: |
| 520 | main.log.report("Pingall Test in reactive mode to discover the hosts failed") |
| 521 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 522 | utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful") |
| 523 | |
| 524 | def CASE10(self): |
| 525 | main.log.report("This testcase uninstalls the reactive forwarding app") |
| 526 | main.log.report("__________________________________") |
| 527 | main.case("Uninstalling reactive forwarding app") |
| 528 | #Unistall onos-app-fwd app to disable reactive forwarding |
| 529 | appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd") |
| 530 | main.log.info("onos-app-fwd uninstalled") |
| 531 | |
| 532 | #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s |
| 533 | #So sleep for 15s |
| 534 | time.sleep(15) |
| 535 | |
| 536 | flows = main.ONOS2.flows() |
| 537 | main.log.info(flows) |
| 538 | |
| 539 | case10_result = appUninstall_result |
| 540 | utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 541 | |
| 542 | |
| 543 | def CASE6(self): |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 544 | main.log.report("This testcase is testing the addition of host intents and then does pingall") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 545 | main.log.report("__________________________________") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 546 | main.case("Obtaining host id's") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 547 | main.step("Get hosts") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 548 | hosts = main.ONOS2.hosts() |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 549 | #main.log.info(hosts) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 550 | |
| 551 | main.step("Get all devices id") |
| 552 | devices_id_list = main.ONOS2.get_all_devices_id() |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 553 | #main.log.info(devices_id_list) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 554 | |
| 555 | #ONOS displays the hosts in hex format unlike mininet which does in decimal format |
| 556 | #So take care while adding intents |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 557 | ''' |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 558 | main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12") |
| 559 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1") |
| 560 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1") |
| 561 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1") |
| 562 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1") |
| 563 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1") |
| 564 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1") |
| 565 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1") |
| 566 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1") |
| 567 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1") |
| 568 | hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 569 | print "_____________________________________________________________________________________" |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 570 | ''' |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 571 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 572 | for i in range(8,18): |
| 573 | main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10)) |
| 574 | host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper() |
| 575 | host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper() |
| 576 | #NOTE: get host can return None |
| 577 | #TODO: handle this |
| 578 | host1_id = main.ONOS2.get_host(host1)['id'] |
| 579 | host2_id = main.ONOS2.get_host(host2)['id'] |
| 580 | tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id ) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 581 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 582 | time.sleep(10) |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 583 | h_intents = main.ONOS2.intents(json_format = False) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 584 | main.log.info("intents:" +h_intents) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 585 | flowHandle = main.ONOS2.flows() |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 586 | #main.log.info("flow:" +flowHandle) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 587 | |
| 588 | count = 1 |
| 589 | i = 8 |
| 590 | Ping_Result = main.TRUE |
| 591 | #while i<10: |
| 592 | while i <18 : |
| 593 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 594 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 595 | if ping == main.FALSE and count <5: |
| 596 | count+=1 |
| 597 | #i = 8 |
| 598 | Ping_Result = main.FALSE |
| 599 | main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 600 | time.sleep(2) |
| 601 | elif ping==main.FALSE: |
| 602 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 603 | i=19 |
| 604 | Ping_Result = main.FALSE |
| 605 | elif ping==main.TRUE: |
| 606 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!") |
| 607 | i+=1 |
| 608 | Ping_Result = main.TRUE |
| 609 | else: |
| 610 | main.log.info("Unknown error") |
| 611 | Ping_Result = main.ERROR |
| 612 | if Ping_Result==main.FALSE: |
| 613 | main.log.report("Ping all test after Host intent addition failed. Cleaning up") |
| 614 | #main.cleanup() |
| 615 | #main.exit() |
| 616 | if Ping_Result==main.TRUE: |
| 617 | main.log.report("Ping all test after Host intent addition successful") |
| 618 | |
| 619 | case6_result = Ping_Result |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 620 | utilities.assert_equals(expect=main.TRUE, actual=case6_result, |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 621 | onpass="Pingall Test after Host intents addition successful", |
| 622 | onfail="Pingall Test after Host intents addition failed") |
| 623 | |
| 624 | |
| 625 | def CASE5(self,main) : |
| 626 | import json |
| 627 | from subprocess import Popen, PIPE |
| 628 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 629 | #main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1']) |
| 630 | deviceResult = main.ONOS2.devices() |
| 631 | linksResult = main.ONOS2.links() |
| 632 | #portsResult = main.ONOS2.ports() |
| 633 | print "**************" |
| 634 | |
| 635 | main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet") |
| 636 | main.log.report("__________________________________") |
| 637 | main.case("Comparing Mininet topology with the topology of ONOS") |
| 638 | main.step("Start continuous pings") |
| 639 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 640 | target=main.params['PING']['target1'],pingTime=500) |
| 641 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 642 | target=main.params['PING']['target2'],pingTime=500) |
| 643 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 644 | target=main.params['PING']['target3'],pingTime=500) |
| 645 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 646 | target=main.params['PING']['target4'],pingTime=500) |
| 647 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 648 | target=main.params['PING']['target5'],pingTime=500) |
| 649 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 650 | target=main.params['PING']['target6'],pingTime=500) |
| 651 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 652 | target=main.params['PING']['target7'],pingTime=500) |
| 653 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 654 | target=main.params['PING']['target8'],pingTime=500) |
| 655 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 656 | target=main.params['PING']['target9'],pingTime=500) |
| 657 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 658 | target=main.params['PING']['target10'],pingTime=500) |
| 659 | |
| 660 | main.step("Create TestONTopology object") |
| 661 | global ctrls |
| 662 | ctrls = [] |
| 663 | count = 1 |
| 664 | while True: |
| 665 | temp = () |
| 666 | if ('ip' + str(count)) in main.params['CTRL']: |
| 667 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 668 | temp = temp + ("ONOS"+str(count),) |
| 669 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 670 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 671 | ctrls.append(temp) |
| 672 | count = count + 1 |
| 673 | else: |
| 674 | break |
| 675 | global MNTopo |
| 676 | Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 677 | MNTopo = Topo |
| 678 | |
| 679 | Topology_Check = main.TRUE |
| 680 | main.step("Compare ONOS Topology to MN Topology") |
| 681 | devices_json = main.ONOS2.devices() |
| 682 | links_json = main.ONOS2.links() |
| 683 | #ports_json = main.ONOS2.ports() |
| 684 | print "devices_json= ", devices_json |
| 685 | |
| 686 | result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json)) |
| 687 | result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json)) |
| 688 | #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json)) |
| 689 | |
| 690 | #result = result1 and result2 and result3 |
| 691 | result = result1 and result2 |
| 692 | |
| 693 | print "***********************" |
| 694 | if result == main.TRUE: |
| 695 | main.log.report("ONOS"+ " Topology matches MN Topology") |
| 696 | else: |
| 697 | main.log.report("ONOS"+ " Topology does not match MN Topology") |
| 698 | |
| 699 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 700 | onpass="ONOS" + " Topology matches MN Topology", |
| 701 | onfail="ONOS" + " Topology does not match MN Topology") |
| 702 | |
| 703 | Topology_Check = Topology_Check and result |
| 704 | utilities.assert_equals(expect=main.TRUE,actual=Topology_Check, |
| 705 | onpass="Topology checks passed", onfail="Topology checks failed") |
| 706 | |
| 707 | |
| 708 | def CASE7 (self,main): |
| 709 | |
| 710 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 711 | |
| 712 | link_sleep = int(main.params['timers']['LinkDiscovery']) |
| 713 | |
| 714 | main.log.report("This testscase is killing a link to ensure that link discovery is consistent") |
| 715 | main.log.report("__________________________________") |
| 716 | main.log.report("Killing a link to ensure that link discovery is consistent") |
| 717 | main.case("Killing a link to Ensure that Link Discovery is Working Properly") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 718 | ''' |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 719 | main.step("Start continuous pings") |
| 720 | |
| 721 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 722 | target=main.params['PING']['target1'],pingTime=500) |
| 723 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 724 | target=main.params['PING']['target2'],pingTime=500) |
| 725 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 726 | target=main.params['PING']['target3'],pingTime=500) |
| 727 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 728 | target=main.params['PING']['target4'],pingTime=500) |
| 729 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 730 | target=main.params['PING']['target5'],pingTime=500) |
| 731 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 732 | target=main.params['PING']['target6'],pingTime=500) |
| 733 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 734 | target=main.params['PING']['target7'],pingTime=500) |
| 735 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 736 | target=main.params['PING']['target8'],pingTime=500) |
| 737 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 738 | target=main.params['PING']['target9'],pingTime=500) |
| 739 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 740 | target=main.params['PING']['target10'],pingTime=500) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 741 | ''' |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 742 | |
| 743 | main.step("Determine the current number of switches and links") |
| 744 | topology_output = main.ONOS2.topology() |
| 745 | topology_result = main.ONOS1.get_topology(topology_output) |
| 746 | activeSwitches = topology_result['devices'] |
| 747 | links = topology_result['links'] |
| 748 | print "activeSwitches = ", type(activeSwitches) |
| 749 | print "links = ", type(links) |
| 750 | main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links))) |
| 751 | |
| 752 | main.step("Kill Link between s3 and s28") |
| 753 | main.Mininet1.link(END1="s3",END2="s28",OPTION="down") |
| 754 | time.sleep(link_sleep) |
| 755 | topology_output = main.ONOS2.topology() |
| 756 | Link_Down = main.ONOS1.check_status(topology_output,activeSwitches,str(int(links)-2)) |
| 757 | if Link_Down == main.TRUE: |
| 758 | main.log.report("Link Down discovered properly") |
| 759 | utilities.assert_equals(expect=main.TRUE,actual=Link_Down, |
| 760 | onpass="Link Down discovered properly", |
| 761 | onfail="Link down was not discovered in "+ str(link_sleep) + " seconds") |
| 762 | |
| 763 | #Check ping result here..add code for it |
| 764 | |
| 765 | main.step("Bring link between s3 and s28 back up") |
| 766 | Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up") |
| 767 | time.sleep(link_sleep) |
| 768 | topology_output = main.ONOS2.topology() |
| 769 | Link_Up = main.ONOS1.check_status(topology_output,activeSwitches,str(links)) |
| 770 | if Link_Up == main.TRUE: |
| 771 | main.log.report("Link up discovered properly") |
| 772 | utilities.assert_equals(expect=main.TRUE,actual=Link_Up, |
| 773 | onpass="Link up discovered properly", |
| 774 | onfail="Link up was not discovered in "+ str(link_sleep) + " seconds") |
| 775 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 776 | #NOTE Check ping result here..add code for it |
| 777 | |
| 778 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 779 | main.step("Compare ONOS Topology to MN Topology") |
| 780 | Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 781 | MNTopo = Topo |
| 782 | Topology_Check = main.TRUE |
| 783 | |
| 784 | devices_json = main.ONOS2.devices() |
| 785 | links_json = main.ONOS2.links() |
| 786 | ports_json = main.ONOS2.ports() |
| 787 | print "devices_json= ", devices_json |
| 788 | |
| 789 | result1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices_json)) |
| 790 | result2 = main.Mininet1.compare_links(MNTopo, json.loads(links_json)) |
| 791 | #result3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports_json)) |
| 792 | |
| 793 | #result = result1 and result2 and result3 |
| 794 | result = result1 and result2 |
| 795 | print "***********************" |
| 796 | |
| 797 | if result == main.TRUE: |
| 798 | main.log.report("ONOS"+ " Topology matches MN Topology") |
| 799 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 800 | onpass="ONOS" + " Topology matches MN Topology", |
| 801 | onfail="ONOS" + " Topology does not match MN Topology") |
| 802 | |
| 803 | Topology_Check = Topology_Check and result |
| 804 | utilities.assert_equals(expect=main.TRUE,actual=Topology_Check, |
| 805 | onpass="Topology checks passed", onfail="Topology checks failed") |
| 806 | |
| 807 | result = Link_Down and Link_Up and Topology_Check |
| 808 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 809 | onpass="Link failure is discovered correctly", |
| 810 | onfail="Link Discovery failed") |
| 811 | |
| 812 | |
| 813 | def CASE8(self): |
| 814 | ''' |
| 815 | Host intents removal |
| 816 | ''' |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 817 | main.log.report("This testcase removes host intents before adding the same intents or point intents") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 818 | main.log.report("__________________________________") |
| 819 | main.log.info("Host intents removal") |
| 820 | main.case("Removing host intents") |
| 821 | main.step("Obtain the intent id's") |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 822 | intent_result = main.ONOS2.intents(json_format = False) |
| 823 | main.log.info("intent_result = " +intent_result) |
| 824 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 825 | intent_linewise = intent_result.split("\n") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 826 | intentList = [] |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 827 | for line in intent_linewise: |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 828 | if line.startswith("id="): |
| 829 | intentList.append(line) |
| 830 | |
| 831 | intentids = [] |
| 832 | for line in intentList: |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 833 | intentids.append(line.split(",")[0].split("=")[1]) |
| 834 | for id in intentids: |
| 835 | print "id = ", id |
| 836 | |
| 837 | main.step("Iterate through the intentids list and remove each intent") |
| 838 | for id in intentids: |
| 839 | main.ONOS2.remove_intent(intent_id = id) |
| 840 | |
shahshreya | f1b1b9f | 2014-12-04 16:59:20 -0800 | [diff] [blame] | 841 | intent_result = main.ONOS2.intents(json_format = False) |
| 842 | main.log.info("intent_result = " +intent_result) |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 843 | |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 844 | case8_result = main.TRUE |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 845 | if case8_result == main.TRUE: |
| 846 | main.log.report("Intent removal successful") |
| 847 | else: |
| 848 | main.log.report("Intent removal failed") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 849 | |
| 850 | Ping_Result = main.TRUE |
| 851 | if case8_result == main.TRUE: |
| 852 | i = 8 |
| 853 | while i <18 : |
| 854 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 855 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 856 | if ping==main.TRUE: |
| 857 | i = 19 |
| 858 | Ping_Result = Ping_Result and main.TRUE |
| 859 | elif ping==main.FALSE: |
| 860 | i+=1 |
| 861 | Ping_Result = Ping_Result and main.FALSE |
| 862 | else: |
| 863 | main.log.info("Unknown error") |
| 864 | Ping_Result = main.ERROR |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 865 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 866 | #Note: If the ping result failed, that means the intents have been withdrawn correctly. |
| 867 | if Ping_Result==main.TRUE: |
| 868 | main.log.report("Host intents have not been withdrawn correctly") |
| 869 | #main.cleanup() |
| 870 | #main.exit() |
| 871 | if Ping_Result==main.FALSE: |
| 872 | main.log.report("Host intents have been withdrawn correctly") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 873 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 874 | case8_result = case8_result and Ping_Result |
| 875 | |
| 876 | if case8_result == main.FALSE: |
| 877 | main.log.report("Intent removal successful") |
| 878 | else: |
| 879 | main.log.report("Intent removal failed") |
| 880 | |
| 881 | utilities.assert_equals(expect=main.FALSE, actual=case8_result, |
| 882 | onpass="Intent removal test failed", |
| 883 | onfail="Intent removal test passed") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 884 | |
| 885 | |
| 886 | def CASE9(self): |
| 887 | main.log.report("This testcase adds point intents and then does pingall") |
| 888 | main.log.report("__________________________________") |
| 889 | main.log.info("Adding point intents") |
| 890 | main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") |
| 891 | main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 892 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 893 | if ptp_intent_result == main.TRUE: |
| 894 | get_intent_result = main.ONOS2.intents() |
| 895 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 896 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 897 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 898 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 899 | if ptp_intent_result == main.TRUE: |
| 900 | get_intent_result = main.ONOS2.intents() |
| 901 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 902 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 903 | |
| 904 | main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 905 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 906 | if ptp_intent_result == main.TRUE: |
| 907 | get_intent_result = main.ONOS2.intents() |
| 908 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 909 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 910 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 911 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 912 | if ptp_intent_result == main.TRUE: |
| 913 | get_intent_result = main.ONOS2.intents() |
| 914 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 915 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 916 | |
| 917 | main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 918 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 919 | if ptp_intent_result == main.TRUE: |
| 920 | get_intent_result = main.ONOS2.intents() |
| 921 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 922 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 923 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 924 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 925 | if ptp_intent_result == main.TRUE: |
| 926 | get_intent_result = main.ONOS2.intents() |
| 927 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 928 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 929 | |
| 930 | main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 931 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 932 | if ptp_intent_result == main.TRUE: |
| 933 | get_intent_result = main.ONOS2.intents() |
| 934 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 935 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 936 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 937 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 938 | if ptp_intent_result == main.TRUE: |
| 939 | get_intent_result = main.ONOS2.intents() |
| 940 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 941 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 942 | |
| 943 | main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 944 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 945 | if ptp_intent_result == main.TRUE: |
| 946 | get_intent_result = main.ONOS2.intents() |
| 947 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 948 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 949 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 950 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 951 | if ptp_intent_result == main.TRUE: |
| 952 | get_intent_result = main.ONOS2.intents() |
| 953 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 954 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 955 | |
| 956 | main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 957 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 958 | if ptp_intent_result == main.TRUE: |
| 959 | get_intent_result = main.ONOS2.intents() |
| 960 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 961 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 962 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 963 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 964 | if ptp_intent_result == main.TRUE: |
| 965 | get_intent_result = main.ONOS2.intents() |
| 966 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 967 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 968 | |
| 969 | main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 970 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 971 | if ptp_intent_result == main.TRUE: |
| 972 | get_intent_result = main.ONOS2.intents() |
| 973 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 974 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 975 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 976 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 977 | if ptp_intent_result == main.TRUE: |
| 978 | get_intent_result = main.ONOS2.intents() |
| 979 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 980 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 981 | |
| 982 | main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 983 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 984 | if ptp_intent_result == main.TRUE: |
| 985 | get_intent_result = main.ONOS2.intents() |
| 986 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 987 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 988 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 989 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 990 | if ptp_intent_result == main.TRUE: |
| 991 | get_intent_result = main.ONOS2.intents() |
| 992 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 993 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 994 | |
| 995 | main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 996 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 997 | if ptp_intent_result == main.TRUE: |
| 998 | get_intent_result = main.ONOS2.intents() |
| 999 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1000 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1001 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1002 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1003 | if ptp_intent_result == main.TRUE: |
| 1004 | get_intent_result = main.ONOS2.intents() |
| 1005 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1006 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1007 | |
| 1008 | |
| 1009 | main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1010 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1011 | if ptp_intent_result == main.TRUE: |
| 1012 | get_intent_result = main.ONOS2.intents() |
| 1013 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1014 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1015 | |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1016 | ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1") |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1017 | if ptp_intent_result == main.TRUE: |
| 1018 | get_intent_result = main.ONOS2.intents() |
| 1019 | main.log.info("Point to point intent install successful") |
shahshreya | e6c7cf4 | 2014-11-26 16:39:01 -0800 | [diff] [blame] | 1020 | #main.log.info(get_intent_result) |
shahshreya | 4e13a06 | 2014-11-11 16:46:18 -0800 | [diff] [blame] | 1021 | |
| 1022 | print("_______________________________________________________________________________________") |
| 1023 | |
| 1024 | flowHandle = main.ONOS2.flows() |
| 1025 | #print "flowHandle = ", flowHandle |
| 1026 | main.log.info("flows :" + flowHandle) |
| 1027 | |
| 1028 | count = 1 |
| 1029 | i = 8 |
| 1030 | Ping_Result = main.TRUE |
| 1031 | while i <18 : |
| 1032 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 1033 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 1034 | if ping == main.FALSE and count <5: |
| 1035 | count+=1 |
| 1036 | #i = 8 |
| 1037 | Ping_Result = main.FALSE |
| 1038 | main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 1039 | time.sleep(2) |
| 1040 | elif ping==main.FALSE: |
| 1041 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 1042 | i=19 |
| 1043 | Ping_Result = main.FALSE |
| 1044 | elif ping==main.TRUE: |
| 1045 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!") |
| 1046 | i+=1 |
| 1047 | Ping_Result = main.TRUE |
| 1048 | else: |
| 1049 | main.log.info("Unknown error") |
| 1050 | Ping_Result = main.ERROR |
| 1051 | |
| 1052 | if Ping_Result==main.FALSE: |
| 1053 | main.log.report("Point intents have not ben installed correctly. Cleaning up") |
| 1054 | #main.cleanup() |
| 1055 | #main.exit() |
| 1056 | if Ping_Result==main.TRUE: |
| 1057 | main.log.report("Point Intents have been installed correctly") |
| 1058 | |
| 1059 | case9_result = Ping_Result |
| 1060 | utilities.assert_equals(expect=main.TRUE, actual=case9_result, |
| 1061 | onpass="Point intents addition and Pingall Test successful", |
| 1062 | onfail="Point intents addition and Pingall Test NOT successful") |
| 1063 | |
| 1064 | |