summaryrefslogtreecommitdiffstats
path: root/framework/scripts/function_test/Teston
diff options
context:
space:
mode:
authorlanqinglong <lanqinglong@huawei.com>2015-11-02 17:49:05 +0800
committerlanqinglong <lanqinglong@huawei.com>2015-11-02 17:49:05 +0800
commit79359457f9f6044d3f2c48ef66d74f142577d4c0 (patch)
treee6c4c0e8d7e3d5b29987ff06d320aebb3232d6c3 /framework/scripts/function_test/Teston
parent89a574196783f93e32d81244f37f726be11bbf30 (diff)
Write NBI-virtualport related scripts
JIRA:ONOSFW-66 1.Delete subnets 2.Post Virtual-port Change-Id: I13d14f430daa1bfdf30e406dfefb7c7213e34014 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.py184
1 files changed, 184 insertions, 0 deletions
diff --git a/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py b/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
index 082b7879..4ea8a359 100644
--- a/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/framework/scripts/function_test/Teston/testcases/FUNCvirNetNB/FUNCvirNetNB.py
@@ -609,3 +609,187 @@ class FUNCvirNetNB:
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.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
+
+ 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='Subnet is not found',
+ actual=result,
+ onpass="Get Subnet Success",
+ onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
+
+ if result != 'Subnet is not found':
+ main.log.error( "Delete Subnet failed" )
+
+ def CASE8( self, main ):
+
+ """
+ Test Post Port
+ """
+ import os
+
+ try:
+ from tests.FUNCvirNetNB.dependencies.Nbdata import NetworkData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import SubnetData
+ from tests.FUNCvirNetNB.dependencies.Nbdata import VirtualPortData
+ 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 Port Post test Start" )
+ main.case( "Virtual Network NBI Test - Port" )
+ main.caseExplanation = "Test Port Post NBI " +\
+ "Verify Stored Data is same with Post Data"
+
+ ctrlip = os.getenv( main.params['CTRL']['ip1'] )
+ httpport = 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
+ port = VirtualPortData()
+ port.id = "9352e05c-58b8-4f2c-b4df-c20435ser56466"
+ port.subnet_id = subnet.id
+ port.tenant_id = network.tenant_id
+ port.network_id = network.id
+
+ networkpostdata = network.DictoJson()
+ subnetpostdata = subnet.DictoJson()
+ portpostdata = port.DictoJson()
+
+ main.step( "Post Network Data via HTTP(Post port need post network)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', 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(Post port need post subnet)" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', 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( "Post Port Data via HTTP" )
+ Poststatus, result = main.ONOSrest.send( ctrlip, httpport, '', path + 'ports/',
+ 'POST', None, portpostdata )
+ utilities.assert_equals(
+ expect='200',
+ actual=Poststatus,
+ onpass="Post Port Success",
+ onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+ main.step( "Get Port Data via HTTP" )
+ Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
+ 'GET', None, None )
+ utilities.assert_equals(
+ expect='200',
+ actual=Getstatus,
+ onpass="Get Port Success",
+ onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
+
+ main.step( "Compare Post Port Data" )
+ IDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'id' )
+ TanantIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'tenant_id' )
+ NetoworkIDcmpresult = subnet.JsonCompare( portpostdata, result, 'port', 'network_id' )
+ fixedIpresult = subnet.JsonCompare( portpostdata, result, 'port', 'fixed_ips' )
+
+ Cmpresult = IDcmpresult and TanantIDcmpresult and NetoworkIDcmpresult and fixedIpresult
+ 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 ) +\
+ ",FixIp compare:" + str( fixedIpresult ) )
+
+ main.step( "Clean Data via HTTP" )
+ deletestatus,result = main.ONOSrest.send( ctrlip, httpport, 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 port compare failed" ) \ No newline at end of file