YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 1 | ''' |
| 2 | SCPFintentEventTp |
| 3 | - Use intentperf app to generate a lot of intent install and withdraw events |
| 4 | - Test will run with 1,3,5,7 nodes, and with all neighbors |
| 5 | - Test will run 400 seconds and grep the overall rate from intent-perf summary |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 6 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 7 | yunpeng@onlab.us |
| 8 | ''' |
| 9 | |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 10 | import time |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 11 | |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 12 | |
suibin | 7f2c9cd | 2015-07-08 17:34:59 -0700 | [diff] [blame] | 13 | class SCPFintentEventTp: |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 14 | def __init__( self ): |
| 15 | self.default = '' |
| 16 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 17 | def CASE0( self, main ): |
| 18 | ''' |
| 19 | - GIT |
| 20 | - BUILDING ONOS |
| 21 | Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| 22 | This step is usually skipped. Because in a Jenkins driven automated |
| 23 | test env. We want Jenkins jobs to pull&build for flexibility to handle |
| 24 | different versions of ONOS. |
| 25 | - Construct tests variables |
| 26 | ''' |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 27 | try: |
| 28 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 29 | main.testSetUp = ONOSSetup() |
| 30 | except ImportError: |
| 31 | main.log.error( "ONOSSetup not found. exiting the test" ) |
| 32 | main.exit() |
| 33 | main.testSetUp.envSetupDescription() |
| 34 | stepResult = main.FALSE |
| 35 | try: |
| 36 | main.cellName = main.params[ 'ENV'][ 'cellName'] |
| 37 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 38 | main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 39 | main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| 40 | main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| 41 | main.maxNodes = int( main.params[ 'max' ] ) |
| 42 | main.numSwitches = ( main.params[ 'TEST' ][ 'numSwitches' ] ).split(",") |
| 43 | main.skipRelRsrc = main.params[ 'TEST' ][ 'skipReleaseResourcesOnWithdrawal' ] |
| 44 | main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
| 45 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| 46 | main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| 47 | main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| 48 | main.scale = ( main.params[ 'SCALE' ] ).split(",") |
| 49 | main.testDuration = main.params[ 'TEST' ][ 'duration' ] |
| 50 | main.logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| 51 | main.debug = main.params[ 'debugMode' ] |
| 52 | main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| 53 | main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ] |
| 54 | if main.flowObj == "True": |
| 55 | main.flowObj = True |
| 56 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| 57 | main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ] |
| 58 | else: |
| 59 | main.flowObj = False |
| 60 | main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
| 61 | main.numKeys = main.params[ 'TEST' ][ 'numKeys' ] |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 62 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 63 | stepResult = main.testSetUp.gitPulling() |
| 64 | # Create DataBase file |
| 65 | main.log.info( "Create Database file " + main.dbFileName ) |
| 66 | resultsDB = open( main.dbFileName, "w+" ) |
| 67 | resultsDB.close() |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 68 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 69 | # set neighbors |
| 70 | main.neighbors = "1" |
| 71 | except Exception as e: |
| 72 | main.testSetUp.envSetupException( e ) |
| 73 | main.testSetUp.evnSetupConclusion( stepResult ) |
| 74 | main.commit = main.commit.split( " " )[ 1 ] |
cameron@onlab.us | 412e956 | 2015-05-13 16:04:34 -0700 | [diff] [blame] | 75 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 76 | def CASE1( self, main ): |
| 77 | # Clean up test environment and set up |
| 78 | import time |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 79 | main.maxNumBatch = 0 |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 80 | main.testSetUp.getNumCtrls( True ) |
| 81 | main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False ) |
| 82 | main.testSetUp.ONOSSetUp( main.MN1Ip, True, |
| 83 | cellName=main.cellName, killRemoveMax=False, |
| 84 | CtrlsSet=False ) |
cameron@onlab.us | 059c256 | 2015-04-02 14:12:51 -0700 | [diff] [blame] | 85 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 86 | # config apps |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 87 | main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager", |
| 88 | "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 89 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int( main.numCtrls*10)) ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 90 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" ) |
| 91 | main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" ) |
YPZhang | e6ef82a | 2016-07-05 16:48:15 -0700 | [diff] [blame] | 92 | if main.flowObj: |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 93 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 94 | "useFlowObjectives", value="true") |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 95 | main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| 96 | "defaultFlowObjectiveCompiler", |
| 97 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 98 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | eae03dc | 2015-07-29 11:51:28 -0700 | [diff] [blame] | 99 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 100 | # balanceMasters |
| 101 | main.CLIs[0].balanceMasters() |
| 102 | time.sleep( main.startUpSleep ) |
cameron@onlab.us | aaecfd7 | 2015-07-08 12:27:26 -0700 | [diff] [blame] | 103 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 104 | def CASE2(self, main): |
jenkins | 3af0cd8 | 2015-03-24 10:27:16 -0700 | [diff] [blame] | 105 | import numpy |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 106 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 107 | main.log.info( "Cluster Count = " + str( main.numCtrls ) ) |
| 108 | # adjust neighbors |
| 109 | if main.numCtrls == 1: |
| 110 | main.neighbors = "0" |
| 111 | main.log.info( "Neighbors: 0" ) |
| 112 | elif main.neighbors != "0": |
| 113 | main.neighbors = "0" |
| 114 | main.log.info( "Neighbors: 0" ) |
| 115 | elif main.neighbors == "0": |
| 116 | main.neighbors = str( main.numCtrls - 1 ) |
| 117 | main.log.info( "Neighbors: " + main.neighbors ) |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 118 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 119 | main.log.info( "Config intent-perf app" ) |
| 120 | main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numKeys " + main.numKeys ) |
| 121 | main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) ) |
| 122 | main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod ) |
cameron@onlab.us | c10e22c | 2015-05-13 13:07:28 -0700 | [diff] [blame] | 123 | |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 124 | main.log.info( "Starting intent-perf test for " + str( main.testDuration) + " seconds..." ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 125 | main.CLIs[0].sendline( "intent-perf-start" ) |
| 126 | stop = time.time() + float( main.testDuration ) |
andrew@onlab.us | 1033220 | 2015-03-11 15:04:43 -0700 | [diff] [blame] | 127 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 128 | while time.time() < stop: |
| 129 | time.sleep(15) |
| 130 | result = main.CLIs[0].getIntentPerfSummary() |
| 131 | if result: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 132 | for i in range( main.numCtrls ): |
| 133 | main.log.info( "Node {} Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 134 | main.log.info( "Stop intent-perf" ) |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 135 | for i in range( main.numCtrls ): |
| 136 | main.CLIs[i].sendline( "intent-perf-stop" ) |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 137 | if result: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 138 | for i in range( main.numCtrls ): |
| 139 | main.log.info( "Node {} final Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) ) |
andrew@onlab.us | 2ae3a11 | 2015-02-02 11:24:32 -0800 | [diff] [blame] | 140 | |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 141 | with open( main.dbFileName, "a" ) as resultDB: |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 142 | for nodes in range( main.numCtrls ): |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 143 | resultString = "'" + main.commit + "'," |
| 144 | resultString += "'1gig'," |
Devin Lim | 58046fa | 2017-07-05 16:55:00 -0700 | [diff] [blame^] | 145 | resultString += str( main.numCtrls) + "," |
YPZhang | cbc2a06 | 2016-07-11 10:55:44 -0700 | [diff] [blame] | 146 | resultString += "'baremetal" + str( nodes+1 ) + "'," |
| 147 | resultString += main.neighbors + "," |
| 148 | resultString += result[ main.ONOSip[ nodes ] ]+"," |
| 149 | resultString += str(0) + "\n" # no stddev |
| 150 | resultDB.write( resultString ) |
| 151 | resultDB.close() |