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