Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 1 | # Testing the NETCONF protocol within ONOS |
| 2 | |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 3 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 4 | class FUNCnetconf: |
| 5 | |
| 6 | def __init__( self ): |
| 7 | self.default = '' |
| 8 | |
| 9 | def CASE1( self, main ): |
| 10 | import time |
| 11 | import imp |
| 12 | import re |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 13 | """ |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 22 | 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() |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 29 | stepResult = main.FALSE |
| 30 | |
| 31 | # Test variables |
| 32 | try: |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 33 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 34 | main.dependencyPath = main.testOnDirectory + \ |
| 35 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 36 | # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 37 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 38 | 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 Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 53 | main.cycle = 0 # How many times FUNCintent has run through its tests |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 54 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 55 | main.hostsData = {} |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 56 | main.assertReturnString = '' # Assembled assert return string |
| 57 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 58 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 59 | |
| 60 | main.netconfFunction = imp.load_source( wrapperFile2, |
Jon Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 61 | main.dependencyPath + |
| 62 | wrapperFile2 + |
| 63 | ".py" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 64 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 65 | stepResult = main.testSetUp.envSetup( True, True ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 66 | # 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" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 72 | except Exception as e: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 73 | main.testSetUp.envSetupException( e ) |
| 74 | main.testSetUp.evnSetupConclusion( stepResult ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 75 | |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 76 | |
| 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 89 | main.testSetUp.ONOSSetUp( main.Mininet1, True ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 90 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 91 | def CASE19( self, main ): |
| 92 | """ |
| 93 | Copy the karaf.log files after each testcase cycle |
| 94 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 95 | 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() |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 105 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 110 | assert main.RESTs, "There is no main.RESTs" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 111 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 143 | assert main.RESTs, "There is no main.RESTs" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 144 | 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 Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 166 | assert main.RESTs, "There is no main.RESTs" |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 167 | 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 Hall | 0c3f46f | 2017-05-24 16:34:46 -0700 | [diff] [blame] | 173 | main.step( "Sending the configuration file" ) |
Jeremy | fc567ca | 2016-02-16 15:08:25 -0800 | [diff] [blame] | 174 | 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 | """ |