def CASE0(self, main): import os import imp """ - 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.MN1Ip = main.params['MN']['ip1'] main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.scale = (main.params['SCALE']).split(",") main.ofpRoleRequest = main.params['TSHARK']['ofpRoleRequest'] main.tsharkResultPath = main.params['TSHARK']['tsharkResultPath'] main.sampleSize = int(main.params['TEST']['sampleSize']) main.warmUp = int(main.params['TEST']['warmUp']) main.dbFileName = main.params['DATABASE']['dbName'] main.maxScale = int(main.params['max']) main.timeout = int(main.params['TIMEOUT']['timeout']) main.MNSleep = int(main.params['SLEEP']['mininet']) main.recoverySleep = int(main.params['SLEEP']['recovery']) main.debug = main.params['TEST']['debug'] main.failoverSleep = int(main.params['SLEEP']['failover']) main.switchID = main.params['SWITCH']['id'] main.topologySwitchCount = main.params['TOPOLOGY']['switchCount'] main.topologyType = main.params['TOPOLOGY']['type'] main.nodeNumToKill = int(main.params['KILL']['nodeNum']) main.failPercent = float(main.params['TEST']['failPercent']) if main.debug == "True": main.debug = True else: main.debug = False stepResult = main.testSetUp.envSetup() main.log.info("Create Database file " + main.dbFileName) resultsDB = open(main.dbFileName, "w+") resultsDB.close() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult)
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall git pull onos-package onos-install -f onos-wait-for-start start cli sessions start BGPLS apps """ import os main.log.info("ONOS Single node start " + "Scapy Tool - initialization") try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: main.cellName = main.params['ENV']['cellName'] main.ipList = os.getenv(main.params['CTRL']['ip1']) main.scapy_ip = os.getenv(main.params['SCAPY']['HOSTNAMES']) main.apps = main.params['ENV']['cellApps'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) cliResults = main.testSetUp.ONOSSetUp(main.Cluster, cellName=main.cellName, mininetIp=main.scapy_ip) main.step("App Ids check") appCheck = main.Cluster.active(0).CLI.appToIDCheck() if appCheck != main.TRUE: main.log.warn(main.Cluster.active(0).CLI.apps()) main.log.warn(main.Cluster.active(0).CLI.appIDs()) utilities.assert_equals(expect=main.TRUE, actual=appCheck, onpass="******", onfail="Something is wrong with app Ids") if cliResults == main.FALSE: main.log.error("Failed to start ONOS,stopping test") main.cleanAndExit()
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ main.log.info("ONOS HA test: Restart a minority of ONOS nodes - " + "initialization") # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.HA.generateGraph("HAkillNodes") main.testSetUp.ONOSSetUp(main.Mininet1, main.Cluster, cellName=cellName, removeLog=True, extraApply=[ main.HA.startingMininet, main.HA.customizeOnosGenPartitions, main.HA.copyBackupConfig, main.ONOSbench.preventAutoRespawn ], extraClean=main.HA.cleanUpGenPartition) main.HA.initialSetUp(serviceClean=True)
def initTest(main): """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() from tests.dependencies.Network import Network main.Network = Network() main.testSetUp.envSetupDescription(False) stepResult = main.FALSE try: main.step("Constructing test variables") # Test variables main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.path = os.path.dirname(main.testFile) main.useCommonTopo = main.params['DEPENDENCY'][ 'useCommonTopo'] == 'True' main.topoPath = main.path + ("/.." if main.useCommonTopo else "") + "/dependencies/" main.useCommonConf = main.params['DEPENDENCY'][ 'useCommonConf'] == 'True' main.configPath = main.path + ("/.." if main.useCommonConf else "") + "/dependencies/" main.forJson = "json/" main.forChart = "chart/" main.forConfig = "conf/" main.forHost = "host/" main.forSwitchFailure = "switchFailure/" main.forLinkFailure = "linkFailure/" main.topology = main.params['DEPENDENCY']['topology'] main.topologyLib = main.params['DEPENDENCY'][ 'lib'] if 'lib' in main.params['DEPENDENCY'] else None main.topologyConf = main.params['DEPENDENCY'][ 'conf'] if 'conf' in main.params['DEPENDENCY'] else None main.scale = (main.params['SCALE']['size']).split(",") main.maxNodes = int(main.params['SCALE']['max']) main.startUpSleep = int(main.params['SLEEP']['startup']) stepResult = main.testSetUp.envSetup(False) except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult)
def CASE1( self, main ): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ import imp import pexpect import time import json main.log.info( "ONOS HA test: Stop a minority of ONOS nodes - " + "initialization" ) # set global variables # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error( "ONOSSetup not found. exiting the test" ) main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() # load some variables from the params file cellName = main.params[ 'ENV' ][ 'cellName' ] main.apps = main.params[ 'ENV' ][ 'appString' ] main.numCtrls = int( main.params[ 'num_controllers' ] ) stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException( e ) main.testSetUp.evnSetupConclusion( stepResult ) main.HA.generateGraph( "HAcontinuousStopNodes" ) main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster, cellName=cellName, removeLog=True, extraApply=[ main.HA.startingMininet, main.HA.customizeOnosGenPartitions ], extraClean=main.HA.cleanUpGenPartition ) main.HA.initialSetUp()
def CASE0(self, main): """ Pull specific ONOS branch, then Build ONOS on 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. """ from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() main.testSetUp.gitPulling() from tests.dependencies.Network import Network main.Network = Network()
def CASE1(self, main): import time import os import imp """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # Test variables main.testOnDirectory = os.path.dirname(os.getcwd()) main.cellName = main.params['CASE1']['cellName'] main.apps = main.params['CASE1']['cellApps'] main.maxNodes = int(main.params['GLOBAL']['maxNodes']) main.startUpSleep = float( main.params['GLOBAL']['SLEEP']['startup']) main.startMNSleep = float( main.params['GLOBAL']['SLEEP']['startMN']) main.addFlowSleep = float( main.params['GLOBAL']['SLEEP']['addFlow']) main.delFlowSleep = float( main.params['GLOBAL']['SLEEP']['delFlow']) main.chkFlowSleep = float( main.params['GLOBAL']['SLEEP']['chkFlow']) main.skipPackaging = main.params['CASE2']['skipPackaging'] if main.skipPackaging.lower() == "true": main.skipPackaging = True else: main.skipPackaging = False main.cfgSleep = float(main.params['GLOBAL']['SLEEP']['cfg']) main.numSw = int(main.params['GLOBAL']['numSw']) main.numThreads = int(main.params['GLOBAL']['numThreads']) main.cluster = main.params['GLOBAL']['cluster'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ main.log.info("ONOS HA test: Restart all ONOS nodes - " + "initialization") # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() # load some variables from the params file cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.testSetUp.ONOSSetUp(main.Cluster, cellName=cellName, removeLog=True, extraApply=main.HA.startingMininet) main.HA.initialSetUp()
def CASE0(self, main): """ Pull specific ONOS branch, then Build ONOS on 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. """ try: from tests.dependencies.ONOSSetup import ONOSSetup except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() try: main.testSetUp except (NameError, AttributeError): main.testSetUp = ONOSSetup() main.testSetUp.gitPulling()
def CASE1( self, main ): import imp import time import re """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error( "ONOSSetup not found. exiting the test" ) main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE # Test variables try: main.apps = main.params[ 'ENV' ][ 'cellApps' ] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] ) main.switches = int( main.params[ 'MININET' ][ 'switch' ] ) main.links = int( main.params[ 'MININET' ][ 'links' ] ) main.hosts = int( main.params[ 'MININET' ][ 'hosts' ] ) main.opticalTopo = main.params[ 'MININET' ][ 'toponame' ] main.hostsData = {} main.assertReturnString = '' # Assembled assert return string main.cycle = 0 # How many times FUNCintent has run through its tests # -- INIT SECTION, ONLY RUNS ONCE -- # stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException( e ) main.testSetUp.evnSetupConclusion( stepResult )
def initSetup(self): import json import time import os from operator import eq try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except Exception: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() main.testSetUp.envSetup() main.apps = main.params['ENV']['appString'] cellName = main.params['ENV']['cellName'] main.step("Copying config files") src = os.path.dirname(main.testFile) + "/network-cfg.json" dst = main.ONOSbench.home + "/tools/package/config/network-cfg.json" status = main.ONOSbench.scp(main.ONOSbench, src, dst, direction="to") utilities.assert_equals(expect=main.TRUE, actual=status, onpass="******", onfail="Copy config file failed") main.testSetUp.ONOSSetUp(main.Cluster, cellName=cellName) main.step("Checking if ONOS CLI is ready for issuing commands") ready = utilities.retry(main.Cluster.command, False, kwargs={ "function": "summary", "contentCheck": True }, sleep=30, attempts=10) utilities.assert_equals(expect=True, actual=ready, onpass="******", onfail="ONOS summary command failed") if not ready: main.log.error("ONOS startup failed!") main.cleanAndExit()
def initTest(main): """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: main.step("Constructing test variables") # Test variables main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.diff = main.params['ENV']['diffApps'] main.path = os.path.dirname(main.testFile) main.dependencyPath = main.path + "/../dependencies/" main.topology = main.params['DEPENDENCY']['topology'] wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] main.scale = (main.params['SCALE']['size']).split(",") main.maxNodes = int(main.params['SCALE']['max']) # main.ONOSport = main.params[ 'CTRL' ][ 'port' ] main.startUpSleep = int(main.params['SLEEP']['startup']) # -- INIT SECTION, ONLY RUNS ONCE -- # copyResult1 = main.ONOSbench.scp(main.Mininet1, main.dependencyPath + main.topology, main.Mininet1.home, direction="to") stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult)
def CASE1(self, main): import imp import re """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE # Test variables try: main.apps = main.params['ENV']['cellApps'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] wrapperFile2 = main.params['DEPENDENCY']['wrapper2'] wrapperFile3 = main.params['DEPENDENCY']['wrapper3'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.gossipTime = int(main.params['SLEEP']['cfgGossip']) main.SetNetCfgSleep = int(main.params['SLEEP']['SetNetCfgSleep']) main.hostsData = {} main.retrytimes = int(main.params['RETRY']) main.retrysleep = int(main.params['RetrySleep']) # -- INIT SECTION, SHOULD ONLY BE RUN ONCE -- # main.netCfg = imp.load_source( wrapperFile2, main.dependencyPath + wrapperFile2 + ".py") stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.envSetupConclusion(stepResult)
def CASE1(self, main): import os import imp """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # The variable to decide if the data should be written into data base. # 1 means Yes and -1 means No. main.writeData = 1 main.searchTerm = main.params['SearchTerm'] main.apps = main.params['ENV']['cellApps'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] main.tsharkResultPath = main.params['TsharkPath'] main.roleRequest = main.params['SearchTerm']['roleRequest'] main.multiovs = main.params['DEPENDENCY']['multiovs'] main.topoName = main.params['TOPOLOGY']['topology'] main.topoScale = (main.params['TOPOLOGY']['scale']).split(",") main.topoScaleSize = len(main.topoScale) wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] wrapperFile2 = main.params['DEPENDENCY']['wrapper2'] wrapperFile3 = main.params['DEPENDENCY']['wrapper3'] main.topoCmpAttempts = int(main.params['ATTEMPTS']['topoCmp']) main.pingallAttempts = int(main.params['ATTEMPTS']['pingall']) main.startUpSleep = int(main.params['SLEEP']['startup']) main.balanceSleep = int(main.params['SLEEP']['balance']) main.nodeSleep = int(main.params['SLEEP']['nodeSleep']) main.pingallSleep = int(main.params['SLEEP']['pingall']) main.MNSleep = int(main.params['SLEEP']['MNsleep']) main.pingTimeout = float(main.params['TIMEOUT']['pingall']) main.hostDiscover = main.params['TOPOLOGY']['host'] main.hostDiscoverSleep = float(main.params['SLEEP']['host']) main.basicMNTime = int(main.params['TIMEOUT']['basicMininet']) main.startNetTime = int(main.params['TIMEOUT']['startNet']) main.stopNetTime = int(main.params['TIMEOUT']['stopNet']) main.MNupdateTime = int(main.params['TIMEOUT']['update']) main.MNLinksTime = int(main.params['TIMEOUT']['links']) main.currScale = None main.threadID = 0 if main.hostDiscover == 'True': main.hostDiscover = True else: main.hostDiscover = False main.homeDir = os.path.expanduser('~') main.hostsData = {} stepResult = main.testSetUp.envSetup() main.allinfo = { } # The dictionary to record all the data from karaf.log for i in range(2): main.allinfo[i] = {} for w in range(3): # Totaltime: the time from the new switchConnection to its end # swConnection: the time from the first new switchConnection to the last new switchConnection # lastSwToLastRr: the time from the last new switchConnection to the last role request # lastRrToLastTopology: the time form the last role request to the last topology # disconnectRate: the rate that shows how many switch disconnect after connection main.allinfo[i]['info' + str(w)] = { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 } main.dbFilePath = main.params['DATABASE']['dbPath'] main.log.info("Create Database file " + main.dbFilePath) resultDB = open(main.dbFilePath, 'w+') resultDB.close() main.scaleTopoFunction = imp.load_source( wrapperFile2, main.dependencyPath + wrapperFile2 + ".py") main.topo = imp.load_source( wrapperFile3, main.dependencyPath + wrapperFile3 + ".py") main.ONOSbench.scp(main.Mininet1, main.dependencyPath + main.multiovs, main.Mininet1.home, direction="to") except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ import re main.log.info("ONOS HA test: Restart all ONOS nodes - " + "initialization") # set global variables # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() main.Cluster.numCtrls = 1 try: from tests.HA.dependencies.HA import HA main.HA = HA() # load some variables from the params file cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] stepResult = main.testSetUp.envSetup(includeCaseDesc=False) except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.scaling = main.params['scaling'].split(",") main.log.debug(main.scaling) scale = main.scaling.pop(0) main.log.debug(scale) main.Cluster.setRunningNode(int(re.search("\d+", scale).group(0))) applyFuncs = [main.HA.removeKarafConsoleLogging] applyArgs = [None] try: if main.params['topology']['topoFile']: main.log.info( 'Skipping start of Mininet in this case, make sure you start it elsewhere' ) else: applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) except (KeyError, IndexError): applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) main.testSetUp.ONOSSetUp(main.Cluster, cellName=cellName, extraApply=applyFuncs, applyArgs=applyArgs, installMax=True, atomixClusterSize=3, includeCaseDesc=False) main.HA.initialSetUp() main.step('Set logging levels') logging = True try: logs = main.params.get('ONOS_Logging', False) if logs: for namespace, level in logs.items(): for ctrl in main.Cluster.active(): ctrl.CLI.logSet(level, namespace) except AttributeError: logging = False utilities.assert_equals(expect=True, actual=logging, onpass="******", onfail="Failed to set log levels")
def CASE0(self, main): import os import imp """ - 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.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # The dictionary to record different type of wrongs main.wrong = { 'totalWrong': 0, 'skipDown': 0, 'TsharkValueIncorrect': 0, 'TypeError': 0, 'decodeJasonError': 0, 'checkResultIncorrect': 0 } main.maxWrong = int(main.params['TEST']['MaxWrong']) main.resultRange = main.params['TEST']['ResultRange'] main.searchTerm = main.params['TEST']['SearchTerm'] main.MN1Ip = main.params['MN']['ip1'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] main.topoName = main.params['DEPENDENCY']['topology'] main.dependencyFunc = main.params['DEPENDENCY']['function'] main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.scale = (main.params['SCALE']).split(",") main.ofPackage = main.params['TSHARK'] main.defaultTopoCfg = main.params['CFG']['defaultTopo'] main.tsharkResultPath = main.params['TEST']['tsharkResultPath'] main.sampleSize = int(main.params['TEST']['sampleSize']) main.warmUp = int(main.params['TEST']['warmUp']) main.dbFileName = main.params['DATABASE']['dbName'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.measurementSleep = int(main.params['SLEEP']['measure']) main.deleteSwSleep = int(main.params['SLEEP']['deleteSW']) main.maxScale = int(main.params['max']) main.timeout = int(main.params['TIMEOUT']['timeout']) main.MNSleep = int(main.params['SLEEP']['mininet']) main.device = main.params['TEST']['device'] stepResult = main.testSetUp.envSetup() main.log.info("Create Database file " + main.dbFileName) resultsDB = open(main.dbFileName, "w+") resultsDB.close() main.switchFunc = imp.load_source( main.dependencyFunc, main.dependencyPath + main.dependencyFunc + ".py") except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ main.log.info("ONOS Single node cluster restart " + "HA test - initialization") main.case("Setting up test environment") main.caseExplanation = "Setup the test environment including " +\ "installing ONOS, starting Mininet and ONOS" +\ "cli sessions." # set global variables # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() # load some variables from the params file cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] main.numCtrls = int(main.params['num_controllers']) stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.Cluster.setRunningNode(int(main.params['num_controllers'])) ip = main.Cluster.getIps(allNode=True) main.testSetUp.ONOSSetUp( main.Cluster, cellName="SingleHA", removeLog=True, extraApply=[ main.testSetUp.createApplyCell, main.HA.startingMininet, main.testSetUp.createApplyCell ], applyArgs=[[main.Cluster, True, cellName, "", "", True, ip], None, [ main.Cluster, True, "SingleHA", "", "", True, main.Cluster.runningNodes[0].ipAddress ]]) main.HA.initialSetUp()
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ import imp import time import json try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # load some variables from the params file main.cellName = main.params['ENV']['cellName'] main.sleep = int(main.params['SLEEP']['netcfg']) main.apps = main.params['ENV']['cellApps'] ofPort = main.params['CTRL']['port'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.envSetupConclusion(stepResult) main.testSetUp.ONOSSetUp(main.Cluster, cellName=main.cellName) main.step("Starting Mininet") # scp topo file to mininet # TODO: move to params? topoName = "vpls" topoFile = "vpls.py" filePath = main.ONOSbench.home + "/tools/test/topos/" main.ONOSbench.scp(main.Mininet1, filePath + topoFile, main.Mininet1.home, direction="to") topo = " --custom " + main.Mininet1.home + topoFile + " --topo " + topoName args = " --switch ovs,protocols=OpenFlow13" for ctrl in main.Cluster.active(): args += " --controller=remote,ip=" + ctrl.ipAddress mnCmd = "sudo mn" + topo + args mnResult = main.Mininet1.startNet(mnCmd=mnCmd) utilities.assert_equals(expect=main.TRUE, actual=mnResult, onpass="******", onfail="Error starting Mininet") main.step("Activate apps defined in the params file") # get data from the params apps = main.params.get('apps') if apps: apps = apps.split(',') main.log.warn(apps) activateResult = True for app in apps: main.Cluster.active(0).CLI.app(app, "Activate") # TODO: check this worked time.sleep(main.sleep) # wait for apps to activate for app in apps: state = main.Cluster.active(0).CLI.appStatus(app) if state == "ACTIVE": activateResult = activateResult and True else: main.log.error("{} is in {} state".format(app, state)) activateResult = False utilities.assert_equals(expect=True, actual=activateResult, onpass="******", onfail="Failed to activate apps") else: main.log.warn("No apps were specified to be loaded after startup") main.step("Set ONOS configurations") config = main.params.get('ONOS_Configuration') if config: main.log.debug(config) checkResult = main.TRUE for component in config: for setting in config[component]: value = config[component][setting] check = main.Cluster.active(0).CLI.setCfg( component, setting, value) main.log.info( "Value was changed? {}".format(main.TRUE == check)) checkResult = check and checkResult utilities.assert_equals(expect=main.TRUE, actual=checkResult, onpass="******", onfail="Failed to set config") else: main.log.warn( "No configurations were specified to be changed after startup") main.step("App Ids check") appCheck = main.Cluster.command("appToIDCheck", returnBool=True) if not appCheck: main.log.warn(main.Cluster.active(0).CLI.apps()) main.log.warn(main.Cluster.active(0).CLI.appIDs()) utilities.assert_equals(expect=True, actual=appCheck, onpass="******", onfail="Something is wrong with app Ids")
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.cleanAndExit() 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.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.intentManagerCfg = main.params['CFG']['intentManager'] main.intentConfigRegiCfg = main.params['CFG']['intentConfigRegi'] main.nullProviderCfg = main.params['CFG']['nullProvider'] main.intentPerfInstallerCfg = main.params['CFG'][ 'intentPerfInstaller'] main.neighbor = (main.params['TEST']['neighbors']).split(",") 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.envSetup() # Create DataBase file main.log.info("Create Database file " + main.dbFileName) resultsDB = open(main.dbFileName, "w+") resultsDB.close() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ main.log.info("ONOS Single node cluster restart " + "HA test - initialization") # set global variables # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() # load some variables from the params file cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] main.numCtrls = int(main.params['num_controllers']) stepResult = main.testSetUp.envSetup(includeCaseDesc=False) except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) cellApps = str(main.params["ENV"]["appString"]) cellNAme = str(main.params["ENV"]["appString"]) applyFuncs = [main.testSetUp.createApplyCell] applyArgs = [[ main.Cluster, True, cellName, cellApps, "", True, main.Cluster.runningNodes[0].ipAddress ]] try: if main.params['topology']['topoFile']: main.log.info( 'Skipping start of Mininet in this case, make sure you start it elsewhere' ) else: applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) except (KeyError, IndexError): applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) main.Cluster.setRunningNode(int(main.params['num_controllers'])) ip = main.Cluster.getIps(allNode=True) main.testSetUp.ONOSSetUp(main.Cluster, cellName="SingleHA", extraApply=applyFuncs, applyArgs=applyArgs, includeCaseDesc=False) main.HA.initialSetUp() main.step('Set logging levels') logging = True try: logs = main.params.get('ONOS_Logging', False) if logs: for namespace, level in logs.items(): for ctrl in main.Cluster.active(): ctrl.CLI.logSet(level, namespace) except AttributeError: logging = False utilities.assert_equals(expect=True, actual=logging, onpass="******", onfail="Failed to set log levels")
def CASE1(self, main): import os import imp """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # Test variables main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.ONOSport = main.params['CTRL']['port'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] wrapperFile2 = main.params['DEPENDENCY']['wrapper2'] main.topology = main.params['DEPENDENCY']['topology'] bucket = main.params['DEPENDENCY']['bucket'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.startMNSleep = int(main.params['SLEEP']['startMN']) main.addFlowSleep = int(main.params['SLEEP']['addFlow']) main.delFlowSleep = int(main.params['SLEEP']['delFlow']) main.addGroupSleep = int(main.params['SLEEP']['addGroup']) main.delGroupSleep = int(main.params['SLEEP']['delGroup']) main.debug = main.params['DEBUG'] main.swDPID = main.params['TEST']['swDPID'] egressPort1 = main.params['TEST']['egressPort1'] egressPort2 = main.params['TEST']['egressPort2'] egressPort3 = main.params['TEST']['egressPort3'] ingressPort = main.params['TEST']['ingressPort'] appCookie = main.params['TEST']['appCookie'] type1 = main.params['TEST']['type1'] type2 = main.params['TEST']['type2'] groupId = main.params['TEST']['groupId'] priority = main.params['TEST']['priority'] deviceId = main.params['TEST']['swDPID'] main.debug = True if "on" in main.debug else False # -- INIT SECTION, ONLY RUNS ONCE -- # main.buckets = imp.load_source( bucket, main.dependencyPath + bucket + ".py") copyResult = main.ONOSbench.scp(main.Mininet1, main.dependencyPath + main.topology, main.Mininet1.home + '/custom/', direction="to") utilities.assert_equals(expect=main.TRUE, actual=copyResult, onpass="******" + "test variables ", onfail="Failed to copy test variables") stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult)
def CASE10( self, main ): """ Start ONOS cluster ( 3 nodes in this example ) in three steps: 1 ) start a basic cluster with drivers app via ONOSDriver; 2 ) activate apps via ONOSCliDriver; 3 ) configure onos via ONOSCliDriver; """ try: from tests.dependencies.ONOSSetup import ONOSSetup except ImportError: main.log.error( "ONOSSetup not found. exiting the test" ) main.cleanAndExit() try: main.testSetUp except ( NameError, AttributeError ): main.testSetUp = ONOSSetup() import time main.case( "Start up " + str( main.Cluster.numCtrls ) + "-node onos cluster." ) main.step( "Start ONOS cluster with basic (drivers) app." ) stepResult = main.ONOSbench.startBasicONOS( nodeList=main.Cluster.getIps(), opSleep=200, onosUser=main.ONOScell.karafUser ) utilities.assert_equals( expect=main.TRUE, actual=stepResult, onpass="******", onfail="Failed to start basic ONOS Cluster " ) main.testSetUp.startOnosClis() main.step( "Activate onos apps." ) main.apps = main.params[ 'CASE10' ].get( 'Apps' ) if main.apps: main.log.info( "Apps to activate: " + main.apps ) activateResult = main.TRUE for a in main.apps.split( "," ): activateResult = activateResult & main.Cluster.active( 0 ).CLI.activateApp( a ) # TODO: check this worked time.sleep( main.onosCfgSleep ) # wait for apps to activate else: main.log.warn( "No configurations were specified to be changed after startup" ) utilities.assert_equals( expect=main.TRUE, actual=activateResult, onpass="******", onfail="Failed to set config" ) main.step( "Set ONOS configurations" ) config = main.params[ 'CASE10' ].get( 'ONOS_Configuration' ) if config: main.log.debug( config ) checkResult = main.TRUE for component in config: for setting in config[ component ]: value = config[ component ][ setting ] check = main.Cluster.runningNodes[ 0 ].setCfg( component, setting, value ) main.log.info( "Value was changed? {}".format( main.TRUE == check ) ) checkResult = check and checkResult utilities.assert_equals( expect=main.TRUE, actual=checkResult, onpass="******", onfail="Failed to set config" ) else: main.log.warn( "No configurations were specified to be changed after startup" )
def CASE1(self, main): import time import imp import re """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE # Test variables try: main.apps = main.params['ENV']['cellApps'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] # main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] main.iface = main.params['DEPENDENCY']['iface'] main.scale = (main.params['SCALE']['size']).split(",") wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] wrapperFile2 = main.params['DEPENDENCY']['wrapper2'] wrapperFile3 = main.params['DEPENDENCY']['wrapper3'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.switchSleep = int(main.params['SLEEP']['upSwitch']) main.checkTopoAttempts = int(main.params['SLEEP']['topoAttempts']) main.numSwitch = int(main.params['MININET']['switch']) # Config file parameters main.configDevicePort = main.params['CONFIGURE']['cfgDevicePort'] main.configDriver = main.params['CONFIGURE']['cfgDriver'] main.configApps = main.params['CONFIGURE']['cfgApps'] main.configName = main.params['CONFIGURE']['cfgName'] main.configPass = main.params['CONFIGURE']['cfgPass'] main.configPort = main.params['CONFIGURE']['cfgAppPort'] main.cycle = 0 # How many times FUNCintent has run through its tests main.hostsData = {} main.assertReturnString = '' # Assembled assert return string # -- INIT SECTION, ONLY RUNS ONCE -- # main.netconfFunction = imp.load_source( wrapperFile2, main.dependencyPath + wrapperFile2 + ".py") stepResult = main.testSetUp.envSetup() # Uncomment out the following if a mininet topology is added # copyResult1 = main.ONOSbench.scp( main.Mininet1, # main.dependencyPath + # main.topology, # main.Mininet1.home + "custom/", # direction="to" ) except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.envSetupConclusion(stepResult)
def CASE1( self, main ): import os import imp try: from tests.dependencies.ONOSSetup import ONOSSetup except ImportError: main.log.error( "SetUp not found exiting the test" ) main.cleanAndExit() try: main.testSetUp except ( NameError, AttributeError ): main.testSetUp = ONOSSetup() """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code """ main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # Test variables main.cellName = main.params[ 'ENV' ][ 'cellName' ] main.apps = main.params[ 'ENV' ][ 'cellApps' ] main.ONOSport = main.params[ 'CTRL' ][ 'port' ] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) main.startMNSleep = int( main.params[ 'SLEEP' ][ 'startMN' ] ) main.addFlowSleep = int( main.params[ 'SLEEP' ][ 'addFlow' ] ) main.delFlowSleep = int( main.params[ 'SLEEP' ][ 'delFlow' ] ) main.debug = main.params[ 'DEBUG' ] main.swDPID = main.params[ 'TEST' ][ 'swDPID' ] main.debug = True if "on" in main.debug else False # -- INIT SECTION, ONLY RUNS ONCE -- # try: from tests.FUNC.FUNCflow.dependencies.checkingFlow import CheckingFlow main.checkingFlow = CheckingFlow() except ImportError as e: print e main.log.error( "CheckingFlow not found exiting the test" ) main.cleanAndExit() copyResult = main.ONOSbench.scp( main.Mininet1, main.dependencyPath + main.topology, main.Mininet1.home + '/custom/', direction="to" ) utilities.assert_equals( expect=main.TRUE, actual=copyResult, onpass="******" + "test variables ", onfail="Failed to copy test variables" ) stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException( e ) main.testSetUp.evnSetupConclusion( stepResult )
def CASE0(self, main): """ Startup sequence: apply cell <name> git pull onos-package onos-verify-cell onos-uninstall onos-install onos-start-cli Set IPv6 cfg parameters for Neighbor Discovery start event scheduler start event listener """ import time from threading import Lock, Condition from core.graph import Graph from tests.CHOTestMonkey.dependencies.elements.ONOSElement import Controller from tests.CHOTestMonkey.dependencies.EventGenerator import EventGenerator from tests.CHOTestMonkey.dependencies.EventScheduler import EventScheduler try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: onosPackage = main.params['TEST']['package'] karafTimeout = main.params['TEST']['karafCliTimeout'] main.enableIPv6 = main.params['TEST']['IPv6'] main.enableIPv6 = True if main.enableIPv6 == "on" else False main.caseSleep = int(main.params['TEST']['caseSleep']) main.onosCell = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.controllers = [] main.devices = [] main.links = [] main.hosts = [] main.intents = [] main.enabledEvents = {} for eventName in main.params['EVENT'].keys(): if main.params['EVENT'][eventName]['status'] == 'on': main.enabledEvents[int(main.params['EVENT'][eventName] ['typeIndex'])] = eventName print main.enabledEvents main.graph = Graph() main.eventScheduler = EventScheduler() main.eventGenerator = EventGenerator() main.variableLock = Lock() main.mininetLock = Lock() main.ONOSbenchLock = Lock() main.threadID = 0 main.eventID = 0 main.caseResult = main.TRUE stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) setupResult = main.testSetUp.ONOSSetUp(main.Cluster, cellName=main.onosCell) for i in range(1, main.Cluster.numCtrls + 1): newController = Controller(i) newController.setCLI(main.Cluster.active(i - 1).CLI) main.controllers.append(newController) main.step("Set IPv6 cfg parameters for Neighbor Discovery") setIPv6CfgSleep = int(main.params['TEST']['setIPv6CfgSleep']) if main.enableIPv6: time.sleep(setIPv6CfgSleep) cfgResult1 = main.controllers[0].CLI.setCfg( "org.onosproject.net.neighbour.impl.NeighbourResolutionManager", "ndpEnabled", "true") time.sleep(setIPv6CfgSleep) cfgResult2 = main.controllers[0].CLI.setCfg( "org.onosproject.provider.host.impl.HostLocationProvider", "requestIpv6ND", "true") else: main.log.info( "Skipped setting IPv6 cfg parameters as it is disabled in params file" ) cfgResult1 = main.TRUE cfgResult2 = main.TRUE cfgResult = cfgResult1 and cfgResult2 utilities.assert_equals( expect=main.TRUE, actual=cfgResult, onpass="******", onfail="Failed to cfg set ipv6NeighborDiscovery") main.step("Start a thread for the scheduler") t = main.Thread(target=main.eventScheduler.startScheduler, threadID=main.threadID, name="startScheduler", args=[]) t.start() stepResult = main.TRUE with main.variableLock: main.threadID = main.threadID + 1 utilities.assert_equals(expect=main.TRUE, actual=stepResult, onpass="******", onfail="Test step FAIL") main.step( "Start a thread to listen to and handle network, ONOS and application events" ) t = main.Thread(target=main.eventGenerator.startListener, threadID=main.threadID, name="startListener", args=[]) t.start() with main.variableLock: main.threadID = main.threadID + 1 caseResult = setupResult and cfgResult utilities.assert_equals(expect=main.TRUE, actual=caseResult, onpass="******", onfail="Set up test environment FAIL")
def CASE1(self, main): import os import imp """ - Construct tests variables - GIT ( optional ) - Checkout ONOS master branch - Pull latest ONOS code - Building ONOS ( optional ) - Install ONOS package - Build ONOS package """ try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # Test variables main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.ONOSport = main.params['CTRL']['port'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] wrapperFile1 = main.params['DEPENDENCY']['wrapper1'] wrapperFile2 = main.params['DEPENDENCY']['wrapper2'] main.topology = main.params['DEPENDENCY']['topology'] bucket = main.params['DEPENDENCY']['bucket'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.startMNSleep = int(main.params['SLEEP']['startMN']) main.addFlowSleep = int(main.params['SLEEP']['addFlow']) main.delFlowSleep = int(main.params['SLEEP']['delFlow']) main.addGroupSleep = int(main.params['SLEEP']['addGroup']) main.delGroupSleep = int(main.params['SLEEP']['delGroup']) main.debug = main.params['DEBUG'] main.swDPID = main.params['TEST']['swDPID'] egressPort1 = main.params['TEST']['egressPort1'] egressPort2 = main.params['TEST']['egressPort2'] egressPort3 = main.params['TEST']['egressPort3'] ingressPort = main.params['TEST']['ingressPort'] appCookie = main.params['TEST']['appCookie'] type1 = main.params['TEST']['type1'] type2 = main.params['TEST']['type2'] groupId = main.params['TEST']['groupId'] priority = main.params['TEST']['priority'] deviceId = main.params['TEST']['swDPID'] main.scapyHostNames = main.params['SCAPY']['HOSTNAMES'].split(',') main.scapyHosts = [] # List of scapy hosts for iterating main.debug = True if "on" in main.debug else False # -- INIT SECTION, ONLY RUNS ONCE -- # main.buckets = imp.load_source( bucket, main.dependencyPath + bucket + ".py") stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult)
def CASE0(self, main): import os import imp """ - 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.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: main.MN1Ip = main.params['MN']['ip1'] main.dependencyPath = main.testOnDirectory + \ main.params[ 'DEPENDENCY' ][ 'path' ] main.dependencyFunc = main.params['DEPENDENCY']['function'] main.topoName = main.params['DEPENDENCY']['topology'] main.cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['cellApps'] main.scale = (main.params['SCALE']).split(",") main.ofportStatus = main.params['TSHARK']['ofpPortStatus'] main.tsharkResultPath = main.params['TSHARK']['tsharkReusltPath'] main.sampleSize = int(main.params['TEST']['sampleSize']) main.warmUp = int(main.params['TEST']['warmUp']) main.maxProcessTime = int(main.params['TEST']['maxProcessTime']) main.dbFileName = main.params['DATABASE']['dbName'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.measurementSleep = int(main.params['SLEEP']['measure']) main.maxScale = int(main.params['max']) main.defaultTopoCfg = main.params['CFG']['defaultTopo'] main.interface = main.params['TEST']['interface'] main.timeout = int(main.params['TIMEOUT']['timeout']) main.MNSleep = int(main.params['SLEEP']['mininet']) main.device = main.params['TEST']['device'] main.debug = main.params['TEST']['debug'] if main.debug == "True": main.debug = True else: main.debug = False stepResult = main.testSetUp.envSetup() main.log.info("Create Database file " + main.dbFileName) resultsDB = open(main.dbFileName, "w+") resultsDB.close() main.portFunc = imp.load_source( main.dependencyFunc, main.dependencyPath + main.dependencyFunc + ".py") except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE0(self, main): import imp import os """ - 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.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: main.apps = main.params['ENV']['cellApps'] main.BENCHUser = main.params['BENCH']['user'] main.BENCHIp = main.params['BENCH']['ip1'] main.MN1Ip = main.params['MN']['ip1'] main.maxNodes = int(main.params['max']) main.cellName = main.params['ENV']['cellName'] main.scale = (main.params['SCALE']).split(",") main.timeout = int(main.params['SLEEP']['timeout']) main.startUpSleep = int(main.params['SLEEP']['startup']) main.installSleep = int(main.params['SLEEP']['install']) main.verifySleep = int(main.params['SLEEP']['verify']) main.intentManagerCfg = main.params['CFG']['intentManager'] main.intentConfigRegiCfg = main.params['CFG']['intentConfigRegi'] main.nullProviderCfg = main.params['CFG']['nullProvider'] main.verifyAttempts = int(main.params['ATTEMPTS']['verify']) main.cfgRetry = int(main.params['ATTEMPTS']['cfg']) main.maxInvalidRun = int(main.params['ATTEMPTS']['maxInvalidRun']) main.sampleSize = int(main.params['TEST']['sampleSize']) main.warmUp = int(main.params['TEST']['warmUp']) main.intentsList = (main.params['TEST']['intents']).split(",") main.deviceCount = int(main.params['TEST']['deviceCount']) main.ingress = main.params['TEST']['ingress'] main.egress = main.params['TEST']['egress'] main.debug = main.params['TEST']['debug'] main.flowObj = main.params['TEST']['flowObj'] if main.flowObj == "True": main.flowObj = True main.dbFileName = main.params['DATABASE']['dbFlowObj'] else: main.flowObj = False main.dbFileName = main.params['DATABASE']['dbName'] for i in range(0, len(main.intentsList)): main.intentsList[i] = int(main.intentsList[i]) stepResult = main.testSetUp.envSetup() # Create DataBase file main.log.info("Create Database file " + main.dbFileName) resultsDB = open(main.dbFileName, "w+") resultsDB.close() file1 = main.params["DEPENDENCY"]["FILE1"] main.dependencyPath = os.path.dirname( os.getcwd()) + main.params["DEPENDENCY"]["PATH"] main.intentFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py") except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.envSetupConclusion(stepResult) main.commit = main.commit.split(" ")[1]
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: cell <name> onos-verify-cell NOTE: temporary - onos-remove-raft-logs onos-uninstall start mininet git pull mvn clean install onos-package onos-install -f onos-wait-for-start start cli sessions start tcpdump """ main.log.info("ONOS HA test: Stop a minority of ONOS nodes - " + "initialization") # These are for csv plotting in jenkins main.HAlabels = [] main.HAdata = [] try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() try: from tests.HA.dependencies.HA import HA main.HA = HA() cellName = main.params['ENV']['cellName'] main.apps = main.params['ENV']['appString'] stepResult = main.testSetUp.envSetup(includeCaseDesc=False) except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) applyFuncs = [main.HA.copyBackupConfig] applyArgs = [None] try: if main.params['topology']['topoFile']: main.log.info( 'Skipping start of Mininet in this case, make sure you start it elsewhere' ) else: applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) except (KeyError, IndexError): applyFuncs.append(main.HA.startingMininet) applyArgs.append(None) main.testSetUp.ONOSSetUp(main.Cluster, cellName=cellName, removeLog=True, extraApply=applyFuncs, applyArgs=applyArgs, extraClean=main.HA.cleanUpGenPartition, includeCaseDesc=False) main.HA.initialSetUp(serviceClean=True) main.step('Set logging levels') logging = True try: logs = main.params.get('ONOS_Logging', False) if logs: for namespace, level in logs.items(): for ctrl in main.Cluster.active(): ctrl.CLI.logSet(level, namespace) except AttributeError: logging = False utilities.assert_equals(expect=True, actual=logging, onpass="******", onfail="Failed to set log levels")
def CASE1(self, main): """ CASE1 is to compile ONOS and push it to the test machines Startup sequence: Construct test variables Safety check, kill all ONOS processes before setup NOTE: temporary - onos-remove-raft-logs Create ONOS package Install ONOS package start cli sessions start ovsdb start vtn apps """ import os import time main.log.info("ONOS Single node start ovsdb test - initialization") try: from tests.dependencies.ONOSSetup import ONOSSetup main.testSetUp = ONOSSetup() except ImportError: main.log.error("ONOSSetup not found. exiting the test") main.cleanAndExit() main.testSetUp.envSetupDescription() stepResult = main.FALSE try: # load some variables from the params file main.step("Constructing test variables") cellName = main.params['ENV']['cellName'] main.startUpSleep = int(main.params['SLEEP']['startup']) main.apps = main.params['ENV']['cellApps'] stepResult = main.testSetUp.envSetup() except Exception as e: main.testSetUp.envSetupException(e) main.testSetUp.evnSetupConclusion(stepResult) cliResults = main.testSetUp.ONOSSetUp(main.Cluster, cellName=cellName, mininetIp=main.OVSDB1) if cliResults == main.FALSE: main.log.error("Failed to start ONOS, stopping test") main.cleanAndExit() main.step("App Ids check") appCheck = main.Cluster.active(0).CLI.appToIDCheck() if appCheck != main.TRUE: main.log.warn(main.Cluster.active(0).CLI.apps()) main.log.warn(main.Cluster.active(0).CLI.appIDs()) utilities.assert_equals(expect=main.TRUE, actual=appCheck, onpass="******", onfail="Something is wrong with app Ids") main.step("Install onos-ovsdb") installResults = main.Cluster.active(0).CLI.activateApp( "org.onosproject.ovsdb") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-ovsdatabase failed") main.step("Install onos-app-vtn") installResults = main.Cluster.active(0).CLI.activateApp( "org.onosproject.vtn") utilities.assert_equals(expect=main.TRUE, actual=installResults, onpass="******", onfail="Install onos-app-vtn failed")