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