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