blob: 5e3059c173c7448675f359b74300069746ebb5b1 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2016 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
Jeremyfc567ca2016-02-16 15:08:25 -080022# Testing the NETCONF protocol within ONOS
23
Jon Hall0c3f46f2017-05-24 16:34:46 -070024
Jeremyfc567ca2016-02-16 15:08:25 -080025class FUNCnetconf:
26
27 def __init__( self ):
28 self.default = ''
29
30 def CASE1( self, main ):
31 import time
32 import imp
33 import re
Jeremyfc567ca2016-02-16 15:08:25 -080034 """
35 - Construct tests variables
36 - GIT ( optional )
37 - Checkout ONOS master branch
38 - Pull latest ONOS code
39 - Building ONOS ( optional )
40 - Install ONOS package
41 - Build ONOS package
42 """
Devin Lim58046fa2017-07-05 16:55:00 -070043 try:
44 from tests.dependencies.ONOSSetup import ONOSSetup
45 main.testSetUp = ONOSSetup()
46 except ImportError:
47 main.log.error( "ONOSSetup not found. exiting the test" )
48 main.exit()
49 main.testSetUp.envSetupDescription()
Jeremyfc567ca2016-02-16 15:08:25 -080050 stepResult = main.FALSE
51
52 # Test variables
53 try:
Jeremyfc567ca2016-02-16 15:08:25 -080054 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jeremyfc567ca2016-02-16 15:08:25 -080055 main.dependencyPath = main.testOnDirectory + \
56 main.params[ 'DEPENDENCY' ][ 'path' ]
57 # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
58 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 Lim58046fa2017-07-05 16:55:00 -070086 stepResult = main.testSetUp.envSetup( True, True )
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 )
95 main.testSetUp.evnSetupConclusion( stepResult )
Jeremyfc567ca2016-02-16 15:08:25 -080096
Jeremyfc567ca2016-02-16 15:08:25 -080097
98 def CASE2( self, main ):
99 """
100 - Set up cell
101 - Create cell file
102 - Set cell file
103 - Verify cell file
104 - Kill ONOS process
105 - Uninstall ONOS cluster
106 - Verify ONOS start up
107 - Install ONOS cluster
108 - Connect to cli
109 """
Devin Lim58046fa2017-07-05 16:55:00 -0700110 main.testSetUp.ONOSSetUp( main.Mininet1, True )
Jeremyfc567ca2016-02-16 15:08:25 -0800111
Jeremy Songster17147f22016-05-31 18:30:52 -0700112 def CASE19( self, main ):
113 """
114 Copy the karaf.log files after each testcase cycle
115 """
Devin Lim58046fa2017-07-05 16:55:00 -0700116 try:
117 from tests.dependencies.utils import Utils
118 except ImportError:
119 main.log.error( "Utils not found exiting the test" )
120 main.exit()
121 try:
122 main.Utils
123 except ( NameError, AttributeError ):
124 main.Utils = Utils()
125 main.Utils.copyKarafLog()
Jeremyfc567ca2016-02-16 15:08:25 -0800126 def CASE100( self, main ):
127 """
128 Start NETCONF app and OFC-Server or make sure that they are already running
129 """
130 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700131 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800132 assert main.numCtrls, "Placed the total number of switch topology in \
133 main.numCtrls"
134
135 testResult = main.FALSE
136 main.testName = "Start up NETCONF app in all nodes"
137 main.case( main.testName + " Test - " + str( main.numCtrls ) +
138 " NODE(S)" )
139 main.step( "Starting NETCONF app" )
140 main.assertReturnString = "Assertion result for starting NETCONF app"
141 testResult = main.netconfFunction.startApp( main )
142
143 utilities.assert_equals( expect=main.TRUE,
144 actual=testResult,
145 onpass=main.assertReturnString,
146 onfail=main.assertReturnString )
147
148 main.step( "Starting OFC-Server" )
149 main.assertReturnString = "Assertion result for starting OFC-Server"
150 testResult = main.netconfFunction.startOFC( main )
151
152 utilities.assert_equals( expect=main.TRUE,
153 actual=testResult,
154 onpass=main.assertReturnString,
155 onfail=main.assertReturnString )
156 time.sleep( main.startUpSleep )
157
158 def CASE200( self, main ):
159 """
160 Create or modify a Configuration file
161 -The file is built from information loaded from the .params file
162 """
163 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700164 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800165 assert main.numCtrls, "Placed the total number of switch topology in \
166 main.numCtrls"
167
168 main.testName = "Assemble the configuration"
169 main.case( main.testName + " Test - " + str( main.numCtrls ) +
170 " NODES(S)" )
171 main.step( "Assembling configuration file" )
172 main.assertReturnString = "Assertion result for assembling configuration file"
173 testResult = main.FALSE
174 testResult = main.netconfFunction.createConfig( main )
175
176 utilities.assert_equals( expect=main.TRUE,
177 actual=testResult,
178 onpass=main.assertReturnString,
179 onfail=main.assertReturnString )
180 time.sleep( main.startUpSleep )
181
182 def CASE300( self, main ):
183 """
184 Push a configuration and bring up a switch
185 """
186 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700187 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800188 assert main.numCtrls, "Placed the total number of switch topology in \
189 main.numCtrls"
190
191 main.testName = "Uploading the configuration"
192 main.case( main.testName + " Test - " + str( main.numCtrls ) +
193 " NODES(S)" )
Jon Hall0c3f46f2017-05-24 16:34:46 -0700194 main.step( "Sending the configuration file" )
Jeremyfc567ca2016-02-16 15:08:25 -0800195 main.assertReturnString = "Assertion result for sending the configuration file"
196 testResult = main.FALSE
197
198 testResult = main.netconfFunction.sendConfig( main )
199
200 utilities.assert_equals( expect=main.TRUE,
201 actual=testResult,
202 onpass=main.assertReturnString,
203 onfail=main.assertReturnString )
204
205 time.sleep( main.switchSleep )
206
207 main.step( "Confirming the device was configured" )
208 main.assertReturnString = "Assertion result for confirming a configuration."
209 testResult = main.FALSE
210
211 testResult = main.netconfFunction.devices( main )
212
213 utilities.assert_equals( expect=main.TRUE,
214 actual=testResult,
215 onpass=main.assertReturnString,
216 onfail=main.assertReturnString )
217
218 def CASE400( self, main ):
219 """
220 Bring down a switch
221 This test case is not yet possible, but the functionality needed to
222 perform it is planned to be added
223 There is a message that is sent "Device () has closed session"
224 when the device disconnects from onos for some reason.
225 Because of the triggers for this message are not practical
226 to activate this will likely not be used to implement the test
227 case at this time
228 Possible ways to do this may include bringing down mininet then checking
229 ONOS to see if it was recongnized the device being disconnected
230 """