Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 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 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 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 | """ |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 21 | # Testing the NETCONF protocol within ONOS |
| 22 | |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 23 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 24 | class FUNCnetconf: |
| 25 | |
| 26 | def __init__( self ): |
| 27 | self.default = '' |
| 28 | |
| 29 | def CASE1( self, main ): |
| 30 | import time |
| 31 | import imp |
| 32 | import re |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 33 | """ |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 42 | 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 47 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 48 | main.testSetUp.envSetupDescription() |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 49 | stepResult = main.FALSE |
| 50 | |
| 51 | # Test variables |
| 52 | try: |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 53 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 54 | main.dependencyPath = main.testOnDirectory + \ |
| 55 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 56 | # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
Jeremy Ronquillo | ed3550d | 2018-04-11 12:23:59 -0700 | [diff] [blame] | 57 | main.iface = main.params[ 'DEPENDENCY' ][ 'iface' ] |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 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 | def CASE2( self, main ): |
| 98 | """ |
| 99 | - Set up cell |
| 100 | - Create cell file |
| 101 | - Set cell file |
| 102 | - Verify cell file |
| 103 | - Kill ONOS process |
| 104 | - Uninstall ONOS cluster |
| 105 | - Verify ONOS start up |
| 106 | - Install ONOS cluster |
| 107 | - Connect to cli |
| 108 | """ |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 109 | main.testSetUp.ONOSSetUp( main.Cluster, True ) |
Jeremy Ronquillo | ed3550d | 2018-04-11 12:23:59 -0700 | [diff] [blame] | 110 | time.sleep( main.startUpSleep ) |
| 111 | utilities.assert_equals(expect=True, |
| 112 | actual=main.Cluster.nodesCheck(), |
| 113 | onpass="Nodes check successful.", |
| 114 | onfail="Nodes check failed.") |
| 115 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 116 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 117 | def CASE19( self, main ): |
| 118 | """ |
| 119 | Copy the karaf.log files after each testcase cycle |
| 120 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 121 | try: |
| 122 | from tests.dependencies.utils import Utils |
| 123 | except ImportError: |
| 124 | main.log.error( "Utils not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 125 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 126 | try: |
| 127 | main.Utils |
| 128 | except ( NameError, AttributeError ): |
| 129 | main.Utils = Utils() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 130 | main.Utils.copyKarafLog( "cycle" + str( main.cycle ) ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 131 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 132 | def CASE100( self, main ): |
| 133 | """ |
| 134 | Start NETCONF app and OFC-Server or make sure that they are already running |
| 135 | """ |
| 136 | assert main, "There is no main" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 137 | |
| 138 | testResult = main.FALSE |
| 139 | main.testName = "Start up NETCONF app in all nodes" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 140 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 141 | " NODE(S)" ) |
| 142 | main.step( "Starting NETCONF app" ) |
| 143 | main.assertReturnString = "Assertion result for starting NETCONF app" |
| 144 | testResult = main.netconfFunction.startApp( main ) |
| 145 | |
| 146 | utilities.assert_equals( expect=main.TRUE, |
| 147 | actual=testResult, |
| 148 | onpass=main.assertReturnString, |
| 149 | onfail=main.assertReturnString ) |
| 150 | |
| 151 | main.step( "Starting OFC-Server" ) |
| 152 | main.assertReturnString = "Assertion result for starting OFC-Server" |
| 153 | testResult = main.netconfFunction.startOFC( 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 CASE200( self, main ): |
| 162 | """ |
| 163 | Create or modify a Configuration file |
| 164 | -The file is built from information loaded from the .params file |
| 165 | """ |
| 166 | assert main, "There is no main" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 167 | |
| 168 | main.testName = "Assemble the configuration" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 169 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 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" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 187 | |
| 188 | main.testName = "Uploading the configuration" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 189 | main.case( main.testName + " Test - " + str( main.Cluster.numCtrls ) + |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 190 | " NODES(S)" ) |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 191 | main.step( "Sending the configuration file" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 192 | main.assertReturnString = "Assertion result for sending the configuration file" |
| 193 | testResult = main.FALSE |
| 194 | |
| 195 | testResult = main.netconfFunction.sendConfig( main ) |
| 196 | |
| 197 | utilities.assert_equals( expect=main.TRUE, |
| 198 | actual=testResult, |
| 199 | onpass=main.assertReturnString, |
| 200 | onfail=main.assertReturnString ) |
| 201 | |
| 202 | time.sleep( main.switchSleep ) |
| 203 | |
| 204 | main.step( "Confirming the device was configured" ) |
| 205 | main.assertReturnString = "Assertion result for confirming a configuration." |
| 206 | testResult = main.FALSE |
| 207 | |
| 208 | testResult = main.netconfFunction.devices( main ) |
| 209 | |
| 210 | utilities.assert_equals( expect=main.TRUE, |
| 211 | actual=testResult, |
| 212 | onpass=main.assertReturnString, |
| 213 | onfail=main.assertReturnString ) |
| 214 | |
| 215 | def CASE400( self, main ): |
| 216 | """ |
| 217 | Bring down a switch |
| 218 | This test case is not yet possible, but the functionality needed to |
| 219 | perform it is planned to be added |
| 220 | There is a message that is sent "Device () has closed session" |
| 221 | when the device disconnects from onos for some reason. |
| 222 | Because of the triggers for this message are not practical |
| 223 | to activate this will likely not be used to implement the test |
| 224 | case at this time |
| 225 | Possible ways to do this may include bringing down mininet then checking |
| 226 | ONOS to see if it was recongnized the device being disconnected |
| 227 | """ |