blob: 2a1ecb47082a989238548ea8be8c97224fe9ed46 [file] [log] [blame]
Devin Lim3ebd5e72017-11-14 10:38:00 -08001"""
2Copyright 2017 Open Networking Foundation ( ONF )
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 ( at your option ) any later version.
12
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
21
22
23class FUNCformCluster:
24
25 def __init__( self ):
26 self.default = ''
27
28 def CASE0( self, main ):
29 import imp
30 import re
31
32 try:
33 from tests.dependencies.ONOSSetup import ONOSSetup
34 main.testSetUp = ONOSSetup()
35 except ImportError:
36 main.log.error( "ONOSSetup not found. exiting the test" )
37 main.cleanAndExit()
38 main.testSetUp.envSetupDescription()
39 stepResult = main.TRUE
40 try:
41 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
42 main.additionalApp = main.params[ 'ENV' ][ 'additionalApp' ]
43 main.cellBasicName = main.params[ 'ENV' ][ 'cellBasicName' ]
44 main.mnTopo = main.params[ 'MININET' ][ 'topo' ]
45 main.startSleep = int( main.params[ 'SLEEP' ][ 'afterONOSStart' ] )
46 dependencyPath = main.testOnDirectory + \
47 main.params[ 'DEPENDENCY' ][ 'path' ]
48 dependencyFile = main.params[ 'DEPENDENCY' ][ 'file' ]
49 main.numNodes = int( main.params[ 'TEST' ][ 'numNodes' ] )
50 main.funcs = imp.load_source( dependencyFile,
51 dependencyPath +
52 dependencyFile +
53 ".py" )
54 main.pingallRetry = int( main.params[ 'RETRY' ][ 'pingall' ] )
55 main.topoCheckRetry = int( main.params[ 'RETRY' ][ 'topoCheck' ] )
56 main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
57
58 except Exception as e:
59 main.testSetUp.envSetupException( e )
60 if len( main.Cluster.runningNodes ) != main.numNodes:
61 main.log.error( "The number of the nodes needs to be " + str( main.numNodes ) +
62 "\nExiting Test..." )
63 main.cleanAndExit()
64 main.testSetUp.evnSetupConclusion( stepResult )
65
66 def CASE1( self, main ):
67 """
68 - Create cells with single node
69 - apply each cell to each cluster
70 - install ONOS
71 - ssh-secure
72 - start the ONOS
73 - activate org.onosproject.fwd to cluster 1 only.
74 """
75 main.case( "Starting ONOS with indepenent configuration" )
76 main.caseExplanation = "Starting ONOS with one node itself."
77 main.testSetUp.killingAllOnos( main.Cluster, True, False )
78 threads = []
79 i = 0
80 for cluster in main.Cluster.runningNodes:
81 i += 1
82 t = main.Thread( target=cluster.Bench.createCellFile,
83 name="create-cell",
84 args=[ main.ONOSbench.ip_address,
85 main.cellBasicName + str( i ),
86 main.Mininet1.ip_address,
87 main.apps,
88 cluster.ip_address,
Jon Hall3e6edb32018-08-21 16:20:30 -070089 cluster.ip_address,
Devin Lim3ebd5e72017-11-14 10:38:00 -080090 main.ONOScell.karafUser,
91 True ] )
92 threads.append( t )
93 t.start()
94 cellResult = main.TRUE
95 for t in threads:
96 t.join()
97 cellResult = cellResult and t.result
98
99 threads = []
100 i = 0
101 for cluster in main.Cluster.runningNodes:
102 i += 1
103 t = main.Thread( target=cluster.Bench.setCell,
104 name="set-cell",
105 args=[ main.cellBasicName + str( i ) ] )
106 threads.append( t )
107 t.start()
108 for t in threads:
109 t.join()
110 cellResult = cellResult and t.result
111
112 threads = []
113 i = 0
114 for cluster in main.Cluster.runningNodes:
115 i += 1
116 t = main.Thread( target=cluster.Bench.verifyCell,
117 name="verify-cell" )
118 threads.append( t )
119 t.start()
120 for t in threads:
121 t.join()
122 cellResult = cellResult and t.result
123
124 uninstallResult = main.testSetUp.uninstallOnos( main.Cluster, True )
125 buildResult = main.testSetUp.buildOnos( main.Cluster )
126 installResult = main.testSetUp.installOnos( main.Cluster, True, True )
127 secureSshResult = main.testSetUp.setupSsh( main.Cluster )
128 onosServiceResult = main.testSetUp.checkOnosService( main.Cluster )
129 onosCliResult = main.testSetUp.startOnosClis( main.Cluster )
130 activateResult = main.Cluster.active( 0 ).CLI.activateApp( main.additionalApp )
131
132 result = cellResult and uninstallResult and buildResult and installResult and \
133 secureSshResult and onosServiceResult and onosCliResult and activateResult
134 utilities.assert_equals( expect=main.TRUE,
135 actual=result,
136 onpass="Successfully started the ONOS",
137 onfail="Failed to start the ONOS" )
138
139 def CASE2( self, main ):
140 """
141 - Execute onos-form-cluster to all the nodes.
142 - start the ONOS.
143 - activate org.onosproject.fwd to cluster 1.
144 """
145 main.case( "Starting ONOS with form cluster." )
146 main.caseExplanation = "This will connect all the clusters of the ONOS."
147 main.step( "Executing onos-form-cluster" )
148 formClusterResult = main.ONOSbench.formCluster( main.Cluster.getIps( True, True ) )
149 utilities.assert_equals( expect=main.TRUE,
150 actual=result,
151 onpass="Successfully formed clusters to ONOS",
152 onfail="Failed to form clusters to ONOS" )
153 onosServiceResult = main.testSetUp.checkOnosService( main.Cluster )
154 onosCliResult = main.testSetUp.startOnosClis( main.Cluster )
155 activateResult = main.Cluster.active( 0 ).CLI.activateApp( main.additionalApp )
156 result = formClusterResult and onosServiceResult and onosCliResult and activateResult
157 utilities.assert_equals( expect=main.TRUE,
158 actual=result,
159 onpass="Successfully formed clusters to ONOS and started",
160 onfail="Failed to form clusters to ONOS and started" )
161
162 def CASE3( self, main ):
163 """
164 Checking the configuration of the ONOS with single-node ONOS.
165 It will check :
166 - the number of the node : They should only have 1 node.
167 - App status : Only the first node should have additional app installed.
168 """
169 import time
170 main.case( "Checking the configuration of the ONOS" )
171 main.caseExplanation = "Checking the number of the nodes and apps"
172 main.step( "Checking the number of the nodes" )
173 main.log.info( "Sleep for " + str( main.startSleep ) + " to give enough time to ONOS")
174 time.sleep( main.startSleep )
175 result = main.funcs.checkingNumNodes( main, 1 )
176 utilities.assert_equals( expect=main.TRUE,
177 actual=result,
178 onpass="Successfully checking the nodes numbers of the ONOS",
179 onfail="Failed to checking the nodes numbers of the ONOS" )
180 main.step( "Checking the app status. Only the first node should have " +
181 main.additionalApp + " installed." )
182 i = 0
183 appResult = main.TRUE
184 for cluster in main.Cluster.active():
185 appResult = appResult and main.funcs.checkingApp( main, main.additionalApp, cluster, True if i == 0 else False )
186 i += 1
187 main.Cluster.active( 0 ).CLI.deactivateApp( main.additionalApp )
188 utilities.assert_equals( expect=main.TRUE,
189 actual=appResult,
190 onpass="Successfully checking the app status of the ONOS",
191 onfail="Failed to checking the app status of the ONOS" )
192
193 def CASE4( self, main ):
194 """
195 Checking the configuration of the ONOS with form-cluster.
196 It will check :
197 - the number of the node : They should only have 7 nodes.
198 - state of the node.
199 - App status : All the nodes should have additional app.
200 """
201 import time
202 main.case( "Checking the configuration of the ONOS after form-cluster" )
203 main.caseExplanation = "Checking the number of the nodes and apps"
204 main.step( "Checking the number of the nodes" )
205 main.log.info( "Sleep for " + str( main.startSleep ) + " to give enough time to ONOS")
206 time.sleep( main.startSleep )
207 result = main.funcs.checkingNumNodes( main, main.numNodes )
208 utilities.assert_equals( expect=main.TRUE,
209 actual=result,
210 onpass="Successfully checking the nodes numbers of the ONOS",
211 onfail="Failed to checking the nodes numbers of the ONOS" )
212 main.step( "Checking the status of the nodes" )
213 nodeStatusResult = main.TRUE if main.Cluster.nodesCheck() else main.FALSE
214 utilities.assert_equals( expect=main.TRUE,
215 actual=nodeStatusResult,
216 onpass="The status of the nodes were in READY as expected",
217 onfail="The status of the nodes were NOT in READY as expected" )
218 main.step( "Checking the app status. All nodes should have " +
219 main.additionalApp + " installed." )
220 appResult = main.TRUE
221 for cluster in main.Cluster.active():
222 appResult = appResult and main.funcs.checkingApp( main, main.additionalApp, cluster, True )
223 utilities.assert_equals( expect=main.TRUE,
224 actual=appResult,
225 onpass="Successfully checking the app status of the ONOS",
226 onfail="Failed to checking the app status of the ONOS" )
227
228 def CASE5( self, main ):
229 """
230 Run simple mininet to check connectivity of ONOS clusters.
231 - It will do ping all
232 - It will compare topos between mininet and ONOS.
233 """
234 try:
235 from tests.dependencies.topology import Topology
236 except ImportError:
237 main.log.error( "Topology not found exiting the test" )
238 main.cleanAndExit()
239 try:
240 main.Topology
241 except ( NameError, AttributeError ):
242 main.Topology = Topology()
243 main.case( "Starting 2x2 Tree Mininet and compare the Topology" )
244 main.caseExplanation = "Starting 2x2 Mininet and assign ONOS controllers to switches."
245 main.step( "Starting Mininet" )
246 for ctrl in main.Cluster.runningNodes:
247 main.mnTopo += " --controller remote,ip=" + ctrl.ipAddress
248 startMnResult = main.Mininet1.startNet( mnCmd=main.mnTopo )
249 utilities.assert_equals( expect=main.TRUE,
250 actual=startMnResult,
251 onpass="Successfully started Mininet",
252 onfail="Failed to start Mininet" )
253 main.step( "Pingall hosts to confirm ONOS discovery" )
254 pingResult = utilities.retry( f=main.Mininet1.pingall,
255 retValue=main.FALSE,
256 attempts=main.pingallRetry,
257 sleep=main.pingallSleep )
258 utilities.assert_equals( expect=main.TRUE,
259 actual=pingResult,
260 onpass="Successfully discovered hosts",
261 onfail="Failed to discover hosts" )
262 main.Topology.compareTopos( main.Mininet1, main.topoCheckRetry )