blob: ad2c4bab726ff5682dbbf56a889be62a8db4fb40 [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' ]
57 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Jeremyfc567ca2016-02-16 15:08:25 -080058 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
59 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
60 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
61 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
62 main.switchSleep = int( main.params[ 'SLEEP' ][ 'upSwitch' ] )
63 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
64 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
65
66 # Config file parameters
67 main.configDevicePort = main.params[ 'CONFIGURE' ][ 'cfgDevicePort' ]
68 main.configDriver = main.params[ 'CONFIGURE' ][ 'cfgDriver' ]
69 main.configApps = main.params[ 'CONFIGURE' ][ 'cfgApps' ]
70 main.configName = main.params[ 'CONFIGURE' ][ 'cfgName' ]
71 main.configPass = main.params[ 'CONFIGURE' ][ 'cfgPass' ]
72 main.configPort = main.params[ 'CONFIGURE' ][ 'cfgAppPort' ]
Jon Hall0c3f46f2017-05-24 16:34:46 -070073 main.cycle = 0 # How many times FUNCintent has run through its tests
Jeremyfc567ca2016-02-16 15:08:25 -080074
Jeremyfc567ca2016-02-16 15:08:25 -080075 main.hostsData = {}
Jeremyfc567ca2016-02-16 15:08:25 -080076 main.assertReturnString = '' # Assembled assert return string
77
Jeremyfc567ca2016-02-16 15:08:25 -080078 # -- INIT SECTION, ONLY RUNS ONCE -- #
Jeremyfc567ca2016-02-16 15:08:25 -080079
80 main.netconfFunction = imp.load_source( wrapperFile2,
Jon Hall0c3f46f2017-05-24 16:34:46 -070081 main.dependencyPath +
82 wrapperFile2 +
83 ".py" )
Jeremyfc567ca2016-02-16 15:08:25 -080084
Devin Lim142b5342017-07-20 15:22:39 -070085 stepResult = main.testSetUp.envSetup()
Jeremyfc567ca2016-02-16 15:08:25 -080086 # Uncomment out the following if a mininet topology is added
87 # copyResult1 = main.ONOSbench.scp( main.Mininet1,
88 # main.dependencyPath +
89 # main.topology,
90 # main.Mininet1.home + "custom/",
91 # direction="to" )
Jeremyfc567ca2016-02-16 15:08:25 -080092 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -070093 main.testSetUp.envSetupException( e )
94 main.testSetUp.evnSetupConclusion( stepResult )
Jeremyfc567ca2016-02-16 15:08:25 -080095
Jeremyfc567ca2016-02-16 15:08:25 -080096 def CASE2( self, main ):
97 """
98 - Set up cell
99 - Create cell file
100 - Set cell file
101 - Verify cell file
102 - Kill ONOS process
103 - Uninstall ONOS cluster
104 - Verify ONOS start up
105 - Install ONOS cluster
106 - Connect to cli
107 """
Devin Lim142b5342017-07-20 15:22:39 -0700108 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True )
Jeremyfc567ca2016-02-16 15:08:25 -0800109
Jeremy Songster17147f22016-05-31 18:30:52 -0700110 def CASE19( self, main ):
111 """
112 Copy the karaf.log files after each testcase cycle
113 """
Devin Lim58046fa2017-07-05 16:55:00 -0700114 try:
115 from tests.dependencies.utils import Utils
116 except ImportError:
117 main.log.error( "Utils not found exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -0700118 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700119 try:
120 main.Utils
121 except ( NameError, AttributeError ):
122 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700123 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700124
Jeremyfc567ca2016-02-16 15:08:25 -0800125 def CASE100( self, main ):
126 """
127 Start NETCONF app and OFC-Server or make sure that they are already running
128 """
129 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800130
131 testResult = main.FALSE
132 main.testName = "Start up NETCONF app in all nodes"
Devin Lim142b5342017-07-20 15:22:39 -0700133 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800134 " NODE(S)" )
135 main.step( "Starting NETCONF app" )
136 main.assertReturnString = "Assertion result for starting NETCONF app"
137 testResult = main.netconfFunction.startApp( main )
138
139 utilities.assert_equals( expect=main.TRUE,
140 actual=testResult,
141 onpass=main.assertReturnString,
142 onfail=main.assertReturnString )
143
144 main.step( "Starting OFC-Server" )
145 main.assertReturnString = "Assertion result for starting OFC-Server"
146 testResult = main.netconfFunction.startOFC( main )
147
148 utilities.assert_equals( expect=main.TRUE,
149 actual=testResult,
150 onpass=main.assertReturnString,
151 onfail=main.assertReturnString )
152 time.sleep( main.startUpSleep )
153
154 def CASE200( self, main ):
155 """
156 Create or modify a Configuration file
157 -The file is built from information loaded from the .params file
158 """
159 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800160
161 main.testName = "Assemble the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700162 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800163 " NODES(S)" )
164 main.step( "Assembling configuration file" )
165 main.assertReturnString = "Assertion result for assembling configuration file"
166 testResult = main.FALSE
167 testResult = main.netconfFunction.createConfig( main )
168
169 utilities.assert_equals( expect=main.TRUE,
170 actual=testResult,
171 onpass=main.assertReturnString,
172 onfail=main.assertReturnString )
173 time.sleep( main.startUpSleep )
174
175 def CASE300( self, main ):
176 """
177 Push a configuration and bring up a switch
178 """
179 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800180
181 main.testName = "Uploading the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700182 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800183 " NODES(S)" )
Jon Hall0c3f46f2017-05-24 16:34:46 -0700184 main.step( "Sending the configuration file" )
Jeremyfc567ca2016-02-16 15:08:25 -0800185 main.assertReturnString = "Assertion result for sending the configuration file"
186 testResult = main.FALSE
187
188 testResult = main.netconfFunction.sendConfig( main )
189
190 utilities.assert_equals( expect=main.TRUE,
191 actual=testResult,
192 onpass=main.assertReturnString,
193 onfail=main.assertReturnString )
194
195 time.sleep( main.switchSleep )
196
197 main.step( "Confirming the device was configured" )
198 main.assertReturnString = "Assertion result for confirming a configuration."
199 testResult = main.FALSE
200
201 testResult = main.netconfFunction.devices( main )
202
203 utilities.assert_equals( expect=main.TRUE,
204 actual=testResult,
205 onpass=main.assertReturnString,
206 onfail=main.assertReturnString )
207
208 def CASE400( self, main ):
209 """
210 Bring down a switch
211 This test case is not yet possible, but the functionality needed to
212 perform it is planned to be added
213 There is a message that is sent "Device () has closed session"
214 when the device disconnects from onos for some reason.
215 Because of the triggers for this message are not practical
216 to activate this will likely not be used to implement the test
217 case at this time
218 Possible ways to do this may include bringing down mininet then checking
219 ONOS to see if it was recongnized the device being disconnected
220 """