summaryrefslogtreecommitdiffstats
path: root/framework/scripts/function_test/Teston
diff options
context:
space:
mode:
authorlanqinglong <lanqinglong@huawei.com>2015-10-28 14:06:16 +0800
committerlanqinglong <lanqinglong@huawei.com>2015-10-28 14:06:16 +0800
commit7bea183d1c282f20609e3fb562f1c0440772d0d9 (patch)
treea206b7cf73f3f3432c2cde758d3f02ee563cb2ff /framework/scripts/function_test/Teston
parenta5e4300e1bc9ec9d9f14c240c0ae2ff1be6417fb (diff)
Write NBI-subnet related scripts
JIRA:ONOSFW-66 1、Update subnets Change-Id: Ia9a1be9aca710b417b7194612f0a25764a92a60d Signed-off-by: lanqinglong <lanqinglong@huawei.com>
Diffstat (limited to 'framework/scripts/function_test/Teston')
-rw-r--r--framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py111
1 files changed, 110 insertions, 1 deletions
diff --git a/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py b/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
index de263593..082b7879 100644
--- a/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
@@ -13,6 +13,9 @@ CASE7 - Delete Subnet northbound test
CASE8 - Create Virtualport northbound test
CASE9 - Update Virtualport northbound test
CASE10 - Delete Virtualport northbound test
+CASE11 - Post Error Json Create Network test
+CASE12 - Post Error Json Create Subnet test
+CASE13 - Post Error Json Create Virtualport test
lanqinglong@huawei.com
"""
@@ -499,4 +502,110 @@ class FUNCvirNetNB:
onfail="Delete Network Failed" )
if Cmpresult != True:
- main.log.error( "Post Subnet compare failed" ) \ No newline at end of file
+ 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.log.info( "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" )