andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 1 | |
| 2 | #Testing the basic functionality of ONOS Next |
| 3 | #For sanity and driver functionality excercises only. |
| 4 | |
andrewonlab | 7735d85 | 2014-10-09 13:02:47 -0400 | [diff] [blame] | 5 | import time |
| 6 | import sys |
| 7 | import os |
andrewonlab | 2d35516 | 2014-10-10 00:43:59 -0400 | [diff] [blame] | 8 | import re |
andrewonlab | 7735d85 | 2014-10-09 13:02:47 -0400 | [diff] [blame] | 9 | |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 10 | class ONOSNextTest: |
| 11 | def __init__(self): |
| 12 | self.default = '' |
| 13 | |
| 14 | def CASE1(self, main): |
| 15 | ''' |
| 16 | Startup sequence: |
| 17 | git pull |
| 18 | mvn clean install |
| 19 | onos-package |
| 20 | cell <name> |
| 21 | onos-verify-cell |
| 22 | onos-install -f |
| 23 | onos-wait-for-start |
| 24 | ''' |
andrewonlab | 7735d85 | 2014-10-09 13:02:47 -0400 | [diff] [blame] | 25 | |
andrewonlab | 084307e | 2014-10-09 14:06:09 -0400 | [diff] [blame] | 26 | cell_name = main.params['ENV']['cellName'] |
| 27 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrew@onlab.us | 59e8f69 | 2014-10-09 21:41:48 -0400 | [diff] [blame] | 28 | ONOS1_port = main.params['CTRL']['port1'] |
Jon Hall | ea7818b | 2014-10-09 14:30:59 -0400 | [diff] [blame] | 29 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 30 | main.case("Setting up test environment") |
Jon Hall | 3be576e | 2014-10-09 22:23:03 -0400 | [diff] [blame] | 31 | |
andrewonlab | 9428209 | 2014-10-10 13:00:11 -0400 | [diff] [blame] | 32 | main.step("Creating cell file") |
andrewonlab | 2c010fb | 2014-10-10 18:08:59 -0400 | [diff] [blame] | 33 | #params: (bench ip, cell name, mininet ip, *onos ips) |
andrewonlab | 9428209 | 2014-10-10 13:00:11 -0400 | [diff] [blame] | 34 | cell_file_result = main.ONOSbench.create_cell_file( |
| 35 | "10.128.20.10", "temp_cell_2", "10.128.10.90", |
| 36 | "10.128.10.11", "10.128.10.12", "10.128.10.13") |
| 37 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 38 | main.step("Applying cell variable to environment") |
andrewonlab | 084307e | 2014-10-09 14:06:09 -0400 | [diff] [blame] | 39 | cell_result = main.ONOSbench.set_cell(cell_name) |
andrewonlab | c03bf6c | 2014-10-09 14:56:18 -0400 | [diff] [blame] | 40 | verify_result = main.ONOSbench.verify_cell() |
andrewonlab | 2fe32ad | 2014-10-09 16:36:40 -0400 | [diff] [blame] | 41 | |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 42 | main.step("Git checkout and pull master") |
| 43 | main.ONOSbench.git_checkout("master") |
| 44 | git_pull_result = main.ONOSbench.git_pull() |
| 45 | |
| 46 | |
| 47 | main.step("Using mvn clean & install") |
| 48 | clean_install_result = main.ONOSbench.clean_install() |
| 49 | #clean_install_result = main.TRUE |
| 50 | |
| 51 | main.step("Creating ONOS package") |
| 52 | package_result = main.ONOSbench.onos_package() |
| 53 | |
andrewonlab | 2fe32ad | 2014-10-09 16:36:40 -0400 | [diff] [blame] | 54 | main.step("Installing ONOS package") |
Jon Hall | 7993bfc | 2014-10-09 16:30:14 -0400 | [diff] [blame] | 55 | onos_install_result = main.ONOSbench.onos_install() |
| 56 | onos1_isup = main.ONOSbench.isup() |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 57 | |
| 58 | main.step("Starting ONOS service") |
| 59 | start_result = main.ONOSbench.onos_start(ONOS1_ip) |
| 60 | |
Jon Hall | 7993bfc | 2014-10-09 16:30:14 -0400 | [diff] [blame] | 61 | case1_result = (clean_install_result and package_result and\ |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 62 | cell_result and verify_result and onos_install_result and\ |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 63 | onos1_isup and start_result ) |
andrewonlab | 0748d2a | 2014-10-09 13:24:17 -0400 | [diff] [blame] | 64 | utilities.assert_equals(expect=main.TRUE, actual=case1_result, |
| 65 | onpass="Test startup successful", |
| 66 | onfail="Test startup NOT successful") |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 67 | |
andrewonlab | 05e362f | 2014-10-10 00:40:57 -0400 | [diff] [blame] | 68 | def CASE11(self, main): |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 69 | ''' |
| 70 | Cleanup sequence: |
| 71 | onos-service <node_ip> stop |
| 72 | onos-uninstall |
| 73 | |
| 74 | TODO: Define rest of cleanup |
| 75 | |
| 76 | ''' |
| 77 | |
| 78 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 79 | |
| 80 | main.case("Cleaning up test environment") |
| 81 | |
andrewonlab | 057c06a | 2014-10-09 17:19:21 -0400 | [diff] [blame] | 82 | main.step("Testing ONOS kill function") |
| 83 | kill_result = main.ONOSbench.onos_kill(ONOS1_ip) |
| 84 | |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 85 | main.step("Stopping ONOS service") |
| 86 | stop_result = main.ONOSbench.onos_stop(ONOS1_ip) |
| 87 | |
| 88 | main.step("Uninstalling ONOS service") |
andrewonlab | 057c06a | 2014-10-09 17:19:21 -0400 | [diff] [blame] | 89 | uninstall_result = main.ONOSbench.onos_uninstall() |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 90 | |
andrewonlab | 05e362f | 2014-10-10 00:40:57 -0400 | [diff] [blame] | 91 | def CASE3(self, main): |
| 92 | ''' |
| 93 | Test 'onos' command and its functionality in driver |
| 94 | ''' |
| 95 | |
| 96 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | 05e362f | 2014-10-10 00:40:57 -0400 | [diff] [blame] | 97 | |
| 98 | main.case("Testing 'onos' command") |
| 99 | |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 100 | main.step("Sending command 'onos -w <onos-ip> system:name'") |
| 101 | cmdstr1 = "system:name" |
| 102 | cmd_result1 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr1) |
| 103 | main.log.info("onos command returned: "+cmd_result1) |
| 104 | |
| 105 | main.step("Sending command 'onos -w <onos-ip> onos:topology'") |
| 106 | cmdstr2 = "onos:topology" |
| 107 | cmd_result2 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr2) |
| 108 | main.log.info("onos command returned: "+cmd_result2) |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 109 | |
| 110 | main.step("Testing check_status") |
| 111 | check_status_results = main.ONOSbench.check_status(ONOS1_ip, 4, 6) |
| 112 | main.log.info("Results of check_status " + str(check_status_results)) |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 113 | |
andrewonlab | 2c010fb | 2014-10-10 18:08:59 -0400 | [diff] [blame] | 114 | main.step("Sending command 'onos -w <onos-ip> bundle:list'") |
| 115 | cmdstr3 = "bundle:list" |
| 116 | cmd_result3 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr3) |
| 117 | main.log.info("onos command returned: "+cmd_result3) |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 118 | case3_result = (cmd_result1 and cmd_result2 and\ |
| 119 | check_status_results and cmd_result3 ) |
| 120 | utilities.assert_equals(expect=main.TRUE, actual=case3_result, |
| 121 | onpass="Test case 3 successful", |
| 122 | onfail="Test case 3 NOT successful") |
andrewonlab | 2c010fb | 2014-10-10 18:08:59 -0400 | [diff] [blame] | 123 | |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 124 | def CASE4(self, main): |
Jon Hall | 3173533 | 2014-10-10 15:27:43 -0400 | [diff] [blame] | 125 | import re |
| 126 | import time |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 127 | main.case("Pingall Test(No intents are added)") |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 128 | main.step("Assigning switches to controllers") |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 129 | for i in range(1,5): #1 to (num of switches +1) |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 130 | main.Mininet1.assign_sw_controller(sw=str(i), |
| 131 | ip1=ONOS1_ip, port1=ONOS1_port) |
| 132 | switch_mastership = main.TRUE |
Jon Hall | 77f53ce | 2014-10-13 18:02:06 -0400 | [diff] [blame] | 133 | for i in range (1,5): |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 134 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 135 | print("Response is " + str(response)) |
| 136 | if re.search("tcp:"+ONOS1_ip,response): |
| 137 | switch_mastership = switch_mastership and main.TRUE |
| 138 | else: |
| 139 | switch_mastership = main.FALSE |
| 140 | |
| 141 | #REACTIVE FWD test |
| 142 | main.step("Pingall") |
| 143 | ping_result = main.FALSE |
| 144 | while ping_result == main.FALSE: |
| 145 | time1 = time.time() |
| 146 | ping_result = main.Mininet1.pingall() |
| 147 | time2 = time.time() |
| 148 | print "Time for pingall: %2f seconds" % (time2 - time1) |
| 149 | |
| 150 | case4_result = switch_mastership and ping_result |
| 151 | utilities.assert_equals(expect=main.TRUE, actual=case4_result, |
Jon Hall | 3173533 | 2014-10-10 15:27:43 -0400 | [diff] [blame] | 152 | onpass="Pingall Test successful", |
| 153 | onfail="Pingall Test NOT successful") |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 154 | |
andrewonlab | c7345f2 | 2014-10-13 14:12:59 -0400 | [diff] [blame] | 155 | def CASE5(self, main): |
| 156 | ''' |
| 157 | Test the ONOS-cli functionality |
andrewonlab | 7e4d2d3 | 2014-10-15 13:23:21 -0400 | [diff] [blame] | 158 | |
andrewonlab | 3e15ead | 2014-10-15 14:21:34 -0400 | [diff] [blame] | 159 | Below are demonstrations of what the |
| 160 | ONOS cli driver functions can be used for. |
andrewonlab | c7345f2 | 2014-10-13 14:12:59 -0400 | [diff] [blame] | 161 | ''' |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 162 | import time |
| 163 | |
andrewonlab | c7345f2 | 2014-10-13 14:12:59 -0400 | [diff] [blame] | 164 | cell_name = main.params['ENV']['cellName'] |
| 165 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 166 | |
| 167 | main.case("Testing the ONOS-cli") |
| 168 | |
| 169 | main.step("Set cell for ONOS-cli environment") |
| 170 | main.ONOScli.set_cell(cell_name) |
| 171 | |
| 172 | main.step("Start ONOS-cli") |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 173 | main.ONOScli.start_onos_cli(ONOS1_ip) |
andrewonlab | c7345f2 | 2014-10-13 14:12:59 -0400 | [diff] [blame] | 174 | |
| 175 | main.step("issue command: onos:topology") |
andrewonlab | 7c21157 | 2014-10-15 16:45:20 -0400 | [diff] [blame] | 176 | topology_obj = main.ONOScli.topology() |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 177 | |
| 178 | main.step("issue various feature:install <str> commands") |
| 179 | main.ONOScli.feature_install("onos-app-fwd") |
| 180 | main.ONOScli.feature_install("onos-rest") |
| 181 | |
| 182 | main.step("Add a bad node") |
| 183 | node_result = main.ONOScli.add_node("111", "10.128.20.") |
| 184 | if node_result == main.TRUE: |
| 185 | main.log.info("Node successfully added") |
| 186 | |
| 187 | main.step("Add a correct node") |
| 188 | node_result = main.ONOScli.add_node("111", "10.128.20.12") |
| 189 | |
andrewonlab | 7e4d2d3 | 2014-10-15 13:23:21 -0400 | [diff] [blame] | 190 | main.step("Assign switches and list devices") |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 191 | for i in range(1,8): |
andrewonlab | f80585f | 2014-10-13 19:00:11 -0400 | [diff] [blame] | 192 | main.Mininet2.handle.sendline("sh ovs-vsctl set-controller s"+str(i)+ |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 193 | " tcp:10.128.20.11") |
andrewonlab | f80585f | 2014-10-13 19:00:11 -0400 | [diff] [blame] | 194 | main.Mininet2.handle.expect("mininet>") |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 195 | #Need to sleep to allow switch add processing |
andrewonlab | 7e4d2d3 | 2014-10-15 13:23:21 -0400 | [diff] [blame] | 196 | time.sleep(5) |
andrewonlab | 86dc308 | 2014-10-13 18:18:38 -0400 | [diff] [blame] | 197 | list_result = main.ONOScli.devices() |
| 198 | main.log.info(list_result) |
| 199 | |
andrewonlab | 7e4d2d3 | 2014-10-15 13:23:21 -0400 | [diff] [blame] | 200 | main.step("Get all devices id") |
| 201 | devices_id_list = main.ONOScli.get_all_devices_id() |
| 202 | main.log.info(devices_id_list) |
andrewonlab | c7345f2 | 2014-10-13 14:12:59 -0400 | [diff] [blame] | 203 | |
andrewonlab | 3e15ead | 2014-10-15 14:21:34 -0400 | [diff] [blame] | 204 | main.step("Get path and cost between device 1 and 7") |
| 205 | (path, cost) = main.ONOScli.paths(devices_id_list[0], devices_id_list[6]) |
| 206 | main.log.info("Path: "+str(path)) |
| 207 | main.log.info("Cost: "+str(cost)) |
andrewonlab | 7c21157 | 2014-10-15 16:45:20 -0400 | [diff] [blame] | 208 | |
| 209 | main.step("Get nodes currently visible") |
| 210 | nodes_str = main.ONOScli.nodes() |
| 211 | main.log.info(nodes_str) |
| 212 | |
| 213 | main.step("Get all nodes id's") |
| 214 | node_id_list = main.ONOScli.get_all_nodes_id() |
| 215 | main.log.info(node_id_list) |
| 216 | |
| 217 | main.step("Set device "+str(devices_id_list[0])+" to role: standby") |
| 218 | device_role_result = main.ONOScli.device_role( |
| 219 | devices_id_list[0], node_id_list[0], "standby") |
| 220 | if device_role_result == main.TRUE: |
| 221 | main.log.report("Device role successfully set") |
| 222 | |
| 223 | main.step("Check devices / role again") |
| 224 | dev_result = main.ONOScli.devices() |
| 225 | main.log.info(dev_result) |
| 226 | |
andrewonlab | 7e4d2d3 | 2014-10-15 13:23:21 -0400 | [diff] [blame] | 227 | ###### |
| 228 | #jhall@onlab.us |
| 229 | #andrew@onlab.us |
| 230 | ###### |