blob: dd91efb076f7dbe22de221366d6e1dfef63919fb [file] [log] [blame]
andrewonlab4a5c4472014-10-09 12:11:41 -04001
2#Testing the basic functionality of ONOS Next
3#For sanity and driver functionality excercises only.
4
andrewonlab7735d852014-10-09 13:02:47 -04005import time
6import sys
7import os
andrewonlab2d355162014-10-10 00:43:59 -04008import re
9import time
andrewonlab7735d852014-10-09 13:02:47 -040010
andrewonlab4a5c4472014-10-09 12:11:41 -040011class 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 '''
andrewonlab7735d852014-10-09 13:02:47 -040026
andrewonlab084307e2014-10-09 14:06:09 -040027 cell_name = main.params['ENV']['cellName']
28 ONOS1_ip = main.params['CTRL']['ip1']
andrew@onlab.us59e8f692014-10-09 21:41:48 -040029 ONOS1_port = main.params['CTRL']['port1']
Jon Hallea7818b2014-10-09 14:30:59 -040030
andrewonlab8d0d7d72014-10-09 16:33:15 -040031 main.case("Setting up test environment")
Jon Hall3be576e2014-10-09 22:23:03 -040032
33 main.step("Git checkout and pull master")
andrewonlab94282092014-10-10 13:00:11 -040034 #main.ONOSbench.git_checkout("master")
35 #git_pull_result = main.ONOSbench.git_pull()
Jon Hall3be576e2014-10-09 22:23:03 -040036
andrewonlab8d0d7d72014-10-09 16:33:15 -040037
andrewonlab2b30bd32014-10-09 16:48:55 -040038 main.step("Using mvn clean & install")
andrewonlabf103e9f2014-10-10 00:59:07 -040039 #clean_install_result = main.ONOSbench.clean_install()
40 clean_install_result = main.TRUE
andrewonlab2b30bd32014-10-09 16:48:55 -040041
andrewonlab8d0d7d72014-10-09 16:33:15 -040042 main.step("Creating ONOS package")
andrewonlab7735d852014-10-09 13:02:47 -040043 package_result = main.ONOSbench.onos_package()
andrewonlab8d0d7d72014-10-09 16:33:15 -040044
andrewonlab94282092014-10-10 13:00:11 -040045 main.step("Creating cell file")
andrewonlab2c010fb2014-10-10 18:08:59 -040046 #params: (bench ip, cell name, mininet ip, *onos ips)
andrewonlab94282092014-10-10 13:00:11 -040047 cell_file_result = main.ONOSbench.create_cell_file(
48 "10.128.20.10", "temp_cell_2", "10.128.10.90",
49 "10.128.10.11", "10.128.10.12", "10.128.10.13")
50
andrewonlab8d0d7d72014-10-09 16:33:15 -040051 main.step("Applying cell variable to environment")
andrewonlab084307e2014-10-09 14:06:09 -040052 cell_result = main.ONOSbench.set_cell(cell_name)
andrewonlabc03bf6c2014-10-09 14:56:18 -040053 verify_result = main.ONOSbench.verify_cell()
andrewonlab2fe32ad2014-10-09 16:36:40 -040054
55 main.step("Installing ONOS package")
Jon Hall7993bfc2014-10-09 16:30:14 -040056 onos_install_result = main.ONOSbench.onos_install()
57 onos1_isup = main.ONOSbench.isup()
andrewonlab8d0d7d72014-10-09 16:33:15 -040058
59 main.step("Starting ONOS service")
60 start_result = main.ONOSbench.onos_start(ONOS1_ip)
61
Jon Hall7993bfc2014-10-09 16:30:14 -040062 case1_result = (clean_install_result and package_result and\
andrewonlab2b30bd32014-10-09 16:48:55 -040063 cell_result and verify_result and onos_install_result and\
andrewonlabf103e9f2014-10-10 00:59:07 -040064 onos1_isup and start_result )
andrewonlab0748d2a2014-10-09 13:24:17 -040065 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
66 onpass="Test startup successful",
67 onfail="Test startup NOT successful")
andrewonlab4a5c4472014-10-09 12:11:41 -040068
andrewonlab05e362f2014-10-10 00:40:57 -040069 def CASE11(self, main):
andrewonlab2b30bd32014-10-09 16:48:55 -040070 '''
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
andrewonlab057c06a2014-10-09 17:19:21 -040083 main.step("Testing ONOS kill function")
84 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
85
andrewonlab2b30bd32014-10-09 16:48:55 -040086 main.step("Stopping ONOS service")
87 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
88
89 main.step("Uninstalling ONOS service")
andrewonlab057c06a2014-10-09 17:19:21 -040090 uninstall_result = main.ONOSbench.onos_uninstall()
andrewonlab4a5c4472014-10-09 12:11:41 -040091
andrewonlab05e362f2014-10-10 00:40:57 -040092 def CASE3(self, main):
93 '''
94 Test 'onos' command and its functionality in driver
95 '''
96
97 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlab05e362f2014-10-10 00:40:57 -040098
99 main.case("Testing 'onos' command")
100
andrewonlabf103e9f2014-10-10 00:59:07 -0400101 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)
110
andrewonlab2c010fb2014-10-10 18:08:59 -0400111 main.step("Sending command 'onos -w <onos-ip> bundle:list'")
112 cmdstr3 = "bundle:list"
113 cmd_result3 = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr3)
114 main.log.info("onos command returned: "+cmd_result3)
115
andrewonlabf103e9f2014-10-10 00:59:07 -0400116 def CASE4(self, main):
Jon Hall31735332014-10-10 15:27:43 -0400117 import re
118 import time
119 main.case("Pingall Test")
andrewonlabf103e9f2014-10-10 00:59:07 -0400120 main.step("Assigning switches to controllers")
121 for i in range(1,29):
122 main.Mininet1.assign_sw_controller(sw=str(i),
123 ip1=ONOS1_ip, port1=ONOS1_port)
124 switch_mastership = main.TRUE
125 for i in range (1,29):
126 response = main.Mininet1.get_sw_controller("s"+str(i))
127 print("Response is " + str(response))
128 if re.search("tcp:"+ONOS1_ip,response):
129 switch_mastership = switch_mastership and main.TRUE
130 else:
131 switch_mastership = main.FALSE
132
133 #REACTIVE FWD test
134 main.step("Pingall")
135 ping_result = main.FALSE
136 while ping_result == main.FALSE:
137 time1 = time.time()
138 ping_result = main.Mininet1.pingall()
139 time2 = time.time()
140 print "Time for pingall: %2f seconds" % (time2 - time1)
141
142 case4_result = switch_mastership and ping_result
143 utilities.assert_equals(expect=main.TRUE, actual=case4_result,
Jon Hall31735332014-10-10 15:27:43 -0400144 onpass="Pingall Test successful",
145 onfail="Pingall Test NOT successful")
andrewonlabf103e9f2014-10-10 00:59:07 -0400146
andrewonlabc7345f22014-10-13 14:12:59 -0400147 def CASE5(self, main):
148 '''
149 Test the ONOS-cli functionality
150 '''
151 cell_name = main.params['ENV']['cellName']
152 ONOS1_ip = main.params['CTRL']['ip1']
153
154 main.case("Testing the ONOS-cli")
155
156 main.step("Set cell for ONOS-cli environment")
157 main.ONOScli.set_cell(cell_name)
158
159 main.step("Start ONOS-cli")
160 main.ONOScli.start_onos_cli()
161
162 main.step("issue command: onos:topology")
163 main.ONOScli.onos_topology()
164