changes on COMPflow
Change-Id: I251976e9e3a781db99710aac0edfd9e8f9727a94
diff --git a/TestON/drivers/common/api/controller/onosrestdriver.py b/TestON/drivers/common/api/controller/onosrestdriver.py
index da3c994..49e20a2 100644
--- a/TestON/drivers/common/api/controller/onosrestdriver.py
+++ b/TestON/drivers/common/api/controller/onosrestdriver.py
@@ -1512,7 +1512,8 @@
def createFlowBatch( self,
numSw = 1,
- batchSizePerSw = 1,
+ swIndex = 1,
+ batchSize = 1,
batchIndex = 1,
deviceIdpreFix = "of:",
appId=0,
@@ -1564,92 +1565,100 @@
flowJsonList = []
flowJsonBatch = {"flows":flowJsonList}
+ dev = swIndex
- for dev in range(1, numSw + 1):
- for size in range(1, batchSizePerSw +1):
-
- flowJson = { "priority":100,
+ for fl in range(1, batchSize + 1):
+ flowJson = { "priority":100,
"deviceId":"",
"isPermanent":"true",
"timeout":0,
"treatment":{"instructions":[]},
"selector": {"criteria":[]}}
+ main.log.info("fl: " + str(fl))
+ if dev <= numSw:
+ deviceId = deviceIdpreFix + "{0:0{1}x}".format(dev,16)
+ #print deviceId
+ flowJson['deviceId'] = deviceId
+ dev += 1
+ else:
+ dev = 1
deviceId = deviceIdpreFix + "{0:0{1}x}".format(dev,16)
#print deviceId
flowJson['deviceId'] = deviceId
# ethSrc starts with "0"; ethDst starts with "1"
# 3 Hex digit of device number; 4 digits of batch index number; 4 digits of batch size
- ethS = "{0:0{1}x}".format(dev,4) + "{0:0{1}x}".format(batchIndex,4) + "{0:0{1}x}".format(size,4)
- ethSrc = ':'.join(ethS[i:i+2] for i in range(0,len(ethS),2))
- ethD = "1" + "{0:0{1}x}".format(dev,3) + "{0:0{1}x}".format(batchIndex,4) + "{0:0{1}x}".format(size,4)
- ethDst = ':'.join(ethD[i:i+2] for i in range(0,len(ethD),2))
+ ethS = "{0:0{1}x}".format(dev,4) + "{0:0{1}x}".format(batchIndex,4) + "{0:0{1}x}".format(fl,4)
+ ethSrc = ':'.join(ethS[i:i+2] for i in range(0,len(ethS),2))
+ ethD = "1" + "{0:0{1}x}".format(dev,3) + "{0:0{1}x}".format(batchIndex,4) + "{0:0{1}x}".format(fl,4)
+ ethDst = ':'.join(ethD[i:i+2] for i in range(0,len(ethD),2))
- if appId:
- flowJson[ "appId" ] = appId
+ if appId:
+ flowJson[ "appId" ] = appId
- if egressPort:
- flowJson[ 'treatment' ][ 'instructions' ].append( {
+ if egressPort:
+ flowJson[ 'treatment' ][ 'instructions' ].append( {
"type":"OUTPUT",
"port":egressPort } )
- if ingressPort:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ingressPort:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"IN_PORT",
"port":ingressPort } )
- if ethType:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ethType:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"ETH_TYPE",
"ethType":ethType } )
- if ethSrc:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ethSrc:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"ETH_SRC",
"mac":ethSrc } )
- if ethDst:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ethDst:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"ETH_DST",
"mac":ethDst } )
- if vlan:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if vlan:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"VLAN_VID",
"vlanId":vlan } )
- if mpls:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if mpls:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"MPLS_LABEL",
"label":mpls } )
- if ipSrc:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ipSrc:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":ipSrc[0],
"ip":ipSrc[1] } )
- if ipDst:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ipDst:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":ipDst[0],
"ip":ipDst[1] } )
- if tcpSrc:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if tcpSrc:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"TCP_SRC",
"tcpPort": tcpSrc } )
- if tcpDst:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if tcpDst:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"TCP_DST",
"tcpPort": tcpDst } )
- if udpSrc:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if udpSrc:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"UDP_SRC",
"udpPort": udpSrc } )
- if udpDst:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if udpDst:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"UDP_DST",
"udpPort": udpDst } )
- if ipProto:
- flowJson[ 'selector' ][ 'criteria' ].append( {
+ if ipProto:
+ flowJson[ 'selector' ][ 'criteria' ].append( {
"type":"IP_PROTO",
"protocol": ipProto } )
- #pprint(flowJson)
- flowJsonList.append(flowJson)
+ #pprint(flowJson)
+ flowJsonList.append(flowJson)
+ main.log.info("Number of flows in batch: " + str( len(flowJsonList) ) )
flowJsonBatch['flows'] = flowJsonList
- #pprint(flowJsonBatch)
+ pprint(flowJsonBatch)
return flowJsonBatch
diff --git a/TestON/tests/COMPflow/COMPflow.params b/TestON/tests/COMPflow/COMPflow.params
index ac85ea6..f3a0ef5 100755
--- a/TestON/tests/COMPflow/COMPflow.params
+++ b/TestON/tests/COMPflow/COMPflow.params
@@ -44,15 +44,10 @@
</CASE10>
<CASE1000>
- <flowsPerSw>14</flowsPerSw>
- <batches>500</batches>
+ <batchSize>20</batchSize>
+ <batches>10</batches>
</CASE1000>
- <TEST>
- <batchSize>200</batchSize>
- <numThrd>1</numThrd>
- </TEST>
-
<SLEEP>
<startup>15</startup>
<startMN>5</startMN>
diff --git a/TestON/tests/COMPflow/COMPflow.py b/TestON/tests/COMPflow/COMPflow.py
index 37b5256..7fae518 100644
--- a/TestON/tests/COMPflow/COMPflow.py
+++ b/TestON/tests/COMPflow/COMPflow.py
@@ -229,20 +229,29 @@
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.batchSize = int(main.params['CASE1000']['batchSize'])
+ main.log.info("Number of flows in a batch is:" + str(main.batchSize))
main.flowJsonBatchList = []
postTimes = []
+ startSw = 1
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,
+ if startSw <= main.numSw:
+ main.log.info("Creating batch: " + str(index))
+ flowJsonBatch = main.ONOSrest.createFlowBatch( numSw = main.numSw,
+ swIndex = startSw,
+ batchSize = main.batchSize,
batchIndex = index,
ingressPort = 2,
egressPort = 3)
- main.flowJsonBatchList.append(flowJsonBatch)
+ main.flowJsonBatchList.append(flowJsonBatch)
+
+ startSw += 1
+ else:
+ startSw = 1
+
main.step("Using REST API /flows/{} to post flow batch")
tStartPost = time.time()
@@ -263,8 +272,7 @@
tAllAdded = time.time()
numFlows = int(main.params['CASE1000']['batches']) *\
- int(main.params['CASE1000']['flowsPerSw']) *\
- int(main.params['CASE10']['numSw'])
+ int(main.params['CASE1000']['batchSize'])
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))
@@ -300,7 +308,7 @@
tAllRemoved = time.time()
main.log.info("Total number of flows: " + str (int(main.params['CASE1000']['batches']) *\
- int(main.params['CASE1000']['flowsPerSw']) *\
+ int(main.params['CASE1000']['batchSize']) *\
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))