| """ |
| Copyright 2015 Open Networking Foundation (ONF) |
| |
| Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| |
| TestON is free software: you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation, either version 2 of the License, or |
| (at your option) any later version. |
| |
| TestON is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| """ |
| |
| ''' |
| SCPFintentEventTp |
| - Use intentperf app to generate a lot of intent install and withdraw events |
| - Test will run with 1,3,5,7 nodes, and with all neighbors |
| - Test will run 400 seconds and grep the overall rate from intent-perf summary |
| |
| yunpeng@onlab.us |
| ''' |
| |
| import time |
| |
| |
| class SCPFintentEventTp: |
| def __init__( self ): |
| self.default = '' |
| |
| def CASE0( self, main ): |
| ''' |
| - GIT |
| - BUILDING ONOS |
| Pull specific ONOS branch, then Build ONOS ono ONOS Bench. |
| This step is usually skipped. Because in a Jenkins driven automated |
| test env. We want Jenkins jobs to pull&build for flexibility to handle |
| different versions of ONOS. |
| - Construct tests variables |
| ''' |
| try: |
| from tests.dependencies.ONOSSetup import ONOSSetup |
| main.testSetUp = ONOSSetup() |
| except ImportError: |
| main.log.error( "ONOSSetup not found. exiting the test" ) |
| main.exit() |
| main.testSetUp.envSetupDescription() |
| stepResult = main.FALSE |
| try: |
| main.cellName = main.params[ 'ENV'][ 'cellName'] |
| main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ] |
| main.BENCHUser = main.params[ 'BENCH' ][ 'user' ] |
| main.MN1Ip = main.params[ 'MN' ][ 'ip1' ] |
| main.maxNodes = int( main.params[ 'max' ] ) |
| main.numSwitches = ( main.params[ 'TEST' ][ 'numSwitches' ] ).split(",") |
| main.skipRelRsrc = main.params[ 'TEST' ][ 'skipReleaseResourcesOnWithdrawal' ] |
| main.flowObj = main.params[ 'TEST' ][ 'flowObj' ] |
| main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
| main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] ) |
| main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] ) |
| main.scale = ( main.params[ 'SCALE' ] ).split(",") |
| main.testDuration = main.params[ 'TEST' ][ 'duration' ] |
| main.logInterval = main.params[ 'TEST' ][ 'log_interval' ] |
| main.debug = main.params[ 'debugMode' ] |
| main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] ) |
| main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ] |
| if main.flowObj == "True": |
| main.flowObj = True |
| main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ] |
| main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ] |
| else: |
| main.flowObj = False |
| main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ] |
| main.numKeys = main.params[ 'TEST' ][ 'numKeys' ] |
| |
| stepResult = main.testSetUp.gitPulling() |
| # Create DataBase file |
| main.log.info( "Create Database file " + main.dbFileName ) |
| resultsDB = open( main.dbFileName, "w+" ) |
| resultsDB.close() |
| |
| # set neighbors |
| main.neighbors = "1" |
| except Exception as e: |
| main.testSetUp.envSetupException( e ) |
| main.testSetUp.evnSetupConclusion( stepResult ) |
| main.commit = main.commit.split( " " )[ 1 ] |
| |
| def CASE1( self, main ): |
| # Clean up test environment and set up |
| import time |
| main.maxNumBatch = 0 |
| main.testSetUp.getNumCtrls( True ) |
| main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False ) |
| main.testSetUp.ONOSSetUp( main.MN1Ip, True, |
| cellName=main.cellName, killRemoveMax=False, |
| CtrlsSet=False ) |
| |
| # config apps |
| main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager", |
| "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc ) |
| main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int( main.numCtrls*10)) ) |
| main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" ) |
| main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" ) |
| if main.flowObj: |
| main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| "useFlowObjectives", value="true") |
| main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", |
| "defaultFlowObjectiveCompiler", |
| value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler') |
| time.sleep( main.startUpSleep ) |
| |
| # balanceMasters |
| main.CLIs[0].balanceMasters() |
| time.sleep( main.startUpSleep ) |
| |
| def CASE2(self, main): |
| import numpy |
| |
| main.log.info( "Cluster Count = " + str( main.numCtrls ) ) |
| # adjust neighbors |
| if main.numCtrls == 1: |
| main.neighbors = "0" |
| main.log.info( "Neighbors: 0" ) |
| elif main.neighbors != "0": |
| main.neighbors = "0" |
| main.log.info( "Neighbors: 0" ) |
| elif main.neighbors == "0": |
| main.neighbors = str( main.numCtrls - 1 ) |
| main.log.info( "Neighbors: " + main.neighbors ) |
| |
| main.log.info( "Config intent-perf app" ) |
| main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numKeys " + main.numKeys ) |
| main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) ) |
| main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod ) |
| |
| main.log.info( "Starting intent-perf test for " + str( main.testDuration) + " seconds..." ) |
| main.CLIs[0].sendline( "intent-perf-start" ) |
| stop = time.time() + float( main.testDuration ) |
| |
| while time.time() < stop: |
| time.sleep(15) |
| result = main.CLIs[0].getIntentPerfSummary() |
| if result: |
| for i in range( main.numCtrls ): |
| main.log.info( "Node {} Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) ) |
| main.log.info( "Stop intent-perf" ) |
| for i in range( main.numCtrls ): |
| main.CLIs[i].sendline( "intent-perf-stop" ) |
| if result: |
| for i in range( main.numCtrls ): |
| main.log.info( "Node {} final Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) ) |
| |
| with open( main.dbFileName, "a" ) as resultDB: |
| for nodes in range( main.numCtrls ): |
| resultString = "'" + main.commit + "'," |
| resultString += "'1gig'," |
| resultString += str( main.numCtrls) + "," |
| resultString += "'baremetal" + str( nodes+1 ) + "'," |
| resultString += main.neighbors + "," |
| resultString += result[ main.ONOSip[ nodes ] ]+"," |
| resultString += str(0) + "\n" # no stddev |
| resultDB.write( resultString ) |
| resultDB.close() |