COMPflow
Change-Id: I9e738b2bea1c3faf2b8e1775c3ce005a093c472b
diff --git a/TestON/tests/COMPflow/COMPflow.params b/TestON/tests/COMPflow/COMPflow.params
new file mode 100755
index 0000000..ac85ea6
--- /dev/null
+++ b/TestON/tests/COMPflow/COMPflow.params
@@ -0,0 +1,63 @@
+
+<PARAMS>
+ # CASE - Descritpion
+ # 1,2,10,1000,1100,2000,1200,2000,100
+ # 1 - Variable initialization and optional pull and build ONOS package
+ # 2 - install ONOS
+ # 8 - Compare topology
+ # 9 - Report logs
+ # 10 - Start mininet and verify topology
+
+
+ <testcases>1,10,100,1000,100,110</testcases>
+
+ <SCALE>
+ <max>1</max>
+ </SCALE>
+
+ <DEBUG>on</DEBUG>
+
+ <DEPENDENCY>
+ <path>/tests/COMPflow/Dependency/</path>
+ <wrapper1>startUp</wrapper1>
+ <wrapper2>topo</wrapper2>
+ <topology>topo-flow.py</topology>
+ </DEPENDENCY>
+
+ <ENV>
+ <cellName>productionCell</cellName>
+ <cellApps>drivers,openflow-base</cellApps>
+ </ENV>
+
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <CTRL>
+ <port>6653</port>
+ </CTRL>
+
+ <CASE10>
+ <numSw>15</numSw>
+ <mnArgs> --topo linear,15 --switch ovsk,protocols=OpenFlow13 --controller remote</mnArgs>
+ </CASE10>
+
+ <CASE1000>
+ <flowsPerSw>14</flowsPerSw>
+ <batches>500</batches>
+ </CASE1000>
+
+ <TEST>
+ <batchSize>200</batchSize>
+ <numThrd>1</numThrd>
+ </TEST>
+
+ <SLEEP>
+ <startup>15</startup>
+ <startMN>5</startMN>
+ <addFlow>10</addFlow>
+ <delFlow>10</delFlow>
+ </SLEEP>
+
+</PARAMS>
diff --git a/TestON/tests/COMPflow/COMPflow.py b/TestON/tests/COMPflow/COMPflow.py
new file mode 100644
index 0000000..37b5256
--- /dev/null
+++ b/TestON/tests/COMPflow/COMPflow.py
@@ -0,0 +1,334 @@
+class COMPflow:
+
+ def __init__( self ):
+ self.default = ''
+
+ def CASE1( self, main ):
+ import time
+ 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
+ """
+
+ main.case( "Constructing test variables and building ONOS package" )
+ main.step( "Constructing test variables" )
+ stepResult = main.FALSE
+
+ # Test variables
+ main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
+ main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+ main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+ main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
+ 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.cellData = {} # for creating cell file
+ main.CLIs = []
+ main.ONOSip = []
+
+ main.debug = True if "on" in main.debug else False
+
+ main.ONOSip = main.ONOSbench.getOnosIps()
+
+ # Assigning ONOS cli handles to a list
+ for i in range( 1, main.maxNodes + 1 ):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+
+
+ if main.CLIs:
+ stepResult = main.TRUE
+ else:
+ main.log.error( "Did not properly created list of ONOS CLI handle" )
+ stepResult = main.FALSE
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully construct " +
+ "test variables ",
+ onfail="Failed to construct test variables" )
+
+ if gitPull == 'True':
+ main.step( "Building ONOS in " + gitBranch + " branch" )
+ onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+ stepResult = onosBuildResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully compiled " +
+ "latest ONOS",
+ onfail="Failed to compile " +
+ "latest ONOS" )
+ else:
+ main.log.warn( "Did not pull new code so skipping mvn " +
+ "clean install" )
+
+ def CASE2( self, main ):
+ """
+ - Set up cell
+ - Create cell file
+ - Set cell file
+ - Verify cell file
+ - Kill ONOS process
+ - Uninstall ONOS cluster
+ - Verify ONOS start up
+ - Install ONOS cluster
+ - Connect to cli
+ """
+
+ main.numCtrls = int( main.maxNodes )
+
+ main.case( "Starting up " + str( main.numCtrls ) +
+ " node(s) ONOS cluster" )
+
+ #kill off all onos processes
+ main.log.info( "Safety check, killing all ONOS processes" +
+ " before initiating environment setup" )
+
+ for i in range( main.maxNodes ):
+ main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+ print "NODE COUNT = ", main.numCtrls
+
+ tempOnosIp = []
+ for i in range( main.numCtrls ):
+ tempOnosIp.append( main.ONOSip[i] )
+
+ main.ONOSbench.createCellFile( main.ONOSbench.ip_address, "temp", main.Mininet1.ip_address, main.apps, tempOnosIp )
+
+ main.step( "Apply cell to environment" )
+ cellResult = main.ONOSbench.setCell( "temp" )
+ verifyResult = main.ONOSbench.verifyCell()
+ stepResult = cellResult and verifyResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully applied cell to " + \
+ "environment",
+ onfail="Failed to apply cell to environment " )
+
+ main.step( "Creating ONOS package" )
+ packageResult = main.ONOSbench.onosPackage(opTimeout=30)
+ stepResult = packageResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully created ONOS package",
+ onfail="Failed to create ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Uninstalling ONOS package" )
+ onosUninstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosUninstallResult = onosUninstallResult and \
+ main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
+ stepResult = onosUninstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully uninstalled ONOS package",
+ onfail="Failed to uninstall ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Installing ONOS package" )
+ onosInstallResult = main.TRUE
+ for i in range( main.numCtrls ):
+ onosInstallResult = onosInstallResult and \
+ main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+ stepResult = onosInstallResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully installed ONOS package",
+ onfail="Failed to install ONOS package" )
+
+ time.sleep( main.startUpSleep )
+ main.step( "Starting ONOS service" )
+ stopResult = main.TRUE
+ startResult = main.TRUE
+ onosIsUp = main.TRUE
+
+ for i in range( main.numCtrls ):
+ onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+ if onosIsUp == main.TRUE:
+ main.log.report( "ONOS instance is up and ready" )
+ else:
+ main.log.report( "ONOS instance may not be up, stop and " +
+ "start ONOS again " )
+ for i in range( main.numCtrls ):
+ stopResult = stopResult and \
+ main.ONOSbench.onosStop( main.ONOSip[ i ] )
+ for i in range( main.numCtrls ):
+ startResult = startResult and \
+ main.ONOSbench.onosStart( main.ONOSip[ i ] )
+ stepResult = onosIsUp and stopResult and startResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="ONOS service is ready",
+ onfail="ONOS service did not start properly" )
+
+ main.step( "Start ONOS cli" )
+ cliResult = main.TRUE
+ for i in range( main.numCtrls ):
+ cliResult = cliResult and \
+ main.CLIs[ i ].startOnosCli( main.ONOSip[ i ], onosStartTimeout=30 )
+ stepResult = cliResult
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully start ONOS cli",
+ onfail="Failed to start ONOS cli" )
+
+ def CASE10( self, main ):
+ '''
+ Start Mininet
+ '''
+ import json
+
+ main.numSw = int(main.params['CASE10']['numSw'])
+ main.case( "Setup mininet and compare ONOS topology view to Mininet topology" )
+ main.caseExplanation = "Start mininet with custom topology and compare topology " +\
+ "elements between Mininet and ONOS"
+
+ main.step( "Setup Mininet Linear Topology with " + str(main.numSw) + " switches" )
+ stepResult = main.Mininet1.startNet( args = main.params['CASE10']['mnArgs'] )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully loaded topology",
+ onfail="Failed to load topology" )
+
+ main.step( "Assign switches to controller" )
+ for i in range(1, main.numSw + 1):
+ main.Mininet1.assignSwController( "s" + str(i), main.ONOSip[0] )
+
+ utilities.assert_equals( expect=main.TRUE,
+ actual=stepResult,
+ onpass="Successfully assigned switch to controller",
+ onfail="Failed to assign switch to controller" )
+
+ time.sleep( main.startMNSleep )
+
+
+
+
+ def CASE1000( self, main ):
+ '''
+ create JSON object with batched flows
+ '''
+ import numpy
+ import time
+
+ main.case( "Create a json object for the batched flows" )
+
+ main.step( "Parse batch information" )
+ main.flowsPerSw = int(main.params['CASE1000']['flowsPerSw'])
+ main.log.info("Number of flows in a batch is:" + str(main.flowsPerSw * main.numSw))
+
+ main.flowJsonBatchList = []
+ postTimes = []
+
+ main.step("Creating a full list of batches")
+ for index in range(1, int(main.params['CASE1000']['batches']) + 1):
+ flowJsonBatch = main.ONOSrest.createFlowBatch( numSw = main.numSw,
+ batchSizePerSw = main.flowsPerSw,
+ batchIndex = index,
+ ingressPort = 2,
+ egressPort = 3)
+ main.flowJsonBatchList.append(flowJsonBatch)
+
+ main.step("Using REST API /flows/{} to post flow batch")
+ tStartPost = time.time()
+ for item in main.flowJsonBatchList:
+ ts = time.time()
+ resp = main.ONOSrest.sendFlowBatch(batch = item )
+ teBatch = time.time() - ts
+ postTimes.append(teBatch)
+ main.log.info("Batch Rest Post Elapse time is: " + str(teBatch))
+
+ tLastPostEnd = time.time()
+
+ main.step("Check to ensure all flows are in added state.")
+ resp = main.FALSE
+ while resp != main.TRUE:
+ resp = main.ONOSrest.checkFlowsState()
+ time.sleep(0.5)
+ tAllAdded = time.time()
+
+ numFlows = int(main.params['CASE1000']['batches']) *\
+ int(main.params['CASE1000']['flowsPerSw']) *\
+ int(main.params['CASE10']['numSw'])
+ main.log.info("Total number of flows: " + str (numFlows) )
+ main.log.info("Sum of each POST elapse time: " + str(numpy.sum(postTimes)) )
+ main.log.info("Total POST elapse time: " + str(tLastPostEnd-tStartPost))
+
+ duration = tAllAdded - tLastPostEnd
+ main.log.info("Elapse time from end of last REST POST to Flows in ADDED state: " +\
+ str(duration))
+ main.log.info("Rate of Batch Flow add is (flows/sec): " + str( numFlows / duration))
+
+ def CASE2000(self, main):
+ import time
+ import numpy
+
+ rmTimes = []
+
+ main.case("Remove flow timing")
+
+ tStartRemove = time.time()
+ for item in main.flowJsonBatchList:
+ ts = time.time()
+ resp = main.ONOSrest.removeFlowBatch(batch = item )
+ teBatch = time.time() - ts
+ rmTimes.append(teBatch)
+ main.log.info("Batch Rest Remove Elapse time is: " + str(teBatch))
+
+ tLastRemoveEnd = time.time()
+
+ main.step("Check to ensure all flows are in added state.")
+ resp = main.FALSE
+ while resp != main.TRUE:
+ resp = main.ONOSrest.checkFlowsState()
+ time.sleep(0.5)
+ tAllRemoved = time.time()
+
+ main.log.info("Total number of flows: " + str (int(main.params['CASE1000']['batches']) *\
+ int(main.params['CASE1000']['flowsPerSw']) *\
+ int(main.params['CASE10']['numSw'])) )
+ main.log.info("Sum of each DELETE elapse time: " + str(numpy.sum(rmTimes)) )
+ main.log.info("Total POST elapse time: " + str(tLastRemoveEnd-tStartRemove))
+
+ main.log.info("Elapse time from end of last REST POST to Flows in ADDED state: " +\
+ str(tAllRemoved - tLastRemoveEnd))
+
+ def CASE100(self,main):
+ from pprint import pprint
+
+ main.case( "Check to ensure onos flows." )
+
+ resp = main.ONOSrest.checkFlowsState()
+ pprint(resp)
+
+
+ def CASE110( self, main ):
+ '''
+ Report errors/warnings/exceptions
+ '''
+ main.log.info("Error report: \n" )
+ main.ONOSbench.logReport( main.ONOSip[ 0 ],
+ [ "INFO",
+ "FOLLOWER",
+ "WARN",
+ "flow",
+ "ERROR",
+ "Except" ],
+ "s" )
+ main.stop()
+
diff --git a/TestON/tests/COMPflow/COMPflow.topo b/TestON/tests/COMPflow/COMPflow.topo
new file mode 100755
index 0000000..e72bf1b
--- /dev/null
+++ b/TestON/tests/COMPflow/COMPflow.topo
@@ -0,0 +1,45 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>OC1</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOScli1>
+
+ <Mininet1>
+ <host>localhost</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </Mininet1>
+
+ <ONOSrest>
+ <host>OC1</host>
+ <port>8181</port>
+ <user>onos</user>
+ <password>rocks</password>
+ <type>OnosRestDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS>
+ </COMPONENTS>
+ </ONOSrest>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/COMPflow/Dependency/FlowBatch.py b/TestON/tests/COMPflow/Dependency/FlowBatch.py
new file mode 100644
index 0000000..ac749d5
--- /dev/null
+++ b/TestON/tests/COMPflow/Dependency/FlowBatch.py
@@ -0,0 +1,6 @@
+class FlowBatch():
+
+ batchSize = 0
+ batchJson = {}
+
+ def createBatchJson(main, batchSize):
diff --git a/TestON/tests/COMPflow/Dependency/mplsClass.py b/TestON/tests/COMPflow/Dependency/mplsClass.py
new file mode 100644
index 0000000..30b27e8
--- /dev/null
+++ b/TestON/tests/COMPflow/Dependency/mplsClass.py
@@ -0,0 +1,10 @@
+import scapy
+
+class MPLS(Packet):
+ name = "MPLS"
+ fields_desc = [
+ BitField("label", 3, 20),
+ BitField("experimental_bits", 0, 3),
+ BitField("bottom_of_label_stack", 1, 1), # Now we're at the bottom
+ ByteField("TTL", 255)
+ ]
diff --git a/TestON/tests/COMPflow/Dependency/startUp.py b/TestON/tests/COMPflow/Dependency/startUp.py
new file mode 100644
index 0000000..bf2a2b6
--- /dev/null
+++ b/TestON/tests/COMPflow/Dependency/startUp.py
@@ -0,0 +1,38 @@
+"""
+ This wrapper function is use for starting up onos instance
+"""
+
+import time
+import os
+import json
+
+def onosBuild( main, gitBranch ):
+ """
+ This includes pulling ONOS and building it using maven install
+ """
+
+ buildResult = main.FALSE
+
+ # Git checkout a branch of ONOS
+ checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
+ # Does the git pull on the branch that was checked out
+ if not checkOutResult:
+ main.log.warn( "Failed to checked out " + gitBranch +
+ " branch")
+ else:
+ main.log.info( "Successfully checked out " + gitBranch +
+ " branch")
+ gitPullResult = main.ONOSbench.gitPull()
+ if gitPullResult == main.ERROR:
+ main.log.error( "Error pulling git branch" )
+ else:
+ main.log.info( "Successfully pulled " + gitBranch + " branch" )
+
+ # Maven clean install
+ buildResult = main.ONOSbench.cleanInstall()
+
+ return buildResult
+
+
+
+
diff --git a/TestON/tests/COMPflow/README b/TestON/tests/COMPflow/README
new file mode 100644
index 0000000..018e42d
--- /dev/null
+++ b/TestON/tests/COMPflow/README
@@ -0,0 +1,49 @@
+FUNCflow test suite
+
+Summary:
+ This test suite consists of basic flow-rule based functionality testing.
+ The main goal of this test suite is to verify that the flow subsytem is
+ compiling flows correctly. We verify each flow by utilizing Scapy, a
+ Python library for generating and sending packets. The following is an
+ overview of the test.
+ Steps:
+ - Discover hosts
+ - add specific flow
+ - verify flow
+ - remove flow
+
+ Each repetion of the steps tests a specific selector. Here is a list
+ of the selectors that are being tested:
+ Selectors:
+ - MAC
+ - IPv4
+ - VLAN
+ - MPLS
+ - TCP
+ - UDP
+
+ We verify the selectors by sending a tailor made packet through the
+ two hosts. If the packet was recieved, then the flow was compiled
+ correctly.
+
+Topology:
+ The topology consists of one switch with four hosts connected to it.
+ Two hosts are regular IPv4 hosts, while the other two are hosts with
+ vlan interfaces to test the vlan selector.
+
+Required:
+ This test requires Mininet topology file topo-flow.py located in the
+ dependency folder. The topology consistes of VLAN hosts, so you will
+ need to install the VLAN module. You will also need to install the
+ Python module, Scapy.
+
+VLAN configuration:
+ Execute command:
+ $ sudo apt-get install vlan
+ Configuration:
+ $ sudo modprobe 8021q
+ NOTE:To make this configuration permanent
+ $ sudo su -c 'echo "8021q" >> /etc/modules'
+
+Scapy install:
+ sudo apt-get install Scapy
diff --git a/TestON/tests/COMPflow/__init__.py b/TestON/tests/COMPflow/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/COMPflow/__init__.py