blob: c812295be46caf0f4e47be51dc8136e916bc522e [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
8
andrewonlab4a5c4472014-10-09 12:11:41 -04009class 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.us59e8f692014-10-09 21:41:48 -040024 import re
25 import time
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")
34 main.ONOSbench.git_checkout("master")
35 git_pull_result = main.ONOSbench.git_pull()
36
andrewonlab8d0d7d72014-10-09 16:33:15 -040037
andrewonlab2b30bd32014-10-09 16:48:55 -040038 main.step("Using mvn clean & install")
Jon Hall3be576e2014-10-09 22:23:03 -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
45 main.step("Applying cell variable to environment")
andrewonlab084307e2014-10-09 14:06:09 -040046 cell_result = main.ONOSbench.set_cell(cell_name)
andrewonlabc03bf6c2014-10-09 14:56:18 -040047 verify_result = main.ONOSbench.verify_cell()
andrewonlab2fe32ad2014-10-09 16:36:40 -040048
49 main.step("Installing ONOS package")
Jon Hall7993bfc2014-10-09 16:30:14 -040050 onos_install_result = main.ONOSbench.onos_install()
51 onos1_isup = main.ONOSbench.isup()
andrewonlab8d0d7d72014-10-09 16:33:15 -040052
53 main.step("Starting ONOS service")
54 start_result = main.ONOSbench.onos_start(ONOS1_ip)
55
andrew@onlab.us59e8f692014-10-09 21:41:48 -040056 main.step("Assigning switches to controllers")
57 for i in range(1,29):
58 main.Mininet1.assign_sw_controller(sw=str(i),
59 ip1=ONOS1_ip, port1=ONOS1_port)
60 switch_mastership = main.TRUE
61 for i in range (1,29):
62 response = main.Mininet1.get_sw_controller("s"+str(i))
63 print("Response is " + str(response))
64 if re.search("tcp:"+ONOS1_ip,response):
65 switch_mastership = switch_mastership and main.TRUE
66 else:
67 switch_mastership = main.FALSE
68
69 #REACTIVE FWD test
70 main.step("Pingall")
71 ping_result = main.FALSE
72 while ping_result == main.FALSE:
73 time1 = time.time()
74 ping_result = main.Mininet1.pingall()
75 time2 = time.time()
76 print "Time for pingall: %2f seconds" % (time2 - time1)
77
78
Jon Hall7993bfc2014-10-09 16:30:14 -040079 case1_result = (clean_install_result and package_result and\
andrewonlab2b30bd32014-10-09 16:48:55 -040080 cell_result and verify_result and onos_install_result and\
andrew@onlab.us59e8f692014-10-09 21:41:48 -040081 onos1_isup and start_result and ping_result and\
82 switch_mastership)
andrewonlab0748d2a2014-10-09 13:24:17 -040083 utilities.assert_equals(expect=main.TRUE, actual=case1_result,
84 onpass="Test startup successful",
85 onfail="Test startup NOT successful")
andrewonlab4a5c4472014-10-09 12:11:41 -040086
andrewonlab05e362f2014-10-10 00:40:57 -040087 def CASE11(self, main):
andrewonlab2b30bd32014-10-09 16:48:55 -040088 '''
89 Cleanup sequence:
90 onos-service <node_ip> stop
91 onos-uninstall
92
93 TODO: Define rest of cleanup
94
95 '''
96
97 ONOS1_ip = main.params['CTRL']['ip1']
98
99 main.case("Cleaning up test environment")
100
andrewonlab057c06a2014-10-09 17:19:21 -0400101 main.step("Testing ONOS kill function")
102 kill_result = main.ONOSbench.onos_kill(ONOS1_ip)
103
andrewonlab2b30bd32014-10-09 16:48:55 -0400104 main.step("Stopping ONOS service")
105 stop_result = main.ONOSbench.onos_stop(ONOS1_ip)
106
107 main.step("Uninstalling ONOS service")
andrewonlab057c06a2014-10-09 17:19:21 -0400108 uninstall_result = main.ONOSbench.onos_uninstall()
andrewonlab4a5c4472014-10-09 12:11:41 -0400109
andrewonlab05e362f2014-10-10 00:40:57 -0400110 def CASE3(self, main):
111 '''
112 Test 'onos' command and its functionality in driver
113 '''
114
115 ONOS1_ip = main.params['CTRL']['ip1']
116 cmdstr = "system:name"
117
118 main.case("Testing 'onos' command")
119
120 main.step("Sending command 'onos -w <onos-ip> system:name")
121 cmd_result = main.ONOSbench.onos_cli(ONOS1_ip, cmdstr)
122 print cmd_result