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 | |
| 33 | main.step("Git checkout and pull master") |
andrewonlab | 9428209 | 2014-10-10 13:00:11 -0400 | [diff] [blame] | 34 | #main.ONOSbench.git_checkout("master") |
| 35 | #git_pull_result = main.ONOSbench.git_pull() |
Jon Hall | 3be576e | 2014-10-09 22:23:03 -0400 | [diff] [blame] | 36 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 37 | |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 38 | main.step("Using mvn clean & install") |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 39 | #clean_install_result = main.ONOSbench.clean_install() |
| 40 | clean_install_result = main.TRUE |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 41 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 42 | main.step("Creating ONOS package") |
andrewonlab | 7735d85 | 2014-10-09 13:02:47 -0400 | [diff] [blame] | 43 | package_result = main.ONOSbench.onos_package() |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 44 | |
andrewonlab | 9428209 | 2014-10-10 13:00:11 -0400 | [diff] [blame] | 45 | main.step("Creating cell file") |
| 46 | cell_file_result = main.ONOSbench.create_cell_file( |
| 47 | "10.128.20.10", "temp_cell_2", "10.128.10.90", |
| 48 | "10.128.10.11", "10.128.10.12", "10.128.10.13") |
| 49 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 50 | main.step("Applying cell variable to environment") |
andrewonlab | 084307e | 2014-10-09 14:06:09 -0400 | [diff] [blame] | 51 | cell_result = main.ONOSbench.set_cell(cell_name) |
andrewonlab | c03bf6c | 2014-10-09 14:56:18 -0400 | [diff] [blame] | 52 | verify_result = main.ONOSbench.verify_cell() |
andrewonlab | 2fe32ad | 2014-10-09 16:36:40 -0400 | [diff] [blame] | 53 | |
| 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) |
| 109 | |
andrewonlab | f103e9f | 2014-10-10 00:59:07 -0400 | [diff] [blame] | 110 | def CASE4(self, main): |
| 111 | main.step("Assigning switches to controllers") |
| 112 | for i in range(1,29): |
| 113 | main.Mininet1.assign_sw_controller(sw=str(i), |
| 114 | ip1=ONOS1_ip, port1=ONOS1_port) |
| 115 | switch_mastership = main.TRUE |
| 116 | for i in range (1,29): |
| 117 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 118 | print("Response is " + str(response)) |
| 119 | if re.search("tcp:"+ONOS1_ip,response): |
| 120 | switch_mastership = switch_mastership and main.TRUE |
| 121 | else: |
| 122 | switch_mastership = main.FALSE |
| 123 | |
| 124 | #REACTIVE FWD test |
| 125 | main.step("Pingall") |
| 126 | ping_result = main.FALSE |
| 127 | while ping_result == main.FALSE: |
| 128 | time1 = time.time() |
| 129 | ping_result = main.Mininet1.pingall() |
| 130 | time2 = time.time() |
| 131 | print "Time for pingall: %2f seconds" % (time2 - time1) |
| 132 | |
| 133 | case4_result = switch_mastership and ping_result |
| 134 | utilities.assert_equals(expect=main.TRUE, actual=case4_result, |
| 135 | onpass="Test successful", |
| 136 | onfail="Test NOT successful") |
| 137 | |