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