Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2015 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 | """ |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 21 | |
| 22 | # Testing network scalability, this test suite scales up a network topology |
| 23 | # using mininet and verifies ONOS stability |
| 24 | |
GlennRC | 1c5df3c | 2015-08-27 16:12:09 -0700 | [diff] [blame] | 25 | class SCPFscaleTopo: |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 26 | |
| 27 | def __init__( self ): |
| 28 | self.default = '' |
| 29 | |
| 30 | def CASE1( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 31 | import os |
| 32 | import imp |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [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" ) |
| 47 | main.exit() |
| 48 | main.testSetUp.envSetupDescription() |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 49 | stepResult = main.FALSE |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 50 | try: |
| 51 | # The variable to decide if the data should be written into data base. |
| 52 | # 1 means Yes and -1 means No. |
| 53 | main.writeData = 1 |
| 54 | main.searchTerm = main.params[ 'SearchTerm' ] |
| 55 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 56 | main.dependencyPath = main.testOnDirectory + \ |
| 57 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 58 | main.tsharkResultPath = main.params[ 'TsharkPath' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 59 | main.roleRequest = main.params[ 'SearchTerm' ][ 'roleRequest' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 60 | main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ] |
| 61 | main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ] |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 62 | main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," ) |
| 63 | main.topoScaleSize = len( main.topoScale ) |
| 64 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 65 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 66 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 67 | main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] ) |
| 68 | main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] ) |
| 69 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 70 | main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] ) |
| 71 | main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] ) |
| 72 | main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] ) |
| 73 | main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] ) |
| 74 | main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] ) |
| 75 | main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 76 | main.hostDiscoverSleep = float( main.params[ 'SLEEP' ][ 'host' ] ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 77 | if main.hostDiscover == 'True': |
| 78 | main.hostDiscover = True |
| 79 | else: |
| 80 | main.hostDiscover = False |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 81 | main.homeDir = os.path.expanduser( '~' ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 82 | main.hostsData = {} |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 83 | |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 84 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 85 | stepResult = main.testSetUp.envSetup() |
| 86 | main.allinfo = {} # The dictionary to record all the data from karaf.log |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 87 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 88 | for i in range( 2 ): |
| 89 | main.allinfo[ i ]={} |
| 90 | for w in range ( 3 ): |
| 91 | # Totaltime: the time from the new switchConnection to its end |
| 92 | # swConnection: the time from the first new switchConnection to the last new switchConnection |
| 93 | # lastSwToLastRr: the time from the last new switchConnection to the last role request |
| 94 | # lastRrToLastTopology: the time form the last role request to the last topology |
| 95 | # disconnectRate: the rate that shows how many switch disconnect after connection |
| 96 | main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 } |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 97 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 98 | main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ] |
| 99 | main.log.info( "Create Database file " + main.dbFilePath ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 100 | resultDB = open( main.dbFilePath, 'w+' ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 101 | resultDB.close() |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 102 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 103 | main.scaleTopoFunction = imp.load_source( wrapperFile2, |
| 104 | main.dependencyPath + |
| 105 | wrapperFile2 + |
| 106 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 107 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 108 | main.topo = imp.load_source( wrapperFile3, |
| 109 | main.dependencyPath + |
| 110 | wrapperFile3 + |
| 111 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 112 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 113 | main.ONOSbench.scp( main.Mininet1, |
| 114 | main.dependencyPath + |
| 115 | main.multiovs, |
| 116 | main.Mininet1.home, |
| 117 | direction="to" ) |
| 118 | except Exception as e: |
| 119 | main.testSetUp.envSetupException( e ) |
| 120 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 121 | main.commit = main.commit.split( " " )[ 1 ] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 122 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 123 | def CASE2( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 124 | """ |
| 125 | - Set up cell |
| 126 | - Create cell file |
| 127 | - Set cell file |
| 128 | - Verify cell file |
| 129 | - Kill ONOS process |
| 130 | - Uninstall ONOS cluster |
| 131 | - Verify ONOS start up |
| 132 | - Install ONOS cluster |
| 133 | - Connect to cli |
| 134 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 135 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 136 | try: |
| 137 | from tests.dependencies.utils import Utils |
| 138 | except ImportError: |
| 139 | main.log.error( "Utils not found exiting the test" ) |
| 140 | main.exit() |
| 141 | try: |
| 142 | main.Utils |
| 143 | except ( NameError, AttributeError ): |
| 144 | main.Utils = Utils() |
| 145 | main.Utils.mininetCleanup( main.Mininet1 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 146 | main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 147 | |
| 148 | def CASE10( self, main ): |
| 149 | """ |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 150 | Starting up torus topology |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 151 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 152 | |
| 153 | main.case( "Starting up Mininet and verifying topology" ) |
| 154 | main.caseExplanation = "Starting Mininet with a scalling topology and " +\ |
| 155 | "comparing topology elements between Mininet and ONOS" |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 156 | if main.topoScale: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 157 | main.currScale = main.topoScale.pop( 0 ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 158 | else: main.log.error( "topology scale is empty" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 159 | main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 160 | |
| 161 | main.log.info( "Constructing Mininet command" ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 162 | mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \ |
| 163 | " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 164 | for ctrl in main.Cluster.runningNodes: |
| 165 | mnCmd += " --controller remote,ip=" + ctrl.ipAddress |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 166 | stepResult = main.Mininet1.startNet( mnCmd=mnCmd ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 167 | utilities.assert_equals( expect=main.TRUE, |
| 168 | actual=stepResult, |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 169 | onpass=main.topoName + |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 170 | " topology started successfully", |
| 171 | onfail=main.topoName + |
| 172 | " topology failed to start" ) |
| 173 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 174 | time.sleep( main.MNSleep ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 175 | main.log.info( "Clean up Tshark" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 176 | with open( main.tsharkResultPath, "w" ) as tshark: |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 177 | tshark.write( "" ) |
| 178 | main.log.info( "Starting Tshark capture" ) |
| 179 | main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 180 | main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" ) |
Chiyu Cheng | 8149942 | 2016-11-09 11:04:23 -0800 | [diff] [blame] | 181 | time.sleep( main.MNSleep ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 182 | main.log.info( "Stop Tshark" ) |
| 183 | main.ONOSbench.tsharkStop() |
| 184 | main.log.info( "Get role request time" ) |
| 185 | with open( main.tsharkResultPath, "r" ) as resultFile: |
| 186 | resultText = resultFile.readlines() |
| 187 | resultFile.close() |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 188 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 189 | def CASE11( self, main ): |
| 190 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 191 | Compare topo, and sending Arping package |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 192 | if the topology is same, then Pass. |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 193 | """ |
| 194 | import json |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 195 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 196 | try: |
| 197 | from tests.dependencies.topology import Topology |
| 198 | except ImportError: |
| 199 | main.log.error( "Topology not found exiting the test" ) |
| 200 | main.exit() |
| 201 | try: |
| 202 | main.topoRelated |
| 203 | except ( NameError, AttributeError ): |
| 204 | main.topoRelated = Topology() |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 205 | # First capture |
| 206 | for i in range( 3 ): |
| 207 | # Calculate total time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 208 | main.allinfo[ 0 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'end' ], 'last', index=i, funcMode='TD' ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 209 | # Calculate switch connection time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 210 | main.allinfo[ 0 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'start' ], 'first', main.searchTerm[ 'start' ], 'last', index=i, funcMode='TD' ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 211 | # Calculate the time from last switch connection to the last role request |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 212 | main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'start' ], 'last', index=i ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 213 | # Calculate the time from the last role request to the last topology |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 214 | main.allinfo[ 0 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, main.searchTerm[ 'end' ], 'last', index=i ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 215 | # Calculate the disconnecti rate |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 216 | main.allinfo[ 0 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, main.searchTerm[ 'Disconnect' ], 'num', main.searchTerm[ 'start' ], 'num', index=i, funcMode='DR' ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 217 | main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 218 | |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 219 | main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 220 | main.caseExplanation = "Pinging all hosts and comparing topology " +\ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 221 | "elements between Mininet and ONOS" |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 222 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 223 | main.log.info( "Gathering topology information" ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 224 | time.sleep( main.MNSleep ) |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 225 | stepResult = main.TRUE |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 226 | main.step( "Comparing MN topology to ONOS topology" ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 227 | compareRetry = 0 |
| 228 | while compareRetry < 3: |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 229 | #While loop for retry |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 230 | devices = main.topoRelated.getAll( "devices" ) |
| 231 | ports = main.topoRelated.getAll( "ports" ) |
| 232 | links = main.topoRelated.getAll( "links" ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 233 | mnSwitches = main.Mininet1.getSwitches() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 234 | mnLinks = main.Mininet1.getLinks( timeout=180 ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 235 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 236 | for controller in range( len( main.Cluster.active() ) ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 237 | currentDevicesResult = main.topoRelated.compareDevicePort( |
| 238 | main.Mininet1, controller, |
| 239 | mnSwitches, |
| 240 | devices, ports ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 241 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 242 | currentLinksResult = main.topoRelated.compareBase( links, controller, |
| 243 | main.Mininet1.compareLinks, |
| 244 | [ mnSwitches, mnLinks ] ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 245 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 246 | stepResult = stepResult and currentDevicesResult and currentLinksResult |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 247 | if stepResult: |
| 248 | break |
| 249 | compareRetry += 1 |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 250 | utilities.assert_equals( expect=main.TRUE, |
| 251 | actual=stepResult, |
| 252 | onpass=" Topology match Mininet", |
| 253 | onfail="ONOS Topology doesn't match Mininet") |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 254 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 255 | if stepResult: |
| 256 | if main.hostDiscover: |
| 257 | hostList = [] |
| 258 | for i in range( 1, int( main.currScale ) + 1 ): |
| 259 | for j in range( 1, int( main.currScale ) + 1) : |
| 260 | # Generate host list |
| 261 | hoststr = "h" + str(i) + "x" + str(j) |
| 262 | hostList.append(hoststr) |
| 263 | for i in range( len(hostList) ): |
| 264 | totalHost = main.topo.sendArpPackage( main, hostList[i] ) |
| 265 | time.sleep( main.hostDiscoverSleep ) |
| 266 | if totalHost < 0: |
| 267 | # if totalHost less than 0 which means dependence function has exception. |
| 268 | main.log.info( "Error when discover host!" ) |
| 269 | break |
| 270 | if totalHost == int( main.currScale ) * int( main.currScale ): |
| 271 | main.log.info( "Discovered all hosts" ) |
You Wang | 7bb9c46 | 2016-08-10 14:18:16 -0700 | [diff] [blame] | 272 | stepResult = stepResult and main.TRUE |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 273 | else: |
| 274 | main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" ) |
You Wang | 7bb9c46 | 2016-08-10 14:18:16 -0700 | [diff] [blame] | 275 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 276 | utilities.assert_equals( expect=main.TRUE, |
| 277 | actual=stepResult, |
| 278 | onpass=" Topology match Mininet", |
| 279 | onfail="ONOS Topology doesn't match Mininet") |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 280 | main.log.info( "Finished this iteration, continue to scale next topology." ) |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 281 | else: |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 282 | main.log.info( "Clean up and exit TestON. Finished this test." ) |
| 283 | main.cleanup() |
| 284 | main.exit() |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 285 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 286 | def CASE100( self, main ): |
| 287 | ''' |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 288 | Bring Down node 3 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 289 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 290 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 291 | main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale)) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 292 | main.caseExplanation = "Balance masters to make sure " +\ |
| 293 | "each controller has some devices and " +\ |
| 294 | "stop ONOS node 3 service. " |
| 295 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 296 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 297 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 298 | # Always bring down the third node |
| 299 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 300 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 301 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 302 | main.log.info( "Stopping node %s" % node ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 303 | stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 304 | main.log.info( "Removing dead node from list of active nodes" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 305 | main.Cluster.runningNodes[ main.deadNode ].active = False |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 306 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 307 | utilities.assert_equals( expect=main.TRUE, |
| 308 | actual=stepResult, |
| 309 | onpass="Successfully bring down node 3", |
| 310 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 311 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 312 | def CASE200( self, main ): |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 313 | ''' |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 314 | Bring up onos node |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 315 | ''' |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 316 | |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 317 | main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale)) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 318 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 319 | ctrl = main.Cluster.runningNodes[ main.deadNode ] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 320 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 321 | main.log.info( "Starting node %s" % node ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 322 | stepResult = main.ONOSbench.onosStart( ctrl.ipAddress ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 323 | main.log.info( "Starting onos cli" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 324 | stepResult = stepResult and \ |
| 325 | ctrl.CLI.startOnosCli( ctrl.ipAddress ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 326 | main.log.info( "Adding previously dead node to list of active nodes" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 327 | ctrl.active = True |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 328 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 329 | utilities.assert_equals( expect=main.TRUE, |
| 330 | actual=stepResult, |
| 331 | onpass="Successfully brought up onos node %s" % node, |
| 332 | onfail="Failed to bring up onos node %s" % node ) |
| 333 | |
| 334 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 335 | time.sleep(main.nodeSleep) |
| 336 | |
| 337 | def CASE300( self, main ): |
| 338 | ''' |
| 339 | |
| 340 | Balancing Masters |
| 341 | ''' |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 342 | time.sleep(main.balanceSleep) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 343 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 344 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 345 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 346 | if main.Cluster.active(): |
| 347 | stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters, |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 348 | main.FALSE, |
| 349 | [], |
| 350 | sleep=3, |
| 351 | attempts=3 ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 352 | else: |
| 353 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 354 | utilities.assert_equals( expect=main.TRUE, |
| 355 | actual=stepResult, |
| 356 | onpass="Balance masters was successfull", |
| 357 | onfail="Failed to balance masters") |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 358 | time.sleep( main.balanceSleep ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 359 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 360 | def CASE1000( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 361 | ''' |
| 362 | Report errors/warnings/exceptions |
| 363 | ''' |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 364 | # Compare the slowest Node through total time of each node |
| 365 | slowestNode = 0 |
| 366 | slowestTotalTime = 0 |
| 367 | # Second capture |
| 368 | for i in range( 3 ): |
| 369 | # Calculate total time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 370 | main.allinfo[ 1 ][ 'info' + str( i )][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 371 | main.searchTerm[ 'start' ], |
| 372 | 'first', |
| 373 | main.searchTerm[ 'end' ], |
| 374 | 'last', |
| 375 | index=i, |
| 376 | funcMode='TD' ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 377 | # Compare the total time |
| 378 | if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime: |
| 379 | slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] |
| 380 | slowestNode = i |
| 381 | # Calculate switch connection time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 382 | main.allinfo[ 1 ][ 'info' + str( i )][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 383 | main.searchTerm[ 'start' ], |
| 384 | 'first', |
| 385 | main.searchTerm[ 'start' ], |
| 386 | 'last', |
| 387 | index=i, |
| 388 | funcMode='TD' ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 389 | # Calculate the time from last switch connection to the last role request |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 390 | main.allinfo[ 1 ][ 'info' + str( i )][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, |
| 391 | main.searchTerm[ 'start' ], |
| 392 | 'last', |
| 393 | index=i ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 394 | # Calculate the time from the last role request to the last topology |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 395 | main.allinfo[ 1 ][ 'info' + str( i )][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, |
| 396 | main.searchTerm[ 'end' ], |
| 397 | 'last', |
| 398 | index=i ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 399 | # Calculate the disconnecti rate |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 400 | main.allinfo[ 1 ][ 'info' + str( i )][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 401 | main.searchTerm[ 'Disconnect' ], |
| 402 | 'num', |
| 403 | main.searchTerm[ 'start' ], |
| 404 | 'num', |
| 405 | index=i, |
| 406 | funcMode='DR' ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 407 | |
| 408 | if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ): |
| 409 | main.log.error( "The results of two capture are different!" ) |
| 410 | main.log.debug( "The data is " + str( main.allinfo ) ) |
| 411 | if main.writeData != -1: |
| 412 | main.log.info( "Write the date into database" ) |
| 413 | # write the date into data base |
| 414 | with open( main.dbFilePath, "a" ) as dbFile: |
| 415 | temp = str( main.currScale ) |
| 416 | temp += ",'baremetal1'" |
| 417 | # put result from second capture into data base |
| 418 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'totalTime' ] ) |
| 419 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'swConnection' ] ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 420 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastSwToLastRr' ] ) |
| 421 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'lastRrToLastTopology' ] ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 422 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode )][ 'disconnectRate' ] ) |
| 423 | temp += "\n" |
| 424 | dbFile.write( temp ) |
| 425 | else: |
| 426 | main.log.error( "The data from log is wrong!" ) |
| 427 | main.writeData = 1 |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 428 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 429 | main.log.info( "Error report: \n" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 430 | main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 431 | [ "INFO", |
| 432 | "FOLLOWER", |
| 433 | "WARN", |
| 434 | "flow", |
| 435 | "ERROR", |
| 436 | "Except" ], |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 437 | "s" ) |