ONOS-2504 Subnet Post/update/delete
Change-Id: I9872c059abbb0b081808c197734e2179806acb0e
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
index 3ca917f..7f0e058 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.params
@@ -11,7 +11,7 @@
# 9 - Update Virtualport northbound test
#10 - Delete Virtualport northbound test
- <testcases>1,2,3,4</testcases>
+ <testcases>1,2,3,4,5,6,7</testcases>
<SLEEP>
<startup>15</startup>
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
index e3c3cc4..b8c592c 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
@@ -69,7 +69,7 @@
#FIXME:this is short term fix
main.log.info( "Removing raft logs" )
- main.ONOSbench.onosRemoveRaftlogs()
+ main.ONOSbench.onosRemoveRaftLogs()
main.CLIs = []
main.nodes = []
@@ -176,7 +176,7 @@
onfail="Install onos-app-vtnrsc app failed" )
time.sleep( main.startUpSleep )
-
+
main.step( "Install onos-app-vtnweb app" )
installResults = main.ONOScli1.featureInstall( "onos-app-vtnweb" )
utilities.assert_equals( expect=main.TRUE, actual=installResults,
@@ -190,13 +190,15 @@
"""
Test Post Network
"""
- import os,sys
- sys.path.append("..")
+ import os
+
try:
from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
except ImportError:
main.log.exception( "Something wrong with import file or code error." )
- main.log.info( "Import Error,please check!" )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
main.log.info( "ONOS Network Post test Start" )
main.case( "Virtual Network NBI Test - Network" )
@@ -254,7 +256,7 @@
onpass="Delete Network Success",
onfail="Delete Network Failed")
- if Cmpresult !=True:
+ if Cmpresult != True:
main.log.error( "Post Network compare failed" )
def CASE3( self,main ):
@@ -262,13 +264,15 @@
"""
Test Update Network
"""
- import os,sys
- sys.path.append("..")
+ import os
+
try:
from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
except ImportError:
main.log.exception( "Something wrong with import file or code error." )
- main.log.info( "Import Error,please check!" )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
main.log.info( "ONOS Network Update test Start" )
main.case( "Virtual Network NBI Test - Network" )
@@ -339,7 +343,7 @@
onpass="Delete Network Success",
onfail="Delete Network Failed" )
- if Cmpresult!=True:
+ if Cmpresult != True:
main.log.error( "Update Network compare failed" )
def CASE4( self,main ):
@@ -347,13 +351,15 @@
"""
Test Delete Network
"""
- import os,sys
- sys.path.append("..")
+ import os
+
try:
from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
except ImportError:
main.log.exception( "Something wrong with import file or code error." )
- main.log.info( "Import Error,please check!" )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
main.log.info( "ONOS Network Delete test Start" )
main.case( "Virtual Network NBI Test - Network" )
@@ -371,9 +377,8 @@
postdata = network.DictoJson()
main.step( "Post Data via HTTP" )
- Poststatus, result = main.ONOSrest.send( ctrlip, port , '' , path + 'networks/',
- 'POST', None , postdata )
-
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
+ 'POST', None, postdata )
utilities.assert_equals(
expect='200',
actual=Poststatus,
@@ -381,7 +386,7 @@
onfail="Post Failed " + str( Poststatus ) + str( result ) )
main.step( "Delete Data via HTTP" )
- Deletestatus, result = main.ONOSrest.send( ctrlip,port,network.id,path+'networks/',
+ Deletestatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
'DELETE', None, None )
utilities.assert_equals(
expect='200',
@@ -400,3 +405,274 @@
if result != 'The tenantNetwork does not exists':
main.log.error( "Delete Network failed" )
+
+ def CASE5( self, main ):
+
+ """
+ Test Post Subnet
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Subnet Post test Start" )
+ main.case( "Virtual Network NBI Test - Subnet" )
+ main.caseExplanation = "Test Subnet Post NBI " +\
+ "Verify Stored Data is same with Post Data"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ subnet = SubnetData()
+ subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+ subnet.tenant_id = network.tenant_id
+ subnet.network_id = network.id
+
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
+ 'POST', None, networkpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Network Success",
+ onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Subnet Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
+ 'POST', None, subnetpostdata )
+ utilities.assert_equals(
+ expect='202',
+ actual=Poststatus,
+ onpass="Post Subnet Success",
+ onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Get Subnet Data via HTTP" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=Getstatus,
+ onpass="Get Subnet Success",
+ onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
+
+ IDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'id' )
+ TanantIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'tenant_id' )
+ NetoworkIDcmpresult = subnet.JsonCompare( subnetpostdata, result, 'subnet', 'network_id' )
+
+ main.step( "Compare Post Subnet Data via HTTP" )
+ Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult
+ utilities.assert_equals(
+ expect=True,
+ actual=Cmpresult,
+ onpass="Compare Success",
+ onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
+ ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
+ ",Network id compare:" + str( NetoworkIDcmpresult ) )
+
+ deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'DELETE', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=deletestatus,
+ onpass="Delete Network Success",
+ onfail="Delete Network Failed" )
+
+ if Cmpresult != True:
+ main.log.error( "Post Subnet compare failed" )
+
+ def CASE6( self, main ):
+
+ """
+ Test Post Subnet
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Subnet Update test Start" )
+ main.case( "Virtual Network NBI Test - Subnet" )
+ main.caseExplanation = "Test Subnet Update NBI " +\
+ "Verify Stored Data is same with Update Data"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ subnet = SubnetData()
+ subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+ subnet.tenant_id = network.tenant_id
+ subnet.network_id = network.id
+ subnet.start = "192.168.2.1"
+ subnet.end = "192.168.2.255"
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+
+ #Change allocation_poolsdata scope
+ subnet.start = "192.168.102.1"
+ subnet.end = "192.168.102.255"
+ #end change
+ newsubnetpostdata = subnet.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
+ 'POST', None, networkpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Network Success",
+ onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Subnet Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
+ 'POST', None, subnetpostdata )
+ utilities.assert_equals(
+ expect='202',
+ actual=Poststatus,
+ onpass="Post Subnet Success",
+ onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Update Subnet Data via HTTP" )
+ Putstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
+ 'PUT', None, newsubnetpostdata )
+ utilities.assert_equals(
+ expect='203',
+ actual=Putstatus,
+ onpass="Update Subnet Success",
+ onfail="Update Subnet Failed " + str( Putstatus ) + "," + str( result ) )
+
+ main.step( "Get Subnet Data via HTTP" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=Getstatus,
+ onpass="Get Subnet Success",
+ onfail="Get Subnet Failed " + str( Getstatus ) + "," + str( result ) )
+
+ IDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'id' )
+ TanantIDcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'tenant_id' )
+ Poolcmpresult = subnet.JsonCompare( newsubnetpostdata, result, 'subnet', 'allocation_pools' )
+
+ main.step( "Compare Subnet Data" )
+ Cmpresult = IDcmpresult and TanantIDcmpresult and Poolcmpresult
+ utilities.assert_equals(
+ expect=True,
+ actual=Cmpresult,
+ onpass="Compare Success",
+ onfail="Compare Failed:ID compare:" + str( IDcmpresult ) + \
+ ",Tenant id compare:"+ str( TanantIDcmpresult ) + \
+ ",Pool compare:" + str( Poolcmpresult ) )
+
+ main.step( "Delete Subnet via HTTP" )
+ deletestatus,result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
+ 'DELETE', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=deletestatus,
+ onpass="Delete Network Success",
+ onfail="Delete Network Failed" )
+
+ if Cmpresult != True:
+ main.log.error( "Update Subnet compare failed" )
+
+ def CASE7( self, main ):
+
+ """
+ Test Delete Subnet
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ main.log.info( "ONOS Subnet Delete test Start" )
+ main.case( "Virtual Network NBI Test - Subnet" )
+ main.caseExplanation = "Test Subnet Delete NBI " +\
+ "Verify Stored Data is Null after Delete"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ port = main.params['HTTP']['port']
+ path = main.params['HTTP']['path']
+
+ main.step( "Generate Post Data" )
+ network = NetworkData()
+ network.id = '030d6d3d-fa36-45bf-ae2b-4f4bc43a54dc'
+ network.tenant_id = '26cd996094344a0598b0a1af1d525cdc'
+ subnet = SubnetData()
+ subnet.id = "e44bd655-e22c-4aeb-b1e9-ea1606875178"
+ subnet.tenant_id = network.tenant_id
+ subnet.network_id = network.id
+
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post Subnet need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'networks/',
+ 'POST', None, networkpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Network Success",
+ onfail="Post Network Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Post Subnet Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, port, '', path + 'subnets/',
+ 'POST', None, subnetpostdata )
+ utilities.assert_equals(
+ expect='202',
+ actual=Poststatus,
+ onpass="Post Subnet Success",
+ onfail="Post Subnet Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Delete Subnet Data via HTTP" )
+ Deletestatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
+ 'DELETE', None, None )
+ utilities.assert_equals(
+ expect='201',
+ actual=Deletestatus,
+ onpass="Delete Subnet Success",
+ onfail="Delete Subnet Failed " + str( Deletestatus ) + "," + str( result ) )
+
+ main.step( "Get Subnet Data is NULL" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='the subnet does not exists',
+ actual=result,
+ onpass="Get Subnet Success",
+ onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
+
+ if result != 'the subnet does not exists':
+ main.log.error( "Delete Subnet failed" )
\ No newline at end of file
diff --git a/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py b/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py
index c002c4a..dadf6b2 100644
--- a/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py
+++ b/TestON/tests/FUNCvirNetNB/dependencies/Nbdata.py
@@ -67,12 +67,17 @@
print "SourceData or DestData is not JSON Type!"
return False
- Socom = SourceCompareDataDic[FirstPara][SecondPara]
- Decom = DestiCompareDataDic[FirstPara][SecondPara]
- if Socom == Decom:
+ try:
+ Socom = SourceCompareDataDic[FirstPara][SecondPara]
+ Decom = DestiCompareDataDic[FirstPara][SecondPara]
+ except KeyError,error:
+ print "Key error ,This key is not found:%s"%error
+ return False
+
+ if str(Socom).lower()== str(Decom).lower():
return True
else:
- print "Source Compare data:"+FirstPara+"."+SecondPara+"="+Socom
+ print "Source Compare data:"+FirstPara+"."+SecondPara+"="+str(Socom)
print "Dest Compare data: "+FirstPara+"."+SecondPara+"="+str(Decom)
return False
@@ -139,12 +144,6 @@
return json.dumps(Dicdata,indent=4)
- def Ordered(self,obj):
- super(NetworkData,self).Ordered(obj)
-
- def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
- super(NetworkData,self).JsonCompare(SourceData,DestiData,FirstPara,SecondPara)
-
class VirtualPortData(NetworkData):
def __init__(self):
@@ -212,10 +211,4 @@
Dicdata = {'virtualport': Dicdata}
- return json.dumps(Dicdata,indent=4)
-
- def Ordered(self,obj):
- super(NetworkData,self).Ordered(obj)
-
- def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
- super(NetworkData,self).JsonCompare(SourceData,DestiData,FirstPara,SecondPara)
\ No newline at end of file
+ return json.dumps(Dicdata,indent=4)
\ No newline at end of file