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