blob: 1937b8ae66df846993081b04d0c69b283c40b0d6 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
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"""
Jeremyfc567ca2016-02-16 15:08:25 -080021# Testing the NETCONF protocol within ONOS
22
Jon Hall0c3f46f2017-05-24 16:34:46 -070023
Jeremyfc567ca2016-02-16 15:08:25 -080024class FUNCnetconf:
25
26 def __init__( self ):
27 self.default = ''
28
29 def CASE1( self, main ):
30 import time
31 import imp
32 import re
Jeremyfc567ca2016-02-16 15:08:25 -080033 """
34 - Construct tests variables
35 - GIT ( optional )
36 - Checkout ONOS master branch
37 - Pull latest ONOS code
38 - Building ONOS ( optional )
39 - Install ONOS package
40 - Build ONOS package
41 """
Devin Lim58046fa2017-07-05 16:55:00 -070042 try:
43 from tests.dependencies.ONOSSetup import ONOSSetup
44 main.testSetUp = ONOSSetup()
45 except ImportError:
46 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070047 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070048 main.testSetUp.envSetupDescription()
Jeremyfc567ca2016-02-16 15:08:25 -080049 stepResult = main.FALSE
50
51 # Test variables
52 try:
Jeremyfc567ca2016-02-16 15:08:25 -080053 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jeremyfc567ca2016-02-16 15:08:25 -080054 main.dependencyPath = main.testOnDirectory + \
55 main.params[ 'DEPENDENCY' ][ 'path' ]
56 # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
Jeremy Ronquilloed3550d2018-04-11 12:23:59 -070057 main.iface = main.params[ 'DEPENDENCY' ][ 'iface' ]
Jeremyfc567ca2016-02-16 15:08:25 -080058 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Jeremyfc567ca2016-02-16 15:08:25 -080059 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
60 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
61 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
62 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
63 main.switchSleep = int( main.params[ 'SLEEP' ][ 'upSwitch' ] )
64 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
65 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
66
67 # Config file parameters
68 main.configDevicePort = main.params[ 'CONFIGURE' ][ 'cfgDevicePort' ]
69 main.configDriver = main.params[ 'CONFIGURE' ][ 'cfgDriver' ]
70 main.configApps = main.params[ 'CONFIGURE' ][ 'cfgApps' ]
71 main.configName = main.params[ 'CONFIGURE' ][ 'cfgName' ]
72 main.configPass = main.params[ 'CONFIGURE' ][ 'cfgPass' ]
73 main.configPort = main.params[ 'CONFIGURE' ][ 'cfgAppPort' ]
Jon Hall0c3f46f2017-05-24 16:34:46 -070074 main.cycle = 0 # How many times FUNCintent has run through its tests
Jeremyfc567ca2016-02-16 15:08:25 -080075
Jeremyfc567ca2016-02-16 15:08:25 -080076 main.hostsData = {}
Jeremyfc567ca2016-02-16 15:08:25 -080077 main.assertReturnString = '' # Assembled assert return string
78
Jeremyfc567ca2016-02-16 15:08:25 -080079 # -- INIT SECTION, ONLY RUNS ONCE -- #
Jeremyfc567ca2016-02-16 15:08:25 -080080
81 main.netconfFunction = imp.load_source( wrapperFile2,
Jon Hall0c3f46f2017-05-24 16:34:46 -070082 main.dependencyPath +
83 wrapperFile2 +
84 ".py" )
Jeremyfc567ca2016-02-16 15:08:25 -080085
Devin Lim142b5342017-07-20 15:22:39 -070086 stepResult = main.testSetUp.envSetup()
Jeremyfc567ca2016-02-16 15:08:25 -080087 # Uncomment out the following if a mininet topology is added
88 # copyResult1 = main.ONOSbench.scp( main.Mininet1,
89 # main.dependencyPath +
90 # main.topology,
91 # main.Mininet1.home + "custom/",
92 # direction="to" )
Jeremyfc567ca2016-02-16 15:08:25 -080093 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -070094 main.testSetUp.envSetupException( e )
Jon Hallaa1d9b82020-07-30 13:49:42 -070095 main.testSetUp.envSetupConclusion( stepResult )
Jeremyfc567ca2016-02-16 15:08:25 -080096
Jeremyfc567ca2016-02-16 15:08:25 -080097 def CASE2( self, main ):
98 """
99 - Set up cell
100 - Create cell file
101 - Set cell file
102 - Verify cell file
103 - Kill ONOS process
104 - Uninstall ONOS cluster
105 - Verify ONOS start up
106 - Install ONOS cluster
107 - Connect to cli
108 """
You Wanga0f6ff62018-01-11 15:46:30 -0800109 main.testSetUp.ONOSSetUp( main.Cluster, True )
Jeremy Ronquilloed3550d2018-04-11 12:23:59 -0700110 time.sleep( main.startUpSleep )
111 utilities.assert_equals(expect=True,
112 actual=main.Cluster.nodesCheck(),
113 onpass="Nodes check successful.",
114 onfail="Nodes check failed.")
115
Jeremy Songster17147f22016-05-31 18:30:52 -0700116 def CASE19( self, main ):
117 """
118 Copy the karaf.log files after each testcase cycle
119 """
Devin Lim58046fa2017-07-05 16:55:00 -0700120 try:
121 from tests.dependencies.utils import Utils
122 except ImportError:
123 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700124 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700125 try:
126 main.Utils
127 except ( NameError, AttributeError ):
128 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700129 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700130
Jeremyfc567ca2016-02-16 15:08:25 -0800131 def CASE100( self, main ):
132 """
133 Start NETCONF app and OFC-Server or make sure that they are already running
134 """
135 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800136
137 testResult = main.FALSE
138 main.testName = "Start up NETCONF app in all nodes"
Devin Lim142b5342017-07-20 15:22:39 -0700139 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800140 " NODE(S)" )
141 main.step( "Starting NETCONF app" )
142 main.assertReturnString = "Assertion result for starting NETCONF app"
143 testResult = main.netconfFunction.startApp( main )
144
145 utilities.assert_equals( expect=main.TRUE,
146 actual=testResult,
147 onpass=main.assertReturnString,
148 onfail=main.assertReturnString )
149
150 main.step( "Starting OFC-Server" )
151 main.assertReturnString = "Assertion result for starting OFC-Server"
152 testResult = main.netconfFunction.startOFC( main )
153
154 utilities.assert_equals( expect=main.TRUE,
155 actual=testResult,
156 onpass=main.assertReturnString,
157 onfail=main.assertReturnString )
158 time.sleep( main.startUpSleep )
159
160 def CASE200( self, main ):
161 """
162 Create or modify a Configuration file
163 -The file is built from information loaded from the .params file
164 """
165 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800166
167 main.testName = "Assemble the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700168 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800169 " NODES(S)" )
170 main.step( "Assembling configuration file" )
171 main.assertReturnString = "Assertion result for assembling configuration file"
172 testResult = main.FALSE
173 testResult = main.netconfFunction.createConfig( main )
174
175 utilities.assert_equals( expect=main.TRUE,
176 actual=testResult,
177 onpass=main.assertReturnString,
178 onfail=main.assertReturnString )
179 time.sleep( main.startUpSleep )
180
181 def CASE300( self, main ):
182 """
183 Push a configuration and bring up a switch
184 """
185 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800186
187 main.testName = "Uploading the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700188 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800189 " NODES(S)" )
Jon Hall0c3f46f2017-05-24 16:34:46 -0700190 main.step( "Sending the configuration file" )
Jeremyfc567ca2016-02-16 15:08:25 -0800191 main.assertReturnString = "Assertion result for sending the configuration file"
192 testResult = main.FALSE
193
194 testResult = main.netconfFunction.sendConfig( main )
195
196 utilities.assert_equals( expect=main.TRUE,
197 actual=testResult,
198 onpass=main.assertReturnString,
199 onfail=main.assertReturnString )
200
201 time.sleep( main.switchSleep )
202
203 main.step( "Confirming the device was configured" )
204 main.assertReturnString = "Assertion result for confirming a configuration."
205 testResult = main.FALSE
206
207 testResult = main.netconfFunction.devices( main )
208
209 utilities.assert_equals( expect=main.TRUE,
210 actual=testResult,
211 onpass=main.assertReturnString,
212 onfail=main.assertReturnString )
213
214 def CASE400( self, main ):
215 """
216 Bring down a switch
217 This test case is not yet possible, but the functionality needed to
218 perform it is planned to be added
219 There is a message that is sent "Device () has closed session"
220 when the device disconnects from onos for some reason.
221 Because of the triggers for this message are not practical
222 to activate this will likely not be used to implement the test
223 case at this time
224 Possible ways to do this may include bringing down mininet then checking
225 ONOS to see if it was recongnized the device being disconnected
226 """