Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2015 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 21 | # Testing network scalability, this test suite scales up a network topology |
| 22 | # using mininet and verifies ONOS stability |
| 23 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 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" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 47 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 48 | main.testSetUp.envSetupDescription() |
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 | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 77 | main.basicMNTime = int( main.params[ 'TIMEOUT' ][ 'basicMininet' ] ) |
| 78 | main.startNetTime = int( main.params[ 'TIMEOUT' ][ 'startNet' ] ) |
| 79 | main.stopNetTime = int( main.params[ 'TIMEOUT' ][ 'stopNet' ] ) |
| 80 | main.MNupdateTime = int( main.params[ 'TIMEOUT' ][ 'update' ] ) |
| 81 | main.MNLinksTime = int( main.params[ 'TIMEOUT' ][ 'links' ] ) |
| 82 | main.currScale = None |
| 83 | main.threadID = 0 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 84 | if main.hostDiscover == 'True': |
| 85 | main.hostDiscover = True |
| 86 | else: |
| 87 | main.hostDiscover = False |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 88 | main.homeDir = os.path.expanduser( '~' ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 89 | main.hostsData = {} |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 90 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 91 | stepResult = main.testSetUp.envSetup() |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 92 | main.allinfo = {} # The dictionary to record all the data from karaf.log |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 93 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 94 | for i in range( 2 ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 95 | main.allinfo[ i ] = {} |
| 96 | for w in range( 3 ): |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 97 | # Totaltime: the time from the new switchConnection to its end |
| 98 | # swConnection: the time from the first new switchConnection to the last new switchConnection |
| 99 | # lastSwToLastRr: the time from the last new switchConnection to the last role request |
| 100 | # lastRrToLastTopology: the time form the last role request to the last topology |
| 101 | # disconnectRate: the rate that shows how many switch disconnect after connection |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 102 | 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] | 103 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 104 | main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ] |
| 105 | main.log.info( "Create Database file " + main.dbFilePath ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 106 | resultDB = open( main.dbFilePath, 'w+' ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 107 | resultDB.close() |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 108 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 109 | main.scaleTopoFunction = imp.load_source( wrapperFile2, |
| 110 | main.dependencyPath + |
| 111 | wrapperFile2 + |
| 112 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 113 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 114 | main.topo = imp.load_source( wrapperFile3, |
| 115 | main.dependencyPath + |
| 116 | wrapperFile3 + |
| 117 | ".py" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 118 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 119 | main.ONOSbench.scp( main.Mininet1, |
| 120 | main.dependencyPath + |
| 121 | main.multiovs, |
| 122 | main.Mininet1.home, |
| 123 | direction="to" ) |
| 124 | except Exception as e: |
| 125 | main.testSetUp.envSetupException( e ) |
| 126 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 127 | main.commit = main.commit.split( " " )[ 1 ] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 128 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 129 | def CASE2( self, main ): |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 130 | """ |
| 131 | - Set up cell |
| 132 | - Create cell file |
| 133 | - Set cell file |
| 134 | - Verify cell file |
| 135 | - Kill ONOS process |
| 136 | - Uninstall ONOS cluster |
| 137 | - Verify ONOS start up |
| 138 | - Install ONOS cluster |
| 139 | - Connect to cli |
| 140 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 141 | import time |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 142 | main.testSetUp.ONOSSetUp( main.Cluster ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 143 | |
| 144 | def CASE3( self, main ): |
| 145 | """ |
| 146 | cleanup mininet. |
| 147 | """ |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 148 | try: |
| 149 | from tests.dependencies.utils import Utils |
| 150 | except ImportError: |
| 151 | main.log.error( "Utils not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 152 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 153 | try: |
| 154 | main.Utils |
| 155 | except ( NameError, AttributeError ): |
| 156 | main.Utils = Utils() |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 157 | main.Utils.mininetCleanup( main.Mininet1, exitTimeout=main.basicMNTime + ( int( main.currScale ) if main.currScale is not None |
| 158 | else 1 ) * main.stopNetTime ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 159 | |
| 160 | def CASE10( self, main ): |
| 161 | """ |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 162 | Starting up torus topology |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 163 | """ |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 164 | main.case( "Starting up Mininet and verifying topology" ) |
| 165 | main.caseExplanation = "Starting Mininet with a scalling topology and " +\ |
| 166 | "comparing topology elements between Mininet and ONOS" |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 167 | if main.topoScale: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 168 | main.currScale = main.topoScale.pop( 0 ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 169 | else: |
| 170 | main.log.error( "topology scale is empty" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 171 | main.step( "Starting up TORUS %sx%s topology" % ( main.currScale, main.currScale ) ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 172 | |
| 173 | main.log.info( "Constructing Mininet command" ) |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 174 | mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \ |
| 175 | " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 176 | for ctrl in main.Cluster.runningNodes: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 177 | mnCmd += " --controller remote,ip=" + ctrl.ipAddress |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 178 | stepResult = main.Mininet1.startNet( mnCmd=mnCmd, timeout=( main.basicMNTime + int( main.currScale ) * main.startNetTime ) ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 179 | utilities.assert_equals( expect=main.TRUE, |
| 180 | actual=stepResult, |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 181 | onpass=main.topoName + |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 182 | " topology started successfully", |
| 183 | onfail=main.topoName + |
| 184 | " topology failed to start" ) |
| 185 | |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 186 | time.sleep( main.MNSleep ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 187 | main.log.info( "Clean up Tshark" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 188 | with open( main.tsharkResultPath, "w" ) as tshark: |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 189 | tshark.write( "" ) |
| 190 | main.log.info( "Starting Tshark capture" ) |
| 191 | main.ONOSbench.tsharkGrep( main.roleRequest, main.tsharkResultPath, grepOptions='-E' ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 192 | main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.openflow" ) |
Chiyu Cheng | 8149942 | 2016-11-09 11:04:23 -0800 | [diff] [blame] | 193 | time.sleep( main.MNSleep ) |
Chiyu Cheng | 899621b | 2016-11-14 11:14:48 -0800 | [diff] [blame] | 194 | main.log.info( "Stop Tshark" ) |
| 195 | main.ONOSbench.tsharkStop() |
| 196 | main.log.info( "Get role request time" ) |
| 197 | with open( main.tsharkResultPath, "r" ) as resultFile: |
| 198 | resultText = resultFile.readlines() |
| 199 | resultFile.close() |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 200 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 201 | def CASE11( self, main ): |
| 202 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 203 | Compare topo, and sending Arping package |
YPZhang | 85024fc | 2016-02-09 16:59:27 -0800 | [diff] [blame] | 204 | if the topology is same, then Pass. |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 205 | """ |
| 206 | import json |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 207 | import time |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 208 | try: |
| 209 | from tests.dependencies.topology import Topology |
| 210 | except ImportError: |
| 211 | main.log.error( "Topology not found exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 212 | main.cleanAndExit() |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame] | 213 | try: |
| 214 | main.topoRelated |
| 215 | except ( NameError, AttributeError ): |
| 216 | main.topoRelated = Topology() |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 217 | # First capture |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 218 | |
| 219 | main.postResult = True |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 220 | main.step( "Grep information from the ONOS log" ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 221 | for i in range( 3 ): |
| 222 | # Calculate total time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 223 | 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] | 224 | # Calculate switch connection time |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 225 | 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] | 226 | # Calculate the time from last switch connection to the last role request |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 227 | 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] | 228 | # Calculate the time from the last role request to the last topology |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 229 | 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] | 230 | # Calculate the disconnecti rate |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 231 | 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] | 232 | main.log.debug( "The data is " + str( main.allinfo[ 0 ] ) ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 233 | if -1 in main.allinfo[ 0 ][ 'info0' ].values() or -1 in main.allinfo[ 0 ][ 'info1' ].values() or -1 in main.allinfo[ 0 ][ 'info2' ].values(): |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 234 | utilities.assert_equals( expect=main.TRUE, |
| 235 | actual=main.FALSE, |
| 236 | onpass="Everything installed properly to the ONOS.", |
| 237 | onfail="Something happened to ONOS. Skip the rest of the steps." ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 238 | main.postResult = False |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 239 | else: |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 240 | main.case( "Verifying topology: TORUS %sx%s" % ( main.currScale, main.currScale ) ) |
| 241 | main.caseExplanation = "Pinging all hosts and comparing topology " +\ |
| 242 | "elements between Mininet and ONOS" |
| 243 | |
| 244 | main.log.info( "Gathering topology information" ) |
| 245 | time.sleep( main.MNSleep ) |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 246 | |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 247 | compareRetry = 0 |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 248 | main.step( "Checking if ONOS is stable" ) |
| 249 | main.scaleTopoFunction.checkingONOSStablility( main ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 250 | |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 251 | if main.postResult: |
| 252 | main.step( "Comparing MN topology to ONOS topology" ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 253 | |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 254 | compareRetry = 0 |
| 255 | while compareRetry < 2: |
| 256 | stepResult = main.TRUE |
| 257 | currentDevicesResult = main.TRUE |
| 258 | currentLinksResult = main.TRUE |
| 259 | # While loop for retry |
| 260 | devices = main.topoRelated.getAll( "devices" ) |
| 261 | ports = main.topoRelated.getAll( "ports" ) |
| 262 | links = main.topoRelated.getAll( "links" ) |
| 263 | if None in devices or None in ports or None in links: |
| 264 | main.log.warn( "Something went wrong. Retrying..." ) |
| 265 | time.sleep( 20 ) |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 266 | stepResult = main.FALSE |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 267 | compareRetry += 1 |
| 268 | continue |
| 269 | mnSwitches = main.Mininet1.getSwitches( updateTimeout=main.basicMNTime + int( main.currScale ) * main.MNupdateTime ) |
| 270 | main.log.info( "Comparing switches..." ) |
| 271 | devicePool = [] |
| 272 | for controller in range( len( main.Cluster.active() ) ): |
| 273 | t = main.Thread( target=main.topoRelated.compareDevicePort, |
| 274 | threadID=main.threadID, |
| 275 | name="Compare-Device-Port", |
| 276 | args=[ main.Mininet1, controller, |
| 277 | mnSwitches, |
| 278 | devices, ports ] ) |
| 279 | devicePool.append( t ) |
| 280 | t.start() |
| 281 | main.threadID = main.threadID + 1 |
| 282 | |
| 283 | mnLinks = main.Mininet1.getLinks( timeout=main.basicMNTime + int( main.currScale ) * main.MNLinksTime, |
| 284 | updateTimeout=main.basicMNTime + int(main.currScale) * main.MNupdateTime ) |
| 285 | main.log.info( "Comparing links..." ) |
| 286 | linkPool = [] |
| 287 | for controller in range( len( main.Cluster.active() ) ): |
| 288 | t = main.Thread( target=main.topoRelated.compareBase, |
| 289 | threadID=main.threadID, |
| 290 | name="Compare-Link-Result", |
| 291 | args=[ links, controller, |
| 292 | main.Mininet1.compareLinks, |
| 293 | [ mnSwitches, mnLinks ] ] ) |
| 294 | linkPool.append( t ) |
| 295 | t.start() |
| 296 | main.threadID = main.threadID + 1 |
| 297 | |
| 298 | for t in devicePool: |
| 299 | t.join() |
| 300 | currentDevicesResult = currentDevicesResult and t.result |
| 301 | for t in linkPool: |
| 302 | t.join() |
| 303 | currentLinksResult = currentLinksResult and t.result |
| 304 | stepResult = stepResult and currentDevicesResult and currentLinksResult |
| 305 | if stepResult: |
| 306 | break |
| 307 | compareRetry += 1 |
| 308 | utilities.assert_equals( expect=main.TRUE, |
| 309 | actual=stepResult, |
| 310 | onpass=" Topology match Mininet", |
| 311 | onfail="ONOS Topology doesn't match Mininet" ) |
| 312 | main.scaleTopoFunction.checkingONOSStablility( main ) |
| 313 | if stepResult and main.postResult: |
| 314 | if main.hostDiscover: |
| 315 | hostList = [] |
| 316 | for i in range( 1, int( main.currScale ) + 1 ): |
| 317 | for j in range( 1, int( main.currScale ) + 1 ): |
| 318 | # Generate host list |
| 319 | hoststr = "h" + str( i ) + "x" + str( j ) |
| 320 | hostList.append( hoststr ) |
| 321 | for i in range( len( hostList ) ): |
| 322 | main.topo.sendArpPackage( main, hostList[ i ] ) |
| 323 | time.sleep( 20 ) |
| 324 | totalHost = main.topo.getHostNum( main ) |
| 325 | if totalHost == int( main.currScale ) * int( main.currScale ): |
| 326 | main.log.info( "Discovered all hosts" ) |
| 327 | stepResult = stepResult and main.TRUE |
| 328 | else: |
| 329 | main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" ) |
| 330 | stepResult = main.FALSE |
| 331 | utilities.assert_equals( expect=main.TRUE, |
| 332 | actual=stepResult, |
| 333 | onpass=" Topology match Mininet", |
| 334 | onfail="ONOS Topology doesn't match Mininet" ) |
| 335 | main.log.info( "Finished this iteration, continue to scale next topology." ) |
| 336 | else: |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 337 | utilities.assert_equals( expect=main.TRUE, |
Devin Lim | 4a87b2a | 2017-10-11 18:23:12 -0700 | [diff] [blame] | 338 | actual=main.FALSE, |
| 339 | onpass="ONOS is stable.", |
| 340 | onfail="Something happened to ONOS. Skip the rest of the steps." ) |
| 341 | main.postResult = False |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 342 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 343 | def CASE100( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 344 | """ |
YPZhang | 81a7d4e | 2016-04-18 13:10:17 -0700 | [diff] [blame] | 345 | Bring Down node 3 |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 346 | """ |
| 347 | 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] | 348 | main.caseExplanation = "Balance masters to make sure " +\ |
| 349 | "each controller has some devices and " +\ |
| 350 | "stop ONOS node 3 service. " |
| 351 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 352 | stepResult = main.FALSE |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 353 | main.step( "Bringing down node 3" ) |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 354 | # Always bring down the third node |
| 355 | main.deadNode = 2 |
GlennRC | ed2122e | 2015-10-21 14:38:46 -0700 | [diff] [blame] | 356 | # Printing purposes |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 357 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 358 | main.log.info( "Stopping node %s" % node ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 359 | stepResult = main.ONOSbench.onosStop( main.Cluster.active( main.deadNode ).ipAddress ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 360 | main.log.info( "Removing dead node from list of active nodes" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 361 | main.Cluster.runningNodes[ main.deadNode ].active = False |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 362 | |
YPZhang | 77badfc | 2016-03-09 10:28:59 -0800 | [diff] [blame] | 363 | utilities.assert_equals( expect=main.TRUE, |
| 364 | actual=stepResult, |
| 365 | onpass="Successfully bring down node 3", |
| 366 | onfail="Failed to bring down node 3" ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 367 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 368 | def CASE200( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 369 | """ |
YPZhang | acaaf42 | 2016-07-26 09:34:03 -0700 | [diff] [blame] | 370 | Bring up onos node |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 371 | """ |
| 372 | 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] | 373 | main.caseExplanation = "Bring node 3 back up and balance the masters" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 374 | ctrl = main.Cluster.runningNodes[ main.deadNode ] |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 375 | node = main.deadNode + 1 |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 376 | main.log.info( "Starting node %s" % node ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 377 | stepResult = main.ONOSbench.onosStart( ctrl.ipAddress ) |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 378 | main.log.info( "Starting onos cli" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 379 | stepResult = stepResult and \ |
| 380 | ctrl.CLI.startOnosCli( ctrl.ipAddress ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 381 | main.log.info( "Adding previously dead node to list of active nodes" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 382 | ctrl.active = True |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 383 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 384 | utilities.assert_equals( expect=main.TRUE, |
| 385 | actual=stepResult, |
| 386 | onpass="Successfully brought up onos node %s" % node, |
| 387 | onfail="Failed to bring up onos node %s" % node ) |
| 388 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 389 | time.sleep( main.nodeSleep ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 390 | |
| 391 | def CASE300( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 392 | """ |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 393 | Balancing Masters |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 394 | """ |
| 395 | time.sleep( main.balanceSleep ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 396 | main.step( "Balancing Masters" ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 397 | |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 398 | stepResult = main.FALSE |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 399 | if main.Cluster.active(): |
| 400 | stepResult = utilities.retry( main.Cluster.next().CLI.balanceMasters, |
YPZhang | 924ccfe | 2016-01-26 14:17:30 -0800 | [diff] [blame] | 401 | main.FALSE, |
| 402 | [], |
| 403 | sleep=3, |
| 404 | attempts=3 ) |
GlennRC | e283c4b | 2016-01-07 13:04:10 -0800 | [diff] [blame] | 405 | else: |
| 406 | main.log.error( "List of active nodes is empty" ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 407 | utilities.assert_equals( expect=main.TRUE, |
| 408 | actual=stepResult, |
| 409 | onpass="Balance masters was successfull", |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 410 | onfail="Failed to balance masters" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 411 | time.sleep( main.balanceSleep ) |
GlennRC | 475f50d | 2015-10-23 15:01:09 -0700 | [diff] [blame] | 412 | |
GlennRC | 632e289 | 2015-10-19 18:58:41 -0700 | [diff] [blame] | 413 | def CASE1000( self, main ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 414 | """ |
kelvin-onlab | 1d381fe | 2015-07-14 16:24:56 -0700 | [diff] [blame] | 415 | Report errors/warnings/exceptions |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 416 | """ |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 417 | # Compare the slowest Node through total time of each node |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 418 | if main.postResult: |
| 419 | slowestNode = 0 |
| 420 | slowestTotalTime = 0 |
| 421 | # Second capture |
| 422 | for i in range( 3 ): |
| 423 | # Calculate total time |
| 424 | main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 425 | main.searchTerm[ 'start' ], |
| 426 | 'first', |
| 427 | main.searchTerm[ 'end' ], |
| 428 | 'last', |
| 429 | index=i, |
| 430 | funcMode='TD' ) |
| 431 | # Compare the total time |
| 432 | if main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] > slowestTotalTime: |
| 433 | slowestTotalTime = main.allinfo[ 1 ][ 'info' + str( i ) ][ 'totalTime' ] |
| 434 | slowestNode = i |
| 435 | # Calculate switch connection time |
| 436 | main.allinfo[ 1 ][ 'info' + str( i ) ][ 'swConnection' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 437 | main.searchTerm[ 'start' ], |
| 438 | 'first', |
| 439 | main.searchTerm[ 'start' ], |
| 440 | 'last', |
| 441 | index=i, |
| 442 | funcMode='TD' ) |
| 443 | # Calculate the time from last switch connection to the last role request |
| 444 | main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastSwToLastRr' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, |
| 445 | main.searchTerm[ 'start' ], |
| 446 | 'last', |
| 447 | index=i ) |
| 448 | # Calculate the time from the last role request to the last topology |
| 449 | main.allinfo[ 1 ][ 'info' + str( i ) ][ 'lastRrToLastTopology' ] = main.scaleTopoFunction.compareTimeDiffWithRoleRequest( main, |
| 450 | main.searchTerm[ 'end' ], |
| 451 | 'last', |
| 452 | index=i ) |
| 453 | # Calculate the disconnecti rate |
| 454 | main.allinfo[ 1 ][ 'info' + str( i ) ][ 'disconnectRate' ] = main.scaleTopoFunction.getInfoFromLog( main, |
| 455 | main.searchTerm[ 'Disconnect' ], |
| 456 | 'num', |
| 457 | main.searchTerm[ 'start' ], |
| 458 | 'num', |
| 459 | index=i, |
| 460 | funcMode='DR' ) |
Chiyu Cheng | b8c2c84 | 2016-10-05 12:40:49 -0700 | [diff] [blame] | 461 | |
Devin Lim | a7cfdbd | 2017-09-29 15:02:22 -0700 | [diff] [blame] | 462 | if ( main.allinfo[ 0 ] != main.allinfo[ 1 ] ): |
| 463 | main.log.error( "The results of two capture are different!" ) |
| 464 | main.log.debug( "The data is " + str( main.allinfo ) ) |
| 465 | if main.writeData != -1: |
| 466 | main.log.info( "Write the date into database" ) |
| 467 | # write the date into data base |
| 468 | with open( main.dbFilePath, "a" ) as dbFile: |
| 469 | temp = str( main.currScale ) |
| 470 | temp += ",'baremetal1'" |
| 471 | # put result from second capture into data base |
| 472 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'totalTime' ] ) |
| 473 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'swConnection' ] ) |
| 474 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastSwToLastRr' ] ) |
| 475 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'lastRrToLastTopology' ] ) |
| 476 | temp += "," + str( "%.2f" % main.allinfo[ 1 ][ 'info' + str( slowestNode ) ][ 'disconnectRate' ] ) |
| 477 | temp += "\n" |
| 478 | dbFile.write( temp ) |
| 479 | else: |
| 480 | main.log.error( "The data from log is wrong!" ) |
| 481 | main.writeData = 1 |
| 482 | main.case( "Checking logs for errors, warnings, and exceptions" ) |
| 483 | main.log.info( "Error report: \n" ) |
| 484 | main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
| 485 | [ "INFO", |
| 486 | "FOLLOWER", |
| 487 | "WARN", |
| 488 | "flow", |
| 489 | "ERROR", |
| 490 | "Except" ], |
| 491 | "s" ) |