Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 22 | # Testing the NETCONF protocol within ONOS |
| 23 | |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 24 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 25 | class FUNCnetconf: |
| 26 | |
| 27 | def __init__( self ): |
| 28 | self.default = '' |
| 29 | |
| 30 | def CASE1( self, main ): |
| 31 | import time |
| 32 | import imp |
| 33 | import re |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 34 | """ |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 43 | 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() |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 50 | stepResult = main.FALSE |
| 51 | |
| 52 | # Test variables |
| 53 | try: |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 54 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 55 | main.dependencyPath = main.testOnDirectory + \ |
| 56 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 57 | # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 58 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 59 | 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 Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 74 | main.cycle = 0 # How many times FUNCintent has run through its tests |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 75 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 76 | main.hostsData = {} |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 77 | main.assertReturnString = '' # Assembled assert return string |
| 78 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 79 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 80 | |
| 81 | main.netconfFunction = imp.load_source( wrapperFile2, |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 82 | main.dependencyPath + |
| 83 | wrapperFile2 + |
| 84 | ".py" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 85 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 86 | stepResult = main.testSetUp.envSetup() |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 87 | # 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" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 93 | except Exception as e: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 94 | main.testSetUp.envSetupException( e ) |
| 95 | main.testSetUp.evnSetupConclusion( stepResult ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 96 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 97 | |
| 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 110 | main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, True ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 111 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 112 | def CASE19( self, main ): |
| 113 | """ |
| 114 | Copy the karaf.log files after each testcase cycle |
| 115 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 116 | 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() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 125 | main.Utils.copyKarafLog( "cycle" + str( main.cycle ) ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 126 | 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" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 131 | |
| 132 | testResult = main.FALSE |
| 133 | main.testName = "Start up NETCONF app in all nodes" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 134 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 135 | " 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" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 161 | |
| 162 | main.testName = "Assemble the configuration" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 163 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 164 | " 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" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 181 | |
| 182 | main.testName = "Uploading the configuration" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame^] | 183 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 184 | " NODES(S)" ) |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 185 | main.step( "Sending the configuration file" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 186 | 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 | """ |