blob: 55b6e4194ff7f9347423f9240b75b447c6e71d7c [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,
89 main.ONOScell.karafUser,
90 True ] )
91 threads.append( t )
92 t.start()
93 cellResult = main.TRUE
94 for t in threads:
95 t.join()
96 cellResult = cellResult and t.result
97
98 threads = []
99 i = 0
100 for cluster in main.Cluster.runningNodes:
101 i += 1
102 t = main.Thread( target=cluster.Bench.setCell,
103 name="set-cell",
104 args=[ main.cellBasicName + str( i ) ] )
105 threads.append( t )
106 t.start()
107 for t in threads:
108 t.join()
109 cellResult = cellResult and t.result
110
111 threads = []
112 i = 0
113 for cluster in main.Cluster.runningNodes:
114 i += 1
115 t = main.Thread( target=cluster.Bench.verifyCell,
116 name="verify-cell" )
117 threads.append( t )
118 t.start()
119 for t in threads:
120 t.join()
121 cellResult = cellResult and t.result
122
123 uninstallResult = main.testSetUp.uninstallOnos( main.Cluster, True )
124 buildResult = main.testSetUp.buildOnos( main.Cluster )
125 installResult = main.testSetUp.installOnos( main.Cluster, True, True )
126 secureSshResult = main.testSetUp.setupSsh( main.Cluster )
127 onosServiceResult = main.testSetUp.checkOnosService( main.Cluster )
128 onosCliResult = main.testSetUp.startOnosClis( main.Cluster )
129 activateResult = main.Cluster.active( 0 ).CLI.activateApp( main.additionalApp )
130
131 result = cellResult and uninstallResult and buildResult and installResult and \
132 secureSshResult and onosServiceResult and onosCliResult and activateResult
133 utilities.assert_equals( expect=main.TRUE,
134 actual=result,
135 onpass="Successfully started the ONOS",
136 onfail="Failed to start the ONOS" )
137
138 def CASE2( self, main ):
139 """
140 - Execute onos-form-cluster to all the nodes.
141 - start the ONOS.
142 - activate org.onosproject.fwd to cluster 1.
143 """
144 main.case( "Starting ONOS with form cluster." )
145 main.caseExplanation = "This will connect all the clusters of the ONOS."
146 main.step( "Executing onos-form-cluster" )
147 formClusterResult = main.ONOSbench.formCluster( main.Cluster.getIps( True, True ) )
148 utilities.assert_equals( expect=main.TRUE,
149 actual=result,
150 onpass="Successfully formed clusters to ONOS",
151 onfail="Failed to form clusters to ONOS" )
152 onosServiceResult = main.testSetUp.checkOnosService( main.Cluster )
153 onosCliResult = main.testSetUp.startOnosClis( main.Cluster )
154 activateResult = main.Cluster.active( 0 ).CLI.activateApp( main.additionalApp )
155 result = formClusterResult and onosServiceResult and onosCliResult and activateResult
156 utilities.assert_equals( expect=main.TRUE,
157 actual=result,
158 onpass="Successfully formed clusters to ONOS and started",
159 onfail="Failed to form clusters to ONOS and started" )
160
161 def CASE3( self, main ):
162 """
163 Checking the configuration of the ONOS with single-node ONOS.
164 It will check :
165 - the number of the node : They should only have 1 node.
166 - App status : Only the first node should have additional app installed.
167 """
168 import time
169 main.case( "Checking the configuration of the ONOS" )
170 main.caseExplanation = "Checking the number of the nodes and apps"
171 main.step( "Checking the number of the nodes" )
172 main.log.info( "Sleep for " + str( main.startSleep ) + " to give enough time to ONOS")
173 time.sleep( main.startSleep )
174 result = main.funcs.checkingNumNodes( main, 1 )
175 utilities.assert_equals( expect=main.TRUE,
176 actual=result,
177 onpass="Successfully checking the nodes numbers of the ONOS",
178 onfail="Failed to checking the nodes numbers of the ONOS" )
179 main.step( "Checking the app status. Only the first node should have " +
180 main.additionalApp + " installed." )
181 i = 0
182 appResult = main.TRUE
183 for cluster in main.Cluster.active():
184 appResult = appResult and main.funcs.checkingApp( main, main.additionalApp, cluster, True if i == 0 else False )
185 i += 1
186 main.Cluster.active( 0 ).CLI.deactivateApp( main.additionalApp )
187 utilities.assert_equals( expect=main.TRUE,
188 actual=appResult,
189 onpass="Successfully checking the app status of the ONOS",
190 onfail="Failed to checking the app status of the ONOS" )
191
192 def CASE4( self, main ):
193 """
194 Checking the configuration of the ONOS with form-cluster.
195 It will check :
196 - the number of the node : They should only have 7 nodes.
197 - state of the node.
198 - App status : All the nodes should have additional app.
199 """
200 import time
201 main.case( "Checking the configuration of the ONOS after form-cluster" )
202 main.caseExplanation = "Checking the number of the nodes and apps"
203 main.step( "Checking the number of the nodes" )
204 main.log.info( "Sleep for " + str( main.startSleep ) + " to give enough time to ONOS")
205 time.sleep( main.startSleep )
206 result = main.funcs.checkingNumNodes( main, main.numNodes )
207 utilities.assert_equals( expect=main.TRUE,
208 actual=result,
209 onpass="Successfully checking the nodes numbers of the ONOS",
210 onfail="Failed to checking the nodes numbers of the ONOS" )
211 main.step( "Checking the status of the nodes" )
212 nodeStatusResult = main.TRUE if main.Cluster.nodesCheck() else main.FALSE
213 utilities.assert_equals( expect=main.TRUE,
214 actual=nodeStatusResult,
215 onpass="The status of the nodes were in READY as expected",
216 onfail="The status of the nodes were NOT in READY as expected" )
217 main.step( "Checking the app status. All nodes should have " +
218 main.additionalApp + " installed." )
219 appResult = main.TRUE
220 for cluster in main.Cluster.active():
221 appResult = appResult and main.funcs.checkingApp( main, main.additionalApp, cluster, True )
222 utilities.assert_equals( expect=main.TRUE,
223 actual=appResult,
224 onpass="Successfully checking the app status of the ONOS",
225 onfail="Failed to checking the app status of the ONOS" )
226
227 def CASE5( self, main ):
228 """
229 Run simple mininet to check connectivity of ONOS clusters.
230 - It will do ping all
231 - It will compare topos between mininet and ONOS.
232 """
233 try:
234 from tests.dependencies.topology import Topology
235 except ImportError:
236 main.log.error( "Topology not found exiting the test" )
237 main.cleanAndExit()
238 try:
239 main.Topology
240 except ( NameError, AttributeError ):
241 main.Topology = Topology()
242 main.case( "Starting 2x2 Tree Mininet and compare the Topology" )
243 main.caseExplanation = "Starting 2x2 Mininet and assign ONOS controllers to switches."
244 main.step( "Starting Mininet" )
245 for ctrl in main.Cluster.runningNodes:
246 main.mnTopo += " --controller remote,ip=" + ctrl.ipAddress
247 startMnResult = main.Mininet1.startNet( mnCmd=main.mnTopo )
248 utilities.assert_equals( expect=main.TRUE,
249 actual=startMnResult,
250 onpass="Successfully started Mininet",
251 onfail="Failed to start Mininet" )
252 main.step( "Pingall hosts to confirm ONOS discovery" )
253 pingResult = utilities.retry( f=main.Mininet1.pingall,
254 retValue=main.FALSE,
255 attempts=main.pingallRetry,
256 sleep=main.pingallSleep )
257 utilities.assert_equals( expect=main.TRUE,
258 actual=pingResult,
259 onpass="Successfully discovered hosts",
260 onfail="Failed to discover hosts" )
261 main.Topology.compareTopos( main.Mininet1, main.topoCheckRetry )