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 |
| 8 | |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 9 | class ONOSNextTest: |
| 10 | def __init__(self): |
| 11 | self.default = '' |
| 12 | |
| 13 | def CASE1(self, main): |
| 14 | ''' |
| 15 | Startup sequence: |
| 16 | git pull |
| 17 | mvn clean install |
| 18 | onos-package |
| 19 | cell <name> |
| 20 | onos-verify-cell |
| 21 | onos-install -f |
| 22 | onos-wait-for-start |
| 23 | ''' |
andrew@onlab.us | 59e8f69 | 2014-10-09 21:41:48 -0400 | [diff] [blame^] | 24 | import re |
| 25 | import time |
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") |
| 32 | |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 33 | main.step("Using mvn clean & install") |
| 34 | #clean_install_result = main.ONOSbench.clean_install() |
| 35 | clean_install_result = main.TRUE |
| 36 | |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 37 | main.step("Creating ONOS package") |
andrewonlab | 7735d85 | 2014-10-09 13:02:47 -0400 | [diff] [blame] | 38 | package_result = main.ONOSbench.onos_package() |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 39 | |
| 40 | main.step("Applying cell variable to environment") |
andrewonlab | 084307e | 2014-10-09 14:06:09 -0400 | [diff] [blame] | 41 | cell_result = main.ONOSbench.set_cell(cell_name) |
andrewonlab | c03bf6c | 2014-10-09 14:56:18 -0400 | [diff] [blame] | 42 | verify_result = main.ONOSbench.verify_cell() |
andrewonlab | 2fe32ad | 2014-10-09 16:36:40 -0400 | [diff] [blame] | 43 | |
| 44 | main.step("Installing ONOS package") |
Jon Hall | 7993bfc | 2014-10-09 16:30:14 -0400 | [diff] [blame] | 45 | onos_install_result = main.ONOSbench.onos_install() |
| 46 | onos1_isup = main.ONOSbench.isup() |
andrewonlab | 8d0d7d7 | 2014-10-09 16:33:15 -0400 | [diff] [blame] | 47 | |
| 48 | main.step("Starting ONOS service") |
| 49 | start_result = main.ONOSbench.onos_start(ONOS1_ip) |
| 50 | |
andrew@onlab.us | 59e8f69 | 2014-10-09 21:41:48 -0400 | [diff] [blame^] | 51 | main.step("Assigning switches to controllers") |
| 52 | for i in range(1,29): |
| 53 | main.Mininet1.assign_sw_controller(sw=str(i), |
| 54 | ip1=ONOS1_ip, port1=ONOS1_port) |
| 55 | switch_mastership = main.TRUE |
| 56 | for i in range (1,29): |
| 57 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
| 58 | print("Response is " + str(response)) |
| 59 | if re.search("tcp:"+ONOS1_ip,response): |
| 60 | switch_mastership = switch_mastership and main.TRUE |
| 61 | else: |
| 62 | switch_mastership = main.FALSE |
| 63 | |
| 64 | #REACTIVE FWD test |
| 65 | main.step("Pingall") |
| 66 | ping_result = main.FALSE |
| 67 | while ping_result == main.FALSE: |
| 68 | time1 = time.time() |
| 69 | ping_result = main.Mininet1.pingall() |
| 70 | time2 = time.time() |
| 71 | print "Time for pingall: %2f seconds" % (time2 - time1) |
| 72 | |
| 73 | |
Jon Hall | 7993bfc | 2014-10-09 16:30:14 -0400 | [diff] [blame] | 74 | case1_result = (clean_install_result and package_result and\ |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 75 | cell_result and verify_result and onos_install_result and\ |
andrew@onlab.us | 59e8f69 | 2014-10-09 21:41:48 -0400 | [diff] [blame^] | 76 | onos1_isup and start_result and ping_result and\ |
| 77 | switch_mastership) |
andrewonlab | 0748d2a | 2014-10-09 13:24:17 -0400 | [diff] [blame] | 78 | utilities.assert_equals(expect=main.TRUE, actual=case1_result, |
| 79 | onpass="Test startup successful", |
| 80 | onfail="Test startup NOT successful") |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 81 | |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 82 | def CASE2(self, main): |
| 83 | ''' |
| 84 | Cleanup sequence: |
| 85 | onos-service <node_ip> stop |
| 86 | onos-uninstall |
| 87 | |
| 88 | TODO: Define rest of cleanup |
| 89 | |
| 90 | ''' |
| 91 | |
| 92 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 93 | |
| 94 | main.case("Cleaning up test environment") |
| 95 | |
andrewonlab | 057c06a | 2014-10-09 17:19:21 -0400 | [diff] [blame] | 96 | main.step("Testing ONOS kill function") |
| 97 | kill_result = main.ONOSbench.onos_kill(ONOS1_ip) |
| 98 | |
andrewonlab | 2b30bd3 | 2014-10-09 16:48:55 -0400 | [diff] [blame] | 99 | main.step("Stopping ONOS service") |
| 100 | stop_result = main.ONOSbench.onos_stop(ONOS1_ip) |
| 101 | |
| 102 | main.step("Uninstalling ONOS service") |
andrewonlab | 057c06a | 2014-10-09 17:19:21 -0400 | [diff] [blame] | 103 | uninstall_result = main.ONOSbench.onos_uninstall() |
andrewonlab | 4a5c447 | 2014-10-09 12:11:41 -0400 | [diff] [blame] | 104 | |