blob: d518c5aa764ca64895205a28c9d0371243627ec5 [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" )
Devin Lim44075962017-08-11 10:56:37 -070048 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -070049 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 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 )
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 Lim142b5342017-07-20 15:22:39 -0700110 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, 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" )
Devin Lim44075962017-08-11 10:56:37 -0700120 main.cleanAndExit()
Devin Lim58046fa2017-07-05 16:55:00 -0700121 try:
122 main.Utils
123 except ( NameError, AttributeError ):
124 main.Utils = Utils()
Devin Lim142b5342017-07-20 15:22:39 -0700125 main.Utils.copyKarafLog( "cycle" + str( main.cycle ) )
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"
Jeremyfc567ca2016-02-16 15:08:25 -0800131
132 testResult = main.FALSE
133 main.testName = "Start up NETCONF app in all nodes"
Devin Lim142b5342017-07-20 15:22:39 -0700134 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800135 " NODE(S)" )
136 main.step( "Starting NETCONF app" )
137 main.assertReturnString = "Assertion result for starting NETCONF app"
138 testResult = main.netconfFunction.startApp( main )
139
140 utilities.assert_equals( expect=main.TRUE,
141 actual=testResult,
142 onpass=main.assertReturnString,
143 onfail=main.assertReturnString )
144
145 main.step( "Starting OFC-Server" )
146 main.assertReturnString = "Assertion result for starting OFC-Server"
147 testResult = main.netconfFunction.startOFC( main )
148
149 utilities.assert_equals( expect=main.TRUE,
150 actual=testResult,
151 onpass=main.assertReturnString,
152 onfail=main.assertReturnString )
153 time.sleep( main.startUpSleep )
154
155 def CASE200( self, main ):
156 """
157 Create or modify a Configuration file
158 -The file is built from information loaded from the .params file
159 """
160 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800161
162 main.testName = "Assemble the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700163 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800164 " NODES(S)" )
165 main.step( "Assembling configuration file" )
166 main.assertReturnString = "Assertion result for assembling configuration file"
167 testResult = main.FALSE
168 testResult = main.netconfFunction.createConfig( main )
169
170 utilities.assert_equals( expect=main.TRUE,
171 actual=testResult,
172 onpass=main.assertReturnString,
173 onfail=main.assertReturnString )
174 time.sleep( main.startUpSleep )
175
176 def CASE300( self, main ):
177 """
178 Push a configuration and bring up a switch
179 """
180 assert main, "There is no main"
Jeremyfc567ca2016-02-16 15:08:25 -0800181
182 main.testName = "Uploading the configuration"
Devin Lim142b5342017-07-20 15:22:39 -0700183 main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) +
Jeremyfc567ca2016-02-16 15:08:25 -0800184 " NODES(S)" )
Jon Hall0c3f46f2017-05-24 16:34:46 -0700185 main.step( "Sending the configuration file" )
Jeremyfc567ca2016-02-16 15:08:25 -0800186 main.assertReturnString = "Assertion result for sending the configuration file"
187 testResult = main.FALSE
188
189 testResult = main.netconfFunction.sendConfig( main )
190
191 utilities.assert_equals( expect=main.TRUE,
192 actual=testResult,
193 onpass=main.assertReturnString,
194 onfail=main.assertReturnString )
195
196 time.sleep( main.switchSleep )
197
198 main.step( "Confirming the device was configured" )
199 main.assertReturnString = "Assertion result for confirming a configuration."
200 testResult = main.FALSE
201
202 testResult = main.netconfFunction.devices( main )
203
204 utilities.assert_equals( expect=main.TRUE,
205 actual=testResult,
206 onpass=main.assertReturnString,
207 onfail=main.assertReturnString )
208
209 def CASE400( self, main ):
210 """
211 Bring down a switch
212 This test case is not yet possible, but the functionality needed to
213 perform it is planned to be added
214 There is a message that is sent "Device () has closed session"
215 when the device disconnects from onos for some reason.
216 Because of the triggers for this message are not practical
217 to activate this will likely not be used to implement the test
218 case at this time
219 Possible ways to do this may include bringing down mininet then checking
220 ONOS to see if it was recongnized the device being disconnected
221 """