blob: 5e40d18f6858d328ba08d9db1cae9a60d08ea6a7 [file] [log] [blame]
Jeremyfc567ca2016-02-16 15:08:25 -08001# Testing the NETCONF protocol within ONOS
2
Jon Hall0c3f46f2017-05-24 16:34:46 -07003
Jeremyfc567ca2016-02-16 15:08:25 -08004class FUNCnetconf:
5
6 def __init__( self ):
7 self.default = ''
8
9 def CASE1( self, main ):
10 import time
11 import imp
12 import re
Jeremyfc567ca2016-02-16 15:08:25 -080013 """
14 - Construct tests variables
15 - GIT ( optional )
16 - Checkout ONOS master branch
17 - Pull latest ONOS code
18 - Building ONOS ( optional )
19 - Install ONOS package
20 - Build ONOS package
21 """
Devin Lim58046fa2017-07-05 16:55:00 -070022 try:
23 from tests.dependencies.ONOSSetup import ONOSSetup
24 main.testSetUp = ONOSSetup()
25 except ImportError:
26 main.log.error( "ONOSSetup not found. exiting the test" )
27 main.exit()
28 main.testSetUp.envSetupDescription()
Jeremyfc567ca2016-02-16 15:08:25 -080029 stepResult = main.FALSE
30
31 # Test variables
32 try:
Jeremyfc567ca2016-02-16 15:08:25 -080033 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jeremyfc567ca2016-02-16 15:08:25 -080034 main.dependencyPath = main.testOnDirectory + \
35 main.params[ 'DEPENDENCY' ][ 'path' ]
36 # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
37 main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
Jeremyfc567ca2016-02-16 15:08:25 -080038 wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
39 wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
40 wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
41 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
42 main.switchSleep = int( main.params[ 'SLEEP' ][ 'upSwitch' ] )
43 main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] )
44 main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] )
45
46 # Config file parameters
47 main.configDevicePort = main.params[ 'CONFIGURE' ][ 'cfgDevicePort' ]
48 main.configDriver = main.params[ 'CONFIGURE' ][ 'cfgDriver' ]
49 main.configApps = main.params[ 'CONFIGURE' ][ 'cfgApps' ]
50 main.configName = main.params[ 'CONFIGURE' ][ 'cfgName' ]
51 main.configPass = main.params[ 'CONFIGURE' ][ 'cfgPass' ]
52 main.configPort = main.params[ 'CONFIGURE' ][ 'cfgAppPort' ]
Jon Hall0c3f46f2017-05-24 16:34:46 -070053 main.cycle = 0 # How many times FUNCintent has run through its tests
Jeremyfc567ca2016-02-16 15:08:25 -080054
Jeremyfc567ca2016-02-16 15:08:25 -080055 main.hostsData = {}
Jeremyfc567ca2016-02-16 15:08:25 -080056 main.assertReturnString = '' # Assembled assert return string
57
Jeremyfc567ca2016-02-16 15:08:25 -080058 # -- INIT SECTION, ONLY RUNS ONCE -- #
Jeremyfc567ca2016-02-16 15:08:25 -080059
60 main.netconfFunction = imp.load_source( wrapperFile2,
Jon Hall0c3f46f2017-05-24 16:34:46 -070061 main.dependencyPath +
62 wrapperFile2 +
63 ".py" )
Jeremyfc567ca2016-02-16 15:08:25 -080064
Devin Lim58046fa2017-07-05 16:55:00 -070065 stepResult = main.testSetUp.envSetup( True, True )
Jeremyfc567ca2016-02-16 15:08:25 -080066 # Uncomment out the following if a mininet topology is added
67 # copyResult1 = main.ONOSbench.scp( main.Mininet1,
68 # main.dependencyPath +
69 # main.topology,
70 # main.Mininet1.home + "custom/",
71 # direction="to" )
Jeremyfc567ca2016-02-16 15:08:25 -080072 except Exception as e:
Devin Lim58046fa2017-07-05 16:55:00 -070073 main.testSetUp.envSetupException( e )
74 main.testSetUp.evnSetupConclusion( stepResult )
Jeremyfc567ca2016-02-16 15:08:25 -080075
Jeremyfc567ca2016-02-16 15:08:25 -080076
77 def CASE2( self, main ):
78 """
79 - Set up cell
80 - Create cell file
81 - Set cell file
82 - Verify cell file
83 - Kill ONOS process
84 - Uninstall ONOS cluster
85 - Verify ONOS start up
86 - Install ONOS cluster
87 - Connect to cli
88 """
Devin Lim58046fa2017-07-05 16:55:00 -070089 main.testSetUp.ONOSSetUp( main.Mininet1, True )
Jeremyfc567ca2016-02-16 15:08:25 -080090
Jeremy Songster17147f22016-05-31 18:30:52 -070091 def CASE19( self, main ):
92 """
93 Copy the karaf.log files after each testcase cycle
94 """
Devin Lim58046fa2017-07-05 16:55:00 -070095 try:
96 from tests.dependencies.utils import Utils
97 except ImportError:
98 main.log.error( "Utils not found exiting the test" )
99 main.exit()
100 try:
101 main.Utils
102 except ( NameError, AttributeError ):
103 main.Utils = Utils()
104 main.Utils.copyKarafLog()
Jeremyfc567ca2016-02-16 15:08:25 -0800105 def CASE100( self, main ):
106 """
107 Start NETCONF app and OFC-Server or make sure that they are already running
108 """
109 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700110 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800111 assert main.numCtrls, "Placed the total number of switch topology in \
112 main.numCtrls"
113
114 testResult = main.FALSE
115 main.testName = "Start up NETCONF app in all nodes"
116 main.case( main.testName + " Test - " + str( main.numCtrls ) +
117 " NODE(S)" )
118 main.step( "Starting NETCONF app" )
119 main.assertReturnString = "Assertion result for starting NETCONF app"
120 testResult = main.netconfFunction.startApp( main )
121
122 utilities.assert_equals( expect=main.TRUE,
123 actual=testResult,
124 onpass=main.assertReturnString,
125 onfail=main.assertReturnString )
126
127 main.step( "Starting OFC-Server" )
128 main.assertReturnString = "Assertion result for starting OFC-Server"
129 testResult = main.netconfFunction.startOFC( main )
130
131 utilities.assert_equals( expect=main.TRUE,
132 actual=testResult,
133 onpass=main.assertReturnString,
134 onfail=main.assertReturnString )
135 time.sleep( main.startUpSleep )
136
137 def CASE200( self, main ):
138 """
139 Create or modify a Configuration file
140 -The file is built from information loaded from the .params file
141 """
142 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700143 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800144 assert main.numCtrls, "Placed the total number of switch topology in \
145 main.numCtrls"
146
147 main.testName = "Assemble the configuration"
148 main.case( main.testName + " Test - " + str( main.numCtrls ) +
149 " NODES(S)" )
150 main.step( "Assembling configuration file" )
151 main.assertReturnString = "Assertion result for assembling configuration file"
152 testResult = main.FALSE
153 testResult = main.netconfFunction.createConfig( main )
154
155 utilities.assert_equals( expect=main.TRUE,
156 actual=testResult,
157 onpass=main.assertReturnString,
158 onfail=main.assertReturnString )
159 time.sleep( main.startUpSleep )
160
161 def CASE300( self, main ):
162 """
163 Push a configuration and bring up a switch
164 """
165 assert main, "There is no main"
Devin Lim58046fa2017-07-05 16:55:00 -0700166 assert main.RESTs, "There is no main.RESTs"
Jeremyfc567ca2016-02-16 15:08:25 -0800167 assert main.numCtrls, "Placed the total number of switch topology in \
168 main.numCtrls"
169
170 main.testName = "Uploading the configuration"
171 main.case( main.testName + " Test - " + str( main.numCtrls ) +
172 " NODES(S)" )
Jon Hall0c3f46f2017-05-24 16:34:46 -0700173 main.step( "Sending the configuration file" )
Jeremyfc567ca2016-02-16 15:08:25 -0800174 main.assertReturnString = "Assertion result for sending the configuration file"
175 testResult = main.FALSE
176
177 testResult = main.netconfFunction.sendConfig( main )
178
179 utilities.assert_equals( expect=main.TRUE,
180 actual=testResult,
181 onpass=main.assertReturnString,
182 onfail=main.assertReturnString )
183
184 time.sleep( main.switchSleep )
185
186 main.step( "Confirming the device was configured" )
187 main.assertReturnString = "Assertion result for confirming a configuration."
188 testResult = main.FALSE
189
190 testResult = main.netconfFunction.devices( main )
191
192 utilities.assert_equals( expect=main.TRUE,
193 actual=testResult,
194 onpass=main.assertReturnString,
195 onfail=main.assertReturnString )
196
197 def CASE400( self, main ):
198 """
199 Bring down a switch
200 This test case is not yet possible, but the functionality needed to
201 perform it is planned to be added
202 There is a message that is sent "Device () has closed session"
203 when the device disconnects from onos for some reason.
204 Because of the triggers for this message are not practical
205 to activate this will likely not be used to implement the test
206 case at this time
207 Possible ways to do this may include bringing down mininet then checking
208 ONOS to see if it was recongnized the device being disconnected
209 """