blob: 35998067c54ddfb0118afecc0cfb3cacedb87881 [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or 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"""
21
YPZhangcbc2a062016-07-11 10:55:44 -070022'''
23SCPFintentEventTp
24 - Use intentperf app to generate a lot of intent install and withdraw events
25 - Test will run with 1,3,5,7 nodes, and with all neighbors
26 - Test will run 400 seconds and grep the overall rate from intent-perf summary
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080027
YPZhangcbc2a062016-07-11 10:55:44 -070028 yunpeng@onlab.us
29'''
30
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070031import time
andrew@onlab.us10332202015-03-11 15:04:43 -070032
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080033
suibin7f2c9cd2015-07-08 17:34:59 -070034class SCPFintentEventTp:
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080035 def __init__( self ):
36 self.default = ''
37
YPZhangcbc2a062016-07-11 10:55:44 -070038 def CASE0( self, main ):
39 '''
40 - GIT
41 - BUILDING ONOS
42 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
43 This step is usually skipped. Because in a Jenkins driven automated
44 test env. We want Jenkins jobs to pull&build for flexibility to handle
45 different versions of ONOS.
46 - Construct tests variables
47 '''
Devin Lim58046fa2017-07-05 16:55:00 -070048 try:
49 from tests.dependencies.ONOSSetup import ONOSSetup
50 main.testSetUp = ONOSSetup()
51 except ImportError:
52 main.log.error( "ONOSSetup not found. exiting the test" )
53 main.exit()
54 main.testSetUp.envSetupDescription()
55 stepResult = main.FALSE
56 try:
Devin Lim142b5342017-07-20 15:22:39 -070057 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
Devin Lim58046fa2017-07-05 16:55:00 -070058 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
59 main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
60 main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
61 main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
Devin Lim142b5342017-07-20 15:22:39 -070062 main.numSwitches = ( main.params[ 'TEST' ][ 'numSwitches' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070063 main.skipRelRsrc = main.params[ 'TEST' ][ 'skipReleaseResourcesOnWithdrawal' ]
64 main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
65 main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
66 main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
67 main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
Devin Lim142b5342017-07-20 15:22:39 -070068 main.scale = ( main.params[ 'SCALE' ] ).split( "," )
Devin Lim58046fa2017-07-05 16:55:00 -070069 main.testDuration = main.params[ 'TEST' ][ 'duration' ]
70 main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
71 main.debug = main.params[ 'debugMode' ]
Devin Lim142b5342017-07-20 15:22:39 -070072 main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ]
73 main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
74 main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
75 main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ]
76 main.intentPerfInstallerCfg = main.params[ 'CFG' ][ 'intentPerfInstaller' ]
Devin Lim58046fa2017-07-05 16:55:00 -070077 main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
78 main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
79 if main.flowObj == "True":
80 main.flowObj = True
81 main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
82 main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ]
83 else:
84 main.flowObj = False
85 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
86 main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070087
Devin Lim142b5342017-07-20 15:22:39 -070088 stepResult = main.testSetUp.envSetup()
Devin Lim58046fa2017-07-05 16:55:00 -070089 # Create DataBase file
90 main.log.info( "Create Database file " + main.dbFileName )
91 resultsDB = open( main.dbFileName, "w+" )
92 resultsDB.close()
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070093
Devin Lim58046fa2017-07-05 16:55:00 -070094 # set neighbors
95 main.neighbors = "1"
96 except Exception as e:
97 main.testSetUp.envSetupException( e )
98 main.testSetUp.evnSetupConclusion( stepResult )
99 main.commit = main.commit.split( " " )[ 1 ]
cameron@onlab.us412e9562015-05-13 16:04:34 -0700100
YPZhangcbc2a062016-07-11 10:55:44 -0700101 def CASE1( self, main ):
102 # Clean up test environment and set up
103 import time
YPZhangcbc2a062016-07-11 10:55:44 -0700104 main.maxNumBatch = 0
Devin Lim142b5342017-07-20 15:22:39 -0700105 main.testSetUp.ONOSSetUp( main.MN1Ip, main.Cluster, True,
106 cellName=main.cellName, killRemoveMax=False )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700107
YPZhangcbc2a062016-07-11 10:55:44 -0700108 # config apps
Devin Lim142b5342017-07-20 15:22:39 -0700109 main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg,
110 "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc )
111 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
112 "deviceCount " + str( int( main.Cluster.numCtrls * 10 ) ) )
113 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "topoShape linear" )
114 main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "enabled true" )
YPZhange6ef82a2016-07-05 16:48:15 -0700115 if main.flowObj:
Devin Lim142b5342017-07-20 15:22:39 -0700116 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg(),
117 "useFlowObjectives", value="true" )
118 main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg(),
119 "defaultFlowObjectiveCompiler",
120 value=main.linkCollectionIntentCfg )
YPZhangcbc2a062016-07-11 10:55:44 -0700121 time.sleep( main.startUpSleep )
cameron@onlab.useae03dc2015-07-29 11:51:28 -0700122
YPZhangcbc2a062016-07-11 10:55:44 -0700123 # balanceMasters
Devin Lim142b5342017-07-20 15:22:39 -0700124 main.Cluster.active( 0 ).CLI.balanceMasters()
YPZhangcbc2a062016-07-11 10:55:44 -0700125 time.sleep( main.startUpSleep )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700126
Devin Lim142b5342017-07-20 15:22:39 -0700127 def CASE2( self, main ):
jenkins3af0cd82015-03-24 10:27:16 -0700128 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700129
Devin Lim142b5342017-07-20 15:22:39 -0700130 main.log.info( "Cluster Count = " + str( main.Cluster.numCtrls ) )
YPZhangcbc2a062016-07-11 10:55:44 -0700131 # adjust neighbors
Devin Lim142b5342017-07-20 15:22:39 -0700132 if main.Cluster.numCtrls == 1:
YPZhangcbc2a062016-07-11 10:55:44 -0700133 main.neighbors = "0"
134 main.log.info( "Neighbors: 0" )
135 elif main.neighbors != "0":
136 main.neighbors = "0"
137 main.log.info( "Neighbors: 0" )
138 elif main.neighbors == "0":
Devin Lim142b5342017-07-20 15:22:39 -0700139 main.neighbors = str( main.Cluster.numCtrls - 1 )
YPZhangcbc2a062016-07-11 10:55:44 -0700140 main.log.info( "Neighbors: " + main.neighbors )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700141
YPZhangcbc2a062016-07-11 10:55:44 -0700142 main.log.info( "Config intent-perf app" )
Devin Lim142b5342017-07-20 15:22:39 -0700143 main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
144 "numKeys " + main.numKeys )
145 main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
146 "numNeighbors " + str( main.neighbors ) )
147 main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
148 "cyclePeriod " + main.cyclePeriod )
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700149
Devin Lim142b5342017-07-20 15:22:39 -0700150 main.log.info( "Starting intent-perf test for " + str( main.testDuration ) + " seconds..." )
151 main.Cluster.active( 0 ).CLI.sendline( "intent-perf-start" )
YPZhangcbc2a062016-07-11 10:55:44 -0700152 stop = time.time() + float( main.testDuration )
andrew@onlab.us10332202015-03-11 15:04:43 -0700153
YPZhangcbc2a062016-07-11 10:55:44 -0700154 while time.time() < stop:
Devin Lim142b5342017-07-20 15:22:39 -0700155 time.sleep( 15 )
156 result = main.Cluster.active( 0 ).CLI.getIntentPerfSummary()
YPZhangcbc2a062016-07-11 10:55:44 -0700157 if result:
Devin Lim142b5342017-07-20 15:22:39 -0700158 for ctrl in main.Cluster.active():
159 main.log.info( "Node {} Overall Rate: {}".format( ctrl.ipAddress,
160 result[ ctrl.ipAddress ] ) )
YPZhangcbc2a062016-07-11 10:55:44 -0700161 main.log.info( "Stop intent-perf" )
Devin Lim142b5342017-07-20 15:22:39 -0700162 for ctrl in main.Cluster.active():
163 ctrl.CLI.sendline( "intent-perf-stop" )
YPZhangcbc2a062016-07-11 10:55:44 -0700164 if result:
Devin Lim142b5342017-07-20 15:22:39 -0700165 for ctrl in main.Cluster.active():
166 main.log.info( "Node {} final Overall Rate: {}".format( ctrl.ipAddress,
167 result[ ctrl.ipAddress ] ) )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800168
YPZhangcbc2a062016-07-11 10:55:44 -0700169 with open( main.dbFileName, "a" ) as resultDB:
Devin Lim142b5342017-07-20 15:22:39 -0700170 for nodes in range( main.Cluster.numCtrls ):
YPZhangcbc2a062016-07-11 10:55:44 -0700171 resultString = "'" + main.commit + "',"
172 resultString += "'1gig',"
Devin Lim142b5342017-07-20 15:22:39 -0700173 resultString += str( main.Cluster.numCtrls ) + ","
174 resultString += "'baremetal" + str( nodes + 1 ) + "',"
YPZhangcbc2a062016-07-11 10:55:44 -0700175 resultString += main.neighbors + ","
Devin Lim142b5342017-07-20 15:22:39 -0700176 resultString += result[ main.Cluster.active( nodes ).ipAddress ] + ","
177 resultString += str( 0 ) + "\n" # no stddev
YPZhangcbc2a062016-07-11 10:55:44 -0700178 resultDB.write( resultString )
179 resultDB.close()