shahshreya | b512cd0 | 2015-01-27 17:01:47 -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 time |
| 7 | import json |
| 8 | |
| 9 | time.sleep(1) |
| 10 | class MultiProd: |
| 11 | def __init__(self): |
| 12 | self.default = '' |
| 13 | |
| 14 | def CASE1(self, main): |
| 15 | ''' |
| 16 | Startup sequence: |
| 17 | cell <name> |
| 18 | onos-verify-cell |
| 19 | onos-remove-raft-logs |
| 20 | git pull |
| 21 | mvn clean install |
| 22 | onos-package |
| 23 | onos-install -f |
| 24 | onos-wait-for-start |
| 25 | ''' |
| 26 | |
| 27 | cell_name = main.params['ENV']['cellName'] |
| 28 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 29 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 30 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 31 | |
| 32 | main.case("Setting up test environment") |
| 33 | main.log.report("This testcase is testing setting up test environment") |
| 34 | main.log.report("__________________________________") |
| 35 | |
| 36 | main.step("Applying cell variable to environment") |
| 37 | cell_result1 = main.ONOSbench.set_cell(cell_name) |
| 38 | #cell_result2 = main.ONOScli1.set_cell(cell_name) |
| 39 | #cell_result3 = main.ONOScli2.set_cell(cell_name) |
| 40 | #cell_result4 = main.ONOScli3.set_cell(cell_name) |
| 41 | verify_result = main.ONOSbench.verify_cell() |
| 42 | cell_result = cell_result1 |
| 43 | |
| 44 | main.step("Removing raft logs before a clen installation of ONOS") |
| 45 | remove_log_Result = main.ONOSbench.onos_remove_raft_logs() |
| 46 | |
| 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 | main.ONOSbench.get_version(report=True) |
| 52 | |
| 53 | if git_pull_result == 1: |
| 54 | main.step("Using mvn clean & install") |
| 55 | main.ONOSbench.clean_install() |
| 56 | |
| 57 | main.step("Creating ONOS package") |
| 58 | package_result = main.ONOSbench.onos_package() |
| 59 | |
| 60 | #main.step("Creating a cell") |
| 61 | #cell_create_result = main.ONOSbench.create_cell_file(**************) |
| 62 | |
| 63 | main.step("Installing ONOS package") |
| 64 | onos1_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS1_ip) |
| 65 | onos2_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS2_ip) |
| 66 | onos3_install_result = main.ONOSbench.onos_install(options="-f", node=ONOS3_ip) |
| 67 | onos_install_result = onos1_install_result and onos2_install_result and onos3_install_result |
| 68 | if onos_install_result == main.TRUE: |
| 69 | main.log.report("Installing ONOS package successful") |
| 70 | else: |
| 71 | main.log.report("Installing ONOS package failed") |
| 72 | |
| 73 | onos1_isup = main.ONOSbench.isup(ONOS1_ip) |
| 74 | onos2_isup = main.ONOSbench.isup(ONOS2_ip) |
| 75 | onos3_isup = main.ONOSbench.isup(ONOS3_ip) |
| 76 | onos_isup = onos1_isup and onos2_isup and onos3_isup |
| 77 | if onos_isup == main.TRUE: |
| 78 | main.log.report("ONOS instances are up and ready") |
| 79 | else: |
| 80 | main.log.report("ONOS instances may not be up") |
| 81 | |
| 82 | main.step("Starting ONOS service") |
| 83 | start_result = main.TRUE |
| 84 | #start_result = main.ONOSbench.onos_start(ONOS1_ip) |
| 85 | startcli1 = main.ONOScli1.start_onos_cli(ONOS_ip = ONOS1_ip) |
| 86 | startcli2 = main.ONOScli2.start_onos_cli(ONOS_ip = ONOS2_ip) |
| 87 | startcli3 = main.ONOScli3.start_onos_cli(ONOS_ip = ONOS3_ip) |
| 88 | print startcli1 |
| 89 | print startcli2 |
| 90 | print startcli3 |
| 91 | |
| 92 | case1_result = (package_result and\ |
| 93 | cell_result and verify_result and onos_install_result and\ |
| 94 | onos_isup and start_result ) |
| 95 | utilities.assert_equals(expect=main.TRUE, actual=case1_result, |
| 96 | onpass="Test startup successful", |
| 97 | onfail="Test startup NOT successful") |
| 98 | |
| 99 | def CASE11(self, main): |
| 100 | ''' |
| 101 | Cleanup sequence: |
| 102 | onos-service <node_ip> stop |
| 103 | onos-uninstall |
| 104 | |
| 105 | TODO: Define rest of cleanup |
| 106 | |
| 107 | ''' |
| 108 | |
| 109 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 110 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 111 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 112 | |
| 113 | main.case("Cleaning up test environment") |
| 114 | |
| 115 | main.step("Testing ONOS kill function") |
| 116 | kill_result1 = main.ONOSbench.onos_kill(ONOS1_ip) |
| 117 | kill_result2 = main.ONOSbench.onos_kill(ONOS2_ip) |
| 118 | kill_result3 = main.ONOSbench.onos_kill(ONOS3_ip) |
| 119 | |
| 120 | main.step("Stopping ONOS service") |
| 121 | stop_result1 = main.ONOSbench.onos_stop(ONOS1_ip) |
| 122 | stop_result2 = main.ONOSbench.onos_stop(ONOS2_ip) |
| 123 | stop_result3 = main.ONOSbench.onos_stop(ONOS3_ip) |
| 124 | |
| 125 | main.step("Uninstalling ONOS service") |
| 126 | uninstall_result = main.ONOSbench.onos_uninstall() |
| 127 | |
| 128 | def CASE3(self, main): |
| 129 | ''' |
| 130 | Test 'onos' command and its functionality in driver |
| 131 | ''' |
| 132 | |
| 133 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 134 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 135 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 136 | |
| 137 | main.case("Testing 'onos' command") |
| 138 | |
| 139 | main.step("Sending command 'onos -w <onos-ip> system:name'") |
| 140 | cmdstr1 = "system:name" |
| 141 | cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) |
| 142 | main.log.info("onos command returned: "+cmd_result1) |
| 143 | cmd_result2 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr1) |
| 144 | main.log.info("onos command returned: "+cmd_result2) |
| 145 | cmd_result3 = main.ONOSbench.onos_cli(ONOS3_ip, cmdstr1) |
| 146 | main.log.info("onos command returned: "+cmd_result3) |
| 147 | |
| 148 | main.step("Sending command 'onos -w <onos-ip> onos:topology'") |
| 149 | cmdstr2 = "onos:topology" |
| 150 | cmd_result4 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2) |
| 151 | main.log.info("onos command returned: "+cmd_result4) |
| 152 | cmd_result5 = main.ONOSbench.onos_cli(ONOS2_ip, cmdstr2) |
| 153 | main.log.info("onos command returned: "+cmd_result5) |
| 154 | cmd_result6 = main.ONOSbench.onos_cli(ONOS6_ip, cmdstr2) |
| 155 | main.log.info("onos command returned: "+cmd_result6) |
| 156 | |
| 157 | |
| 158 | def CASE4(self, main): |
| 159 | import re |
| 160 | import time |
| 161 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 162 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 163 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 164 | ONOS1_port = main.params['CTRL']['port1'] |
| 165 | ONOS2_port = main.params['CTRL']['port2'] |
| 166 | ONOS3_port = main.params['CTRL']['port3'] |
| 167 | |
| 168 | main.log.report("This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode") |
| 169 | main.log.report("__________________________________") |
| 170 | main.case("Pingall Test(No intents are added)") |
| 171 | main.step("Assigning switches to controllers") |
| 172 | for i in range(1,29): #1 to (num of switches +1) |
| 173 | main.Mininet1.assign_sw_controller(sw=str(i),count=3, |
| 174 | ip1=ONOS1_ip, port1=ONOS1_port, |
| 175 | ip2=ONOS2_ip, port2=ONOS2_port, |
| 176 | ip3=ONOS3_ip, port3=ONOS3_port) |
| 177 | |
| 178 | switch_mastership = main.TRUE |
| 179 | for i in range (1,29): |
| 180 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 181 | print("Response is " + str(response)) |
| 182 | if re.search("tcp:"+ONOS1_ip,response): |
| 183 | switch_mastership = switch_mastership and main.TRUE |
| 184 | else: |
| 185 | switch_mastership = main.FALSE |
| 186 | |
| 187 | if switch_mastership == main.TRUE: |
| 188 | main.log.report("Controller assignment successfull") |
| 189 | else: |
| 190 | main.log.report("Controller assignment failed") |
| 191 | #REACTIVE FWD test |
| 192 | main.step("Pingall") |
| 193 | ping_result = main.FALSE |
| 194 | time1 = time.time() |
| 195 | ping_result = main.Mininet1.pingall() |
| 196 | time2 = time.time() |
| 197 | print "Time for pingall: %2f seconds" % (time2 - time1) |
| 198 | |
| 199 | case4_result = switch_mastership and ping_result |
| 200 | if ping_result == main.TRUE: |
| 201 | main.log.report("Pingall Test in reactive mode to discover the hosts successful") |
| 202 | else: |
| 203 | main.log.report("Pingall Test in reactive mode to discover the hosts failed") |
| 204 | |
| 205 | utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful") |
| 206 | |
| 207 | |
| 208 | |
| 209 | def CASE5(self,main) : |
| 210 | import json |
| 211 | from subprocess import Popen, PIPE |
| 212 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 213 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 214 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 215 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 216 | |
| 217 | main.log.report("This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes") |
| 218 | main.log.report("__________________________________") |
| 219 | main.case ("Testing Mininet topology with the topology of multi instances ONOS") |
| 220 | main.step("Collecting topology information from ONOS") |
| 221 | devices1 = main.ONOScli1.devices() |
| 222 | devices2 = main.ONOScli2.devices() |
| 223 | devices3 = main.ONOScli3.devices() |
| 224 | #print "devices1 = ", devices1 |
| 225 | #print "devices2 = ", devices2 |
| 226 | #print "devices3 = ", devices3 |
| 227 | hosts1 = main.ONOScli1.hosts() |
| 228 | hosts2 = main.ONOScli2.hosts() |
| 229 | hosts3 = main.ONOScli3.hosts() |
| 230 | #print "hosts1 = ", hosts1 |
| 231 | #print "hosts2 = ", hosts2 |
| 232 | #print "hosts3 = ", hosts3 |
| 233 | ports1 = main.ONOScli1.ports() |
| 234 | ports2 = main.ONOScli2.ports() |
| 235 | ports3 = main.ONOScli3.ports() |
| 236 | #print "ports1 = ", ports1 |
| 237 | #print "ports2 = ", ports2 |
| 238 | #print "ports3 = ", ports3 |
| 239 | links1 = main.ONOScli1.links() |
| 240 | links2 = main.ONOScli2.links() |
| 241 | links3 = main.ONOScli3.links() |
| 242 | #print "links1 = ", links1 |
| 243 | #print "links2 = ", links2 |
| 244 | #print "links3 = ", links3 |
| 245 | |
| 246 | print "**************" |
| 247 | |
| 248 | main.step("Start continuous pings") |
| 249 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 250 | target=main.params['PING']['target1'],pingTime=500) |
| 251 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 252 | target=main.params['PING']['target2'],pingTime=500) |
| 253 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 254 | target=main.params['PING']['target3'],pingTime=500) |
| 255 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 256 | target=main.params['PING']['target4'],pingTime=500) |
| 257 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 258 | target=main.params['PING']['target5'],pingTime=500) |
| 259 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 260 | target=main.params['PING']['target6'],pingTime=500) |
| 261 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 262 | target=main.params['PING']['target7'],pingTime=500) |
| 263 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 264 | target=main.params['PING']['target8'],pingTime=500) |
| 265 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 266 | target=main.params['PING']['target9'],pingTime=500) |
| 267 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 268 | target=main.params['PING']['target10'],pingTime=500) |
| 269 | |
| 270 | main.step("Create TestONTopology object") |
| 271 | global ctrls |
| 272 | ctrls = [] |
| 273 | count = 1 |
| 274 | while True: |
| 275 | temp = () |
| 276 | if ('ip' + str(count)) in main.params['CTRL']: |
| 277 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 278 | temp = temp + ("ONOS"+str(count),) |
| 279 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 280 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 281 | ctrls.append(temp) |
| 282 | count = count + 1 |
| 283 | else: |
| 284 | break |
| 285 | global MNTopo |
| 286 | Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 287 | MNTopo = Topo |
| 288 | |
| 289 | Topology_Check = main.TRUE |
| 290 | main.step("Compare ONOS Topology to MN Topology") |
| 291 | |
| 292 | switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1)) |
| 293 | print "switches_Result1 = ", switches_results1 |
| 294 | utilities.assert_equals(expect=main.TRUE, actual=switches_results1, |
| 295 | onpass="ONOS1 Switches view is correct", |
| 296 | onfail="ONOS1 Switches view is incorrect") |
| 297 | |
| 298 | switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2)) |
| 299 | utilities.assert_equals(expect=main.TRUE, actual=switches_results2, |
| 300 | onpass="ONOS2 Switches view is correct", |
| 301 | onfail="ONOS2 Switches view is incorrect") |
| 302 | |
| 303 | switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3)) |
| 304 | utilities.assert_equals(expect=main.TRUE, actual=switches_results3, |
| 305 | onpass="ONOS3 Switches view is correct", |
| 306 | onfail="ONOS3 Switches view is incorrect") |
| 307 | |
| 308 | ''' |
| 309 | ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1)) |
| 310 | utilities.assert_equals(expect=main.TRUE, actual=ports_results1, |
| 311 | onpass="ONOS1 Ports view is correct", |
| 312 | onfail="ONOS1 Ports view is incorrect") |
| 313 | |
| 314 | ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2)) |
| 315 | utilities.assert_equals(expect=main.TRUE, actual=ports_results2, |
| 316 | onpass="ONOS2 Ports view is correct", |
| 317 | onfail="ONOS2 Ports view is incorrect") |
| 318 | |
| 319 | ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3)) |
| 320 | utilities.assert_equals(expect=main.TRUE, actual=ports_results3, |
| 321 | onpass="ONOS3 Ports view is correct", |
| 322 | onfail="ONOS3 Ports view is incorrect") |
| 323 | ''' |
| 324 | |
| 325 | links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1)) |
| 326 | utilities.assert_equals(expect=main.TRUE, actual=links_results1, |
| 327 | onpass="ONOS1 Links view is correct", |
| 328 | onfail="ONOS1 Links view is incorrect") |
| 329 | |
| 330 | links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2)) |
| 331 | utilities.assert_equals(expect=main.TRUE, actual=links_results2, |
| 332 | onpass="ONOS2 Links view is correct", |
| 333 | onfail="ONOS2 Links view is incorrect") |
| 334 | |
| 335 | links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3)) |
| 336 | utilities.assert_equals(expect=main.TRUE, actual=links_results3, |
| 337 | onpass="ONOS2 Links view is correct", |
| 338 | onfail="ONOS2 Links view is incorrect") |
| 339 | |
| 340 | #topo_result = switches_results1 and switches_results2 and switches_results3\ |
| 341 | #and ports_results1 and ports_results2 and ports_results3\ |
| 342 | #and links_results1 and links_results2 and links_results3 |
| 343 | |
| 344 | topo_result = switches_results1 and switches_results2 and switches_results3\ |
| 345 | and links_results1 and links_results2 and links_results3 |
| 346 | |
| 347 | if topo_result == main.TRUE: |
| 348 | main.log.report("Topology Check Test with mininet and ONOS instances successful") |
| 349 | else: |
| 350 | main.log.report("Topology Check Test with mininet and ONOS instances failed") |
| 351 | |
| 352 | utilities.assert_equals(expect=main.TRUE, actual=topo_result, |
| 353 | onpass="Topology Check Test successful", |
| 354 | onfail="Topology Check Test NOT successful") |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | def CASE10(self): |
| 360 | main.log.report("This testcase uninstalls the reactive forwarding app") |
| 361 | main.log.report("__________________________________") |
| 362 | main.case("Uninstalling reactive forwarding app") |
| 363 | #Unistall onos-app-fwd app to disable reactive forwarding |
| 364 | appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd") |
| 365 | appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd") |
| 366 | appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd") |
| 367 | main.log.info("onos-app-fwd uninstalled") |
| 368 | |
| 369 | #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s |
| 370 | #So sleep for 15s |
| 371 | time.sleep(15) |
| 372 | |
| 373 | hosts = main.ONOScli1.hosts() |
| 374 | main.log.info(hosts) |
| 375 | |
| 376 | case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3 |
| 377 | utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed") |
| 378 | |
| 379 | |
| 380 | def CASE6(self): |
| 381 | main.log.report("This testcase is testing the addition of host intents and then doing pingall") |
| 382 | main.log.report("__________________________________") |
| 383 | main.case("Obtaining hostsfor adding host intents") |
| 384 | main.step("Get hosts") |
| 385 | hosts = main.ONOScli1.hosts() |
| 386 | main.log.info(hosts) |
| 387 | |
| 388 | main.step("Get all devices id") |
| 389 | devices_id_list = main.ONOScli1.get_all_devices_id() |
| 390 | main.log.info(devices_id_list) |
| 391 | |
| 392 | #ONOS displays the hosts in hex format unlike mininet which does in decimal format |
| 393 | #So take care while adding intents |
| 394 | |
| 395 | ''' |
| 396 | main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)") |
| 397 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1") |
| 398 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1") |
| 399 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1") |
| 400 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1") |
| 401 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1") |
| 402 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1") |
| 403 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1") |
| 404 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1") |
| 405 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1") |
| 406 | hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1") |
| 407 | ''' |
| 408 | |
| 409 | for i in range(8,18): |
| 410 | main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10)) |
| 411 | host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper() |
| 412 | host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper() |
| 413 | #NOTE: get host can return None |
| 414 | #TODO: handle this |
| 415 | host1_id = main.ONOScli1.get_host(host1)['id'] |
| 416 | host2_id = main.ONOScli1.get_host(host2)['id'] |
| 417 | tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id ) |
| 418 | |
| 419 | flowHandle = main.ONOScli1.flows() |
| 420 | #print "flowHandle = ", flowHandle |
| 421 | main.log.info("flows:" +flowHandle) |
| 422 | |
| 423 | count = 1 |
| 424 | i = 8 |
| 425 | Ping_Result = main.TRUE |
| 426 | while i <18 : |
| 427 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 428 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 429 | if ping == main.FALSE and count <5: |
| 430 | count+=1 |
| 431 | #i = 8 |
| 432 | Ping_Result = main.FALSE |
| 433 | main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 434 | time.sleep(2) |
| 435 | elif ping==main.FALSE: |
| 436 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 437 | i=19 |
| 438 | Ping_Result = main.FALSE |
| 439 | elif ping==main.TRUE: |
| 440 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!") |
| 441 | i+=1 |
| 442 | Ping_Result = main.TRUE |
| 443 | else: |
| 444 | main.log.info("Unknown error") |
| 445 | Ping_Result = main.ERROR |
| 446 | if Ping_Result==main.FALSE: |
| 447 | main.log.report("Host intents have not ben installed correctly. Cleaning up") |
| 448 | #main.cleanup() |
| 449 | #main.exit() |
| 450 | if Ping_Result==main.TRUE: |
| 451 | main.log.report("Host intents have been installed correctly") |
| 452 | |
| 453 | case6_result = Ping_Result |
| 454 | utilities.assert_equals(expect=main.TRUE, actual=case6_result, |
| 455 | onpass="Host intent addition and Pingall Test successful", |
| 456 | onfail="Host intent addition and Pingall Test NOT successful") |
| 457 | |
| 458 | |
| 459 | def CASE7 (self,main): |
| 460 | |
| 461 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 462 | |
| 463 | link_sleep = int(main.params['timers']['LinkDiscovery']) |
| 464 | |
| 465 | main.log.report("This testscase is killing a link to ensure that link discovery is consistent") |
| 466 | main.log.report("__________________________________") |
| 467 | main.case("Killing a link to Ensure that Link Discovery is Working Properly") |
| 468 | main.step("Start continuous pings") |
| 469 | |
| 470 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 471 | target=main.params['PING']['target1'],pingTime=500) |
| 472 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 473 | target=main.params['PING']['target2'],pingTime=500) |
| 474 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 475 | target=main.params['PING']['target3'],pingTime=500) |
| 476 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 477 | target=main.params['PING']['target4'],pingTime=500) |
| 478 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 479 | target=main.params['PING']['target5'],pingTime=500) |
| 480 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 481 | target=main.params['PING']['target6'],pingTime=500) |
| 482 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 483 | target=main.params['PING']['target7'],pingTime=500) |
| 484 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 485 | target=main.params['PING']['target8'],pingTime=500) |
| 486 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 487 | target=main.params['PING']['target9'],pingTime=500) |
| 488 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 489 | target=main.params['PING']['target10'],pingTime=500) |
| 490 | |
| 491 | |
| 492 | main.step("Determine the current number of switches and links") |
| 493 | topology_output = main.ONOScli1.topology() |
| 494 | topology_result = main.ONOSbench.get_topology(topology_output) |
| 495 | activeSwitches = topology_result['devices'] |
| 496 | links = topology_result['links'] |
| 497 | print "activeSwitches = ", type(activeSwitches) |
| 498 | print "links = ", type(links) |
| 499 | main.log.info("Currently there are %s switches and %s links" %(str(activeSwitches), str(links))) |
| 500 | |
| 501 | main.step("Kill Link between s3 and s28") |
| 502 | main.Mininet1.link(END1="s3",END2="s28",OPTION="down") |
| 503 | time.sleep(link_sleep) |
| 504 | topology_output = main.ONOScli2.topology() |
| 505 | Link_Down = main.ONOSbench.check_status(topology_output,activeSwitches,str(int(links)-2)) |
| 506 | if Link_Down == main.TRUE: |
| 507 | main.log.report("Link Down discovered properly") |
| 508 | utilities.assert_equals(expect=main.TRUE,actual=Link_Down, |
| 509 | onpass="Link Down discovered properly", |
| 510 | onfail="Link down was not discovered in "+ str(link_sleep) + " seconds") |
| 511 | |
| 512 | main.step("Bring link between s3 and s28 back up") |
| 513 | Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up") |
| 514 | time.sleep(link_sleep) |
| 515 | topology_output = main.ONOScli2.topology() |
| 516 | Link_Up = main.ONOSbench.check_status(topology_output,activeSwitches,str(links)) |
| 517 | if Link_Up == main.TRUE: |
| 518 | main.log.report("Link up discovered properly") |
| 519 | utilities.assert_equals(expect=main.TRUE,actual=Link_Up, |
| 520 | onpass="Link up discovered properly", |
| 521 | onfail="Link up was not discovered in "+ str(link_sleep) + " seconds") |
| 522 | |
| 523 | main.step("Compare ONOS Topology to MN Topology") |
| 524 | main.case ("Testing Mininet topology with the topology of multi instances ONOS") |
| 525 | main.step("Collecting topology information from ONOS") |
| 526 | devices1 = main.ONOScli1.devices() |
| 527 | devices2 = main.ONOScli2.devices() |
| 528 | devices3 = main.ONOScli3.devices() |
| 529 | print "devices1 = ", devices1 |
| 530 | print "devices2 = ", devices2 |
| 531 | print "devices3 = ", devices3 |
| 532 | hosts1 = main.ONOScli1.hosts() |
| 533 | hosts2 = main.ONOScli2.hosts() |
| 534 | hosts3 = main.ONOScli3.hosts() |
| 535 | #print "hosts1 = ", hosts1 |
| 536 | #print "hosts2 = ", hosts2 |
| 537 | #print "hosts3 = ", hosts3 |
| 538 | ports1 = main.ONOScli1.ports() |
| 539 | ports2 = main.ONOScli2.ports() |
| 540 | ports3 = main.ONOScli3.ports() |
| 541 | #print "ports1 = ", ports1 |
| 542 | #print "ports2 = ", ports2 |
| 543 | #print "ports3 = ", ports3 |
| 544 | links1 = main.ONOScli1.links() |
| 545 | links2 = main.ONOScli2.links() |
| 546 | links3 = main.ONOScli3.links() |
| 547 | #print "links1 = ", links1 |
| 548 | #print "links2 = ", links2 |
| 549 | #print "links3 = ", links3 |
| 550 | |
| 551 | print "**************" |
| 552 | |
| 553 | main.step("Start continuous pings") |
| 554 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 555 | target=main.params['PING']['target1'],pingTime=500) |
| 556 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 557 | target=main.params['PING']['target2'],pingTime=500) |
| 558 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 559 | target=main.params['PING']['target3'],pingTime=500) |
| 560 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 561 | target=main.params['PING']['target4'],pingTime=500) |
| 562 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 563 | target=main.params['PING']['target5'],pingTime=500) |
| 564 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 565 | target=main.params['PING']['target6'],pingTime=500) |
| 566 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 567 | target=main.params['PING']['target7'],pingTime=500) |
| 568 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 569 | target=main.params['PING']['target8'],pingTime=500) |
| 570 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 571 | target=main.params['PING']['target9'],pingTime=500) |
| 572 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 573 | target=main.params['PING']['target10'],pingTime=500) |
| 574 | |
| 575 | main.step("Create TestONTopology object") |
| 576 | global ctrls |
| 577 | ctrls = [] |
| 578 | count = 1 |
| 579 | while True: |
| 580 | temp = () |
| 581 | if ('ip' + str(count)) in main.params['CTRL']: |
| 582 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 583 | temp = temp + ("ONOS"+str(count),) |
| 584 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 585 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 586 | ctrls.append(temp) |
| 587 | count = count + 1 |
| 588 | else: |
| 589 | break |
| 590 | global MNTopo |
| 591 | Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 592 | MNTopo = Topo |
| 593 | |
| 594 | Topology_Check = main.TRUE |
| 595 | main.step("Compare ONOS Topology to MN Topology") |
| 596 | |
| 597 | switches_results1 = main.Mininet1.compare_switches(MNTopo, json.loads(devices1)) |
| 598 | print "switches_Result1 = ", switches_results1 |
| 599 | utilities.assert_equals(expect=main.TRUE, actual=switches_results1, |
| 600 | onpass="ONOS1 Switches view is correct", |
| 601 | onfail="ONOS1 Switches view is incorrect") |
| 602 | |
| 603 | switches_results2 = main.Mininet1.compare_switches(MNTopo, json.loads(devices2)) |
| 604 | utilities.assert_equals(expect=main.TRUE, actual=switches_results2, |
| 605 | onpass="ONOS2 Switches view is correct", |
| 606 | onfail="ONOS2 Switches view is incorrect") |
| 607 | |
| 608 | switches_results3 = main.Mininet1.compare_switches(MNTopo, json.loads(devices3)) |
| 609 | utilities.assert_equals(expect=main.TRUE, actual=switches_results3, |
| 610 | onpass="ONOS3 Switches view is correct", |
| 611 | onfail="ONOS3 Switches view is incorrect") |
| 612 | |
| 613 | ''' |
| 614 | ports_results1 = main.Mininet1.compare_ports(MNTopo, json.loads(ports1)) |
| 615 | utilities.assert_equals(expect=main.TRUE, actual=ports_results1, |
| 616 | onpass="ONOS1 Ports view is correct", |
| 617 | onfail="ONOS1 Ports view is incorrect") |
| 618 | |
| 619 | ports_results2 = main.Mininet1.compare_ports(MNTopo, json.loads(ports2)) |
| 620 | utilities.assert_equals(expect=main.TRUE, actual=ports_results2, |
| 621 | onpass="ONOS2 Ports view is correct", |
| 622 | onfail="ONOS2 Ports view is incorrect") |
| 623 | |
| 624 | ports_results3 = main.Mininet1.compare_ports(MNTopo, json.loads(ports3)) |
| 625 | utilities.assert_equals(expect=main.TRUE, actual=ports_results3, |
| 626 | onpass="ONOS3 Ports view is correct", |
| 627 | onfail="ONOS3 Ports view is incorrect") |
| 628 | ''' |
| 629 | |
| 630 | links_results1 = main.Mininet1.compare_links(MNTopo, json.loads(links1)) |
| 631 | utilities.assert_equals(expect=main.TRUE, actual=links_results1, |
| 632 | onpass="ONOS1 Links view is correct", |
| 633 | onfail="ONOS1 Links view is incorrect") |
| 634 | |
| 635 | links_results2 = main.Mininet1.compare_links(MNTopo, json.loads(links2)) |
| 636 | utilities.assert_equals(expect=main.TRUE, actual=links_results2, |
| 637 | onpass="ONOS2 Links view is correct", |
| 638 | onfail="ONOS2 Links view is incorrect") |
| 639 | |
| 640 | links_results3 = main.Mininet1.compare_links(MNTopo, json.loads(links3)) |
| 641 | utilities.assert_equals(expect=main.TRUE, actual=links_results3, |
| 642 | onpass="ONOS2 Links view is correct", |
| 643 | onfail="ONOS2 Links view is incorrect") |
| 644 | |
| 645 | #topo_result = switches_results1 and switches_results2 and switches_results3\ |
| 646 | #and ports_results1 and ports_results2 and ports_results3\ |
| 647 | #and links_results1 and links_results2 and links_results3 |
| 648 | |
| 649 | topo_result = switches_results1 and switches_results2 and switches_results3\ |
| 650 | and links_results1 and links_results2 and links_results3 |
| 651 | |
| 652 | utilities.assert_equals(expect=main.TRUE, actual=topo_result and Link_Up and Link_Down, |
| 653 | onpass="Topology Check Test successful", |
| 654 | onfail="Topology Check Test NOT successful") |
| 655 | |
| 656 | |
| 657 | def CASE8(self): |
| 658 | ''' |
| 659 | Intent removal |
| 660 | ''' |
| 661 | main.log.report("This testcase removes host any previously added intents") |
| 662 | main.log.report("__________________________________") |
| 663 | main.log.info("Removing any previously installed intents") |
| 664 | main.case("Removing intents") |
| 665 | main.step("Obtain the intent id's") |
| 666 | intent_result = main.ONOScli1.intents(json_format = False) |
| 667 | |
| 668 | intent_linewise = intent_result.split("\n") |
| 669 | intentList = [] |
| 670 | for line in intent_linewise: |
| 671 | if line.startswith("id="): |
| 672 | intentList.append(line) |
| 673 | |
| 674 | intentids = [] |
| 675 | for line in intentList: |
| 676 | intentids.append(line.split(",")[0].split("=")[1]) |
| 677 | for id in intentids: |
| 678 | main.log.info("id = " +id) |
| 679 | |
| 680 | main.step("Iterate through the intentids list and remove each intent") |
| 681 | for id in intentids: |
| 682 | main.ONOScli1.remove_intent(intent_id = id) |
| 683 | |
| 684 | intent_result = main.ONOScli1.intents(json_format = False) |
| 685 | main.log.info("intent_result = " +intent_result) |
| 686 | case8_result = main.TRUE |
| 687 | |
| 688 | i = 8 |
| 689 | Ping_Result = main.TRUE |
| 690 | while i <18 : |
| 691 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 692 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 693 | if ping==main.TRUE: |
| 694 | i = 19 |
| 695 | Ping_Result = main.TRUE |
| 696 | elif ping==main.FALSE: |
| 697 | i+=1 |
| 698 | Ping_Result = main.FALSE |
| 699 | else: |
| 700 | main.log.info("Unknown error") |
| 701 | Ping_Result = main.ERROR |
| 702 | |
| 703 | #Note: If the ping result failed, that means the intents have been withdrawn correctly. |
| 704 | if Ping_Result==main.TRUE: |
| 705 | main.log.report("Host intents have not been withdrawn correctly") |
| 706 | #main.cleanup() |
| 707 | #main.exit() |
| 708 | if Ping_Result==main.FALSE: |
| 709 | main.log.report("Host intents have been withdrawn correctly") |
| 710 | |
| 711 | case8_result = case8_result and Ping_Result |
| 712 | |
| 713 | if case8_result == main.FALSE: |
| 714 | main.log.report("Intent removal successful") |
| 715 | else: |
| 716 | main.log.report("Intent removal failed") |
| 717 | |
| 718 | utilities.assert_equals(expect=main.FALSE, actual=case8_result, |
| 719 | onpass="Intent removal test failed", |
| 720 | onfail="Intent removal test successful") |
| 721 | |
| 722 | |
| 723 | def CASE9(self): |
| 724 | ''' |
| 725 | This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case. |
| 726 | Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows |
| 727 | ''' |
| 728 | main.log.report("This testcase adds point intents and then does pingall") |
| 729 | main.log.report("__________________________________") |
| 730 | main.log.info("Adding point intents") |
| 731 | 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)") |
| 732 | main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12") |
| 733 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1") |
| 734 | if ptp_intent_result == main.TRUE: |
| 735 | get_intent_result = main.ONOScli1.intents() |
| 736 | main.log.info("Point to point intent install successful") |
| 737 | #main.log.info(get_intent_result) |
| 738 | |
| 739 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1") |
| 740 | if ptp_intent_result == main.TRUE: |
| 741 | get_intent_result = main.ONOScli1.intents() |
| 742 | main.log.info("Point to point intent install successful") |
| 743 | #main.log.info(get_intent_result) |
| 744 | |
| 745 | main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13") |
| 746 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1") |
| 747 | if ptp_intent_result == main.TRUE: |
| 748 | get_intent_result = main.ONOScli1.intents() |
| 749 | main.log.info("Point to point intent install successful") |
| 750 | #main.log.info(get_intent_result) |
| 751 | |
| 752 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1") |
| 753 | if ptp_intent_result == main.TRUE: |
| 754 | get_intent_result = main.ONOScli1.intents() |
| 755 | main.log.info("Point to point intent install successful") |
| 756 | #main.log.info(get_intent_result) |
| 757 | |
| 758 | main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14") |
| 759 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1") |
| 760 | if ptp_intent_result == main.TRUE: |
| 761 | get_intent_result = main.ONOScli1.intents() |
| 762 | main.log.info("Point to point intent install successful") |
| 763 | #main.log.info(get_intent_result) |
| 764 | |
| 765 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1") |
| 766 | if ptp_intent_result == main.TRUE: |
| 767 | get_intent_result = main.ONOScli1.intents() |
| 768 | main.log.info("Point to point intent install successful") |
| 769 | #main.log.info(get_intent_result) |
| 770 | |
| 771 | main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15") |
| 772 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1") |
| 773 | if ptp_intent_result == main.TRUE: |
| 774 | get_intent_result = main.ONOScli1.intents() |
| 775 | main.log.info("Point to point intent install successful") |
| 776 | #main.log.info(get_intent_result) |
| 777 | |
| 778 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1") |
| 779 | if ptp_intent_result == main.TRUE: |
| 780 | get_intent_result = main.ONOScli1.intents() |
| 781 | main.log.info("Point to point intent install successful") |
| 782 | #main.log.info(get_intent_result) |
| 783 | |
| 784 | main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16") |
| 785 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1") |
| 786 | if ptp_intent_result == main.TRUE: |
| 787 | get_intent_result = main.ONOScli1.intents() |
| 788 | main.log.info("Point to point intent install successful") |
| 789 | #main.log.info(get_intent_result) |
| 790 | |
| 791 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1") |
| 792 | if ptp_intent_result == main.TRUE: |
| 793 | get_intent_result = main.ONOScli1.intents() |
| 794 | main.log.info("Point to point intent install successful") |
| 795 | #main.log.info(get_intent_result) |
| 796 | |
| 797 | main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17") |
| 798 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1") |
| 799 | if ptp_intent_result == main.TRUE: |
| 800 | get_intent_result = main.ONOScli1.intents() |
| 801 | main.log.info("Point to point intent install successful") |
| 802 | #main.log.info(get_intent_result) |
| 803 | |
| 804 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1") |
| 805 | if ptp_intent_result == main.TRUE: |
| 806 | get_intent_result = main.ONOScli1.intents() |
| 807 | main.log.info("Point to point intent install successful") |
| 808 | #main.log.info(get_intent_result) |
| 809 | |
| 810 | main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18") |
| 811 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1") |
| 812 | if ptp_intent_result == main.TRUE: |
| 813 | get_intent_result = main.ONOScli1.intents() |
| 814 | main.log.info("Point to point intent install successful") |
| 815 | #main.log.info(get_intent_result) |
| 816 | |
| 817 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1") |
| 818 | if ptp_intent_result == main.TRUE: |
| 819 | get_intent_result = main.ONOScli1.intents() |
| 820 | main.log.info("Point to point intent install successful") |
| 821 | #main.log.info(get_intent_result) |
| 822 | |
| 823 | main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19") |
| 824 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1") |
| 825 | if ptp_intent_result == main.TRUE: |
| 826 | get_intent_result = main.ONOScli1.intents() |
| 827 | main.log.info("Point to point intent install successful") |
| 828 | #main.log.info(get_intent_result) |
| 829 | |
| 830 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1") |
| 831 | if ptp_intent_result == main.TRUE: |
| 832 | get_intent_result = main.ONOScli1.intents() |
| 833 | main.log.info("Point to point intent install successful") |
| 834 | #main.log.info(get_intent_result) |
| 835 | |
| 836 | main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A") |
| 837 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1") |
| 838 | if ptp_intent_result == main.TRUE: |
| 839 | get_intent_result = main.ONOScli1.intents() |
| 840 | main.log.info("Point to point intent install successful") |
| 841 | #main.log.info(get_intent_result) |
| 842 | |
| 843 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1") |
| 844 | if ptp_intent_result == main.TRUE: |
| 845 | get_intent_result = main.ONOScli1.intents() |
| 846 | main.log.info("Point to point intent install successful") |
| 847 | #main.log.info(get_intent_result) |
| 848 | |
| 849 | |
| 850 | main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B") |
| 851 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1") |
| 852 | if ptp_intent_result == main.TRUE: |
| 853 | get_intent_result = main.ONOScli1.intents() |
| 854 | main.log.info("Point to point intent install successful") |
| 855 | #main.log.info(get_intent_result) |
| 856 | |
| 857 | ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1") |
| 858 | if ptp_intent_result == main.TRUE: |
| 859 | get_intent_result = main.ONOScli1.intents() |
| 860 | main.log.info("Point to point intent install successful") |
| 861 | #main.log.info(get_intent_result) |
| 862 | |
| 863 | print("_______________________________________________________________________________________") |
| 864 | |
| 865 | flowHandle = main.ONOScli1.flows() |
| 866 | #print "flowHandle = ", flowHandle |
| 867 | main.log.info("flows :" + flowHandle) |
| 868 | |
| 869 | count = 1 |
| 870 | i = 8 |
| 871 | Ping_Result = main.TRUE |
| 872 | while i <18 : |
| 873 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 874 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 875 | if ping == main.FALSE and count <5: |
| 876 | count+=1 |
| 877 | #i = 8 |
| 878 | Ping_Result = main.FALSE |
| 879 | main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 880 | time.sleep(2) |
| 881 | elif ping==main.FALSE: |
| 882 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 883 | i=19 |
| 884 | Ping_Result = main.FALSE |
| 885 | elif ping==main.TRUE: |
| 886 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!") |
| 887 | i+=1 |
| 888 | Ping_Result = main.TRUE |
| 889 | else: |
| 890 | main.log.info("Unknown error") |
| 891 | Ping_Result = main.ERROR |
| 892 | if Ping_Result==main.FALSE: |
| 893 | main.log.report("Ping all test after Point intents addition failed. Cleaning up") |
| 894 | #main.cleanup() |
| 895 | #main.exit() |
| 896 | if Ping_Result==main.TRUE: |
| 897 | main.log.report("Ping all test after Point intents addition successful") |
| 898 | |
| 899 | case8_result = Ping_Result |
| 900 | utilities.assert_equals(expect=main.TRUE, actual=case8_result, |
| 901 | onpass="Ping all test after Point intents addition successful", |
| 902 | onfail="Ping all test after Point intents addition failed") |
| 903 | |
| 904 | def CASE31(self): |
| 905 | ''' |
| 906 | This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1) |
| 907 | ''' |
| 908 | import json |
| 909 | |
| 910 | main.log.report("This test case adds point intent related to SDN-IP matching on ICMP") |
| 911 | main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP") |
| 912 | main.step("Adding bidirectional point intent") |
| 913 | #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1 |
| 914 | |
| 915 | hosts_json = json.loads(main.ONOScli1.hosts()) |
| 916 | for i in range(8,11): |
| 917 | main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10)) |
| 918 | host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper() |
| 919 | host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper() |
| 920 | host1_id = main.ONOScli1.get_host(host1)['id'] |
| 921 | host2_id = main.ONOScli1.get_host(host2)['id'] |
| 922 | for host in hosts_json: |
| 923 | if host['id'] == host1_id: |
| 924 | ip1 = host['ips'][0] |
| 925 | ip1 = str(ip1+"/32") |
| 926 | device1 = host['location']['device'] |
| 927 | device1 = str(device1+"/1") |
| 928 | elif host['id'] == host2_id: |
| 929 | ip2 = str(host['ips'][0])+"/32" |
| 930 | device2 = host['location']["device"] |
| 931 | device2 = str(device2+"/1") |
| 932 | |
| 933 | p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2, |
| 934 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) |
| 935 | |
| 936 | get_intent_result = main.ONOScli1.intents(json_format = False) |
| 937 | main.log.info(get_intent_result) |
| 938 | |
| 939 | p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, |
| 940 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto']) |
| 941 | |
| 942 | get_intent_result = main.ONOScli1.intents(json_format = False) |
| 943 | main.log.info(get_intent_result) |
| 944 | if (p_intent_result1 and p_intent_result2) == main.TRUE: |
| 945 | #get_intent_result = main.ONOScli1.intents() |
| 946 | #main.log.info(get_intent_result) |
| 947 | main.log.info("Point intent related to SDN-IP matching on ICMP install successful") |
| 948 | |
| 949 | time.sleep(15) |
| 950 | get_intent_result = main.ONOScli1.intents(json_format = False) |
| 951 | main.log.info("intents = "+ get_intent_result) |
| 952 | get_flows_result = main.ONOScli1.flows() |
| 953 | main.log.info("flows = " + get_flows_result) |
| 954 | |
| 955 | count = 1 |
| 956 | i = 8 |
| 957 | Ping_Result = main.TRUE |
| 958 | while i <11 : |
| 959 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10)) |
| 960 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 961 | if ping == main.FALSE and count <3: |
| 962 | count+=1 |
| 963 | #i = 8 |
| 964 | Ping_Result = main.FALSE |
| 965 | main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 966 | time.sleep(2) |
| 967 | elif ping==main.FALSE: |
| 968 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 969 | i=19 |
| 970 | Ping_Result = main.FALSE |
| 971 | elif ping==main.TRUE: |
| 972 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!") |
| 973 | i+=1 |
| 974 | Ping_Result = main.TRUE |
| 975 | else: |
| 976 | main.log.info("Unknown error") |
| 977 | Ping_Result = main.ERROR |
| 978 | if Ping_Result==main.FALSE: |
| 979 | main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.") |
| 980 | #main.cleanup() |
| 981 | #main.exit() |
| 982 | if Ping_Result==main.TRUE: |
| 983 | main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful") |
| 984 | |
| 985 | case31_result = Ping_Result and p_intent_result1 and p_intent_result2 |
| 986 | utilities.assert_equals(expect=main.TRUE, actual=case31_result, |
| 987 | onpass="Point intent related to SDN-IP matching on ICMP and ping test successful", |
| 988 | onfail="Point intent related to SDN-IP matching on ICMP and ping test failed") |
| 989 | |
| 990 | def CASE32(self): |
| 991 | ''' |
| 992 | This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001) |
| 993 | Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001 |
| 994 | ''' |
| 995 | import json |
| 996 | |
| 997 | main.log.report("This test case adds point intent related to SDN-IP matching on TCP") |
| 998 | main.case("Adding bidirectional point intent related to SDN-IP matching on TCP") |
| 999 | main.step("Adding bidirectional point intent") |
| 1000 | """ |
| 1001 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1 |
| 1002 | |
| 1003 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1 |
| 1004 | |
| 1005 | add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1 |
| 1006 | |
| 1007 | add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1 |
| 1008 | |
| 1009 | """ |
| 1010 | |
| 1011 | hosts_json = json.loads(main.ONOScli1.hosts()) |
| 1012 | for i in range(8,9): |
| 1013 | main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10)) |
| 1014 | host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper() |
| 1015 | host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper() |
| 1016 | host1_id = main.ONOScli1.get_host(host1)['id'] |
| 1017 | host2_id = main.ONOScli1.get_host(host2)['id'] |
| 1018 | for host in hosts_json: |
| 1019 | if host['id'] == host1_id: |
| 1020 | ip1 = host['ips'][0] |
| 1021 | ip1 = str(ip1+"/32") |
| 1022 | device1 = host['location']['device'] |
| 1023 | device1 = str(device1+"/1") |
| 1024 | elif host['id'] == host2_id: |
| 1025 | ip2 = str(host['ips'][0])+"/32" |
| 1026 | device2 = host['location']["device"] |
| 1027 | device2 = str(device2+"/1") |
| 1028 | |
| 1029 | p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2, |
| 1030 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) |
| 1031 | p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, |
| 1032 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort']) |
| 1033 | |
| 1034 | p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2, |
| 1035 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) |
| 1036 | p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1, |
| 1037 | ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort']) |
| 1038 | |
| 1039 | p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4 |
| 1040 | if p_intent_result ==main.TRUE: |
| 1041 | get_intent_result = main.ONOScli1.intents(json_format = False) |
| 1042 | main.log.info(get_intent_result) |
| 1043 | main.log.info("Point intent related to SDN-IP matching on TCP install successful") |
| 1044 | |
| 1045 | iperf_result = main.Mininet1.iperf('h8', 'h18') |
| 1046 | if iperf_result == main.TRUE: |
| 1047 | main.log.report("iperf test successful") |
| 1048 | else: |
| 1049 | main.log.report("iperf test failed") |
| 1050 | |
| 1051 | |
| 1052 | case32_result = p_intent_result and iperf_result |
| 1053 | utilities.assert_equals(expect=main.TRUE, actual=case32_result, |
| 1054 | onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful", |
| 1055 | onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed") |
| 1056 | |
| 1057 | |
| 1058 | def CASE33(self): |
| 1059 | ''' |
| 1060 | This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address |
| 1061 | Here the mac address to be rewritten is the mac address of the egress device |
| 1062 | ''' |
| 1063 | import json |
| 1064 | import time |
| 1065 | |
| 1066 | main.log.report("This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action") |
| 1067 | main.case("Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip") |
| 1068 | main.step("Adding bidirectional multipoint to singlepoint intent") |
| 1069 | """ |
| 1070 | add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1 |
| 1071 | |
| 1072 | add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1 |
| 1073 | """ |
| 1074 | |
| 1075 | main.case("Installing multipoint to single point intent with rewrite mac address") |
| 1076 | main.step("Uninstalling proxy arp app") |
| 1077 | #Unistall onos-app-proxyarp app to disable reactive forwarding |
| 1078 | appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-proxyarp") |
| 1079 | appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-proxyarp") |
| 1080 | appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-proxyarp") |
| 1081 | main.log.info("onos-app-proxyarp uninstalled") |
| 1082 | |
| 1083 | main.step("Changing ipaddress of hosts h8,h9 and h18") |
| 1084 | main.Mininet1.changeIP(host='h8', intf='h8-eth0', newIP='10.0.1.1', newNetmask='255.255.255.0') |
| 1085 | main.Mininet1.changeIP(host='h9', intf='h9-eth0', newIP='10.0.2.1', newNetmask='255.255.255.0') |
| 1086 | main.Mininet1.changeIP(host='h10', intf='h10-eth0', newIP='10.0.3.1', newNetmask='255.255.255.0') |
| 1087 | |
| 1088 | main.step("Changing default gateway of hosts h8,h9 and h18") |
| 1089 | main.Mininet1.changeDefaultGateway(host='h8', newGW='10.0.1.254') |
| 1090 | main.Mininet1.changeDefaultGateway(host='h9', newGW='10.0.2.254') |
| 1091 | main.Mininet1.changeDefaultGateway(host='h10', newGW='10.0.3.254') |
| 1092 | |
| 1093 | main.step("Assigning random mac address to the default gateways since proxyarp app is uninstalled") |
| 1094 | main.Mininet1.addStaticMACAddress(host='h8', GW='10.0.1.254', macaddr='00:00:00:00:11:11') |
| 1095 | main.Mininet1.addStaticMACAddress(host='h9', GW='10.0.2.254', macaddr='00:00:00:00:22:22') |
| 1096 | main.Mininet1.addStaticMACAddress(host='h10', GW='10.0.3.254', macaddr='00:00:00:00:33:33') |
| 1097 | |
| 1098 | main.step("Verify static gateway and MAC address assignment") |
| 1099 | main.Mininet1.verifyStaticGWandMAC(host='h8') |
| 1100 | main.Mininet1.verifyStaticGWandMAC(host='h9') |
| 1101 | main.Mininet1.verifyStaticGWandMAC(host='h10') |
| 1102 | |
| 1103 | main.step("Adding multipoint to singlepoint intent") |
| 1104 | p_intent_result1 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device1'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'], |
| 1105 | egress_device=main.params['MULTIPOINT_INTENT']['device3'], ipDst=main.params['MULTIPOINT_INTENT']['ip1'], setEthDst=main.params['MULTIPOINT_INTENT']['mac1']) |
| 1106 | |
| 1107 | p_intent_result2 = main.ONOScli1.add_multipoint_to_singlepoint_intent(ingress_device1=main.params['MULTIPOINT_INTENT']['device3'], ingress_device2=main.params['MULTIPOINT_INTENT']['device2'], |
| 1108 | egress_device=main.params['MULTIPOINT_INTENT']['device1'], ipDst=main.params['MULTIPOINT_INTENT']['ip2'], setEthDst=main.params['MULTIPOINT_INTENT']['mac2']) |
| 1109 | |
| 1110 | |
| 1111 | get_intent_result = main.ONOScli1.intents(json_format = False) |
| 1112 | main.log.info("intents = "+ get_intent_result) |
| 1113 | |
| 1114 | time.sleep(10) |
| 1115 | get_flows_result = main.ONOScli1.flows(json_format = False) |
| 1116 | main.log.info("flows = " + get_flows_result) |
| 1117 | |
| 1118 | count = 1 |
| 1119 | i = 8 |
| 1120 | Ping_Result = main.TRUE |
| 1121 | |
| 1122 | main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+2)) |
| 1123 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+2)) |
| 1124 | if ping == main.FALSE and count <3: |
| 1125 | count+=1 |
| 1126 | Ping_Result = main.FALSE |
| 1127 | main.log.report("Ping between h" + str(i) + " and h" + str(i+2) + " failed. Making attempt number "+str(count) + " in 2 seconds") |
| 1128 | time.sleep(2) |
| 1129 | elif ping==main.FALSE: |
| 1130 | main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed") |
| 1131 | Ping_Result = main.FALSE |
| 1132 | elif ping==main.TRUE: |
| 1133 | main.log.info("Ping test between h" + str(i) + " and h" + str(i+2) + "passed!") |
| 1134 | Ping_Result = main.TRUE |
| 1135 | else: |
| 1136 | main.log.info("Unknown error") |
| 1137 | Ping_Result = main.ERROR |
| 1138 | |
| 1139 | if Ping_Result==main.FALSE: |
| 1140 | main.log.report("Ping test failed.") |
| 1141 | #main.cleanup() |
| 1142 | #main.exit() |
| 1143 | if Ping_Result==main.TRUE: |
| 1144 | main.log.report("Ping all successful") |
| 1145 | |
| 1146 | |
| 1147 | p_intent_result = p_intent_result1 and p_intent_result2 |
| 1148 | if p_intent_result ==main.TRUE: |
| 1149 | main.log.info("Multi point intent with rewrite mac address installation successful") |
| 1150 | else: |
| 1151 | main.log.info("Multi point intent with rewrite mac address installation failed") |
| 1152 | |
| 1153 | case33_result = p_intent_result and Ping_Result |
| 1154 | utilities.assert_equals(expect=main.TRUE, actual=case33_result, |
| 1155 | onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful", |
| 1156 | onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed") |