Add functional test for ns-vnffg

Change-Id: Ie669da571a605a7635fd490475aeef80b75c9b2c
Partially-implements: blueprint vnffg-ns
This commit is contained in:
dharmendra 2018-07-13 09:28:28 +00:00 committed by dharmendra kushwaha
parent 422055b9ba
commit c99fa62a9e
7 changed files with 340 additions and 1 deletions

View File

@ -1,5 +1,5 @@
nsd:
vl1_name: net_mgmt
vl2_name: net0
net_src_port_id: c0a40f9c-d229-40b7-871f-55131cf17783
net_src_port_id: 22566484-6585-483b-9f70-0c2811895f96
ip_dest_prefix: 10.10.0.11/24

View File

@ -0,0 +1,5 @@
nsd:
vl1_name: net_mgmt
vl2_name: net0
net_src_port_id: c0a40f9c-d229-40b7-871f-55131cf17783
ip_dest_prefix: 10.10.0.11/24

View File

@ -0,0 +1,67 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: VirtualLinks of CP11 and CP22 will be provided by NS descriptor
node_types:
tosca.nodes.nfv.VNF1:
requirements:
- virtualLink1:
type: tosca.nodes.nfv.VL
required: true
capabilities:
forwader1:
type: tosca.capabilities.nfv.Forwarder
topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF1
requirements:
virtualLink1: [CP11, virtualLink]
capabilities:
forwarder1: [CP11, forwarder]
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.5-x86_64-disk
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
user_data_format: RAW
user_data: |
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
CP11:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
anti_spoofing_protection: false
requirements:
- virtualBinding:
node: VDU1
CP12:
type: tosca.nodes.nfv.CP.Tacker
properties:
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker

View File

@ -0,0 +1,61 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Demo example
node_types:
tosca.nodes.nfv.VNF2:
capabilities:
forwarder1:
type: tosca.capabilities.nfv.Forwarder
topology_template:
substitution_mappings:
node_type: tosca.nodes.nfv.VNF2
capabilities:
forwarder1: [CP21, forwarder]
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.5-x86_64-disk
flavor: m1.tiny
availability_zone: nova
mgmt_driver: noop
config: |
param0: key1
param1: key2
user_data_format: RAW
user_data: |
#!/bin/sh
echo 1 > /proc/sys/net/ipv4/ip_forward
CP21:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
CP22:
type: tosca.nodes.nfv.CP.Tacker
requirements:
- virtualLink:
node: VL2
- virtualBinding:
node: VDU1
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: net_mgmt
vendor: Tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: net0
vendor: Tacker

View File

@ -0,0 +1,109 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: Import VNFDs(already on-boarded) with input parameters
imports:
- sample-vnfd1
- sample-vnfd2
topology_template:
inputs:
vl1_name:
type: string
description: name of VL1 virtuallink
default: net_mgmt
vl2_name:
type: string
description: name of VL2 virtuallink
default: net0
net_src_port_id:
type: string
description: neutron port id of source port
ip_dest_prefix:
type: string
description: IP prefix of destination port
node_templates:
VNF1:
type: tosca.nodes.nfv.VNF1
requirements:
- virtualLink1: VL1
VNF2:
type: tosca.nodes.nfv.VNF2
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: {get_input: vl1_name}
vendor: tacker
VL2:
type: tosca.nodes.nfv.VL
properties:
network_name: {get_input: vl2_name}
vendor: tacker
Forwarding_path1:
type: tosca.nodes.nfv.FP.TackerV2
description: creates path inside ns (src_port->CP12->CP22->dst_port)
properties:
id: 51
policy:
type: ACL
criteria:
- name: block_tcp
classifier:
network_src_port_id: {get_input: net_src_port_id}
destination_port_range: 80-1024
ip_proto: 6
ip_dst_prefix: {get_input: ip_dest_prefix}
path:
- forwarder: sample-vnfd1
capability: CP12
- forwarder: sample-vnfd2
capability: CP22
Forwarding_path2:
type: tosca.nodes.nfv.FP.TackerV2
description: creates path inside ns (src_port->CP12->dst_port)
properties:
id: 52
policy:
type: ACL
criteria:
- name: block_tcp
classifier:
network_src_port_id: {get_input: net_src_port_id}
destination_port_range: 8080-8080
ip_proto: 6
ip_dst_prefix: {get_input: ip_dest_prefix}
path:
- forwarder: sample-vnfd1
capability: CP12
groups:
VNFFG1:
type: tosca.groups.nfv.VNFFG
description: HTTP to Corporate Net
properties:
vendor: tacker
version: 1.0
number_of_endpoints: 2
dependent_virtual_link: [VL1, VL2]
connection_point: [CP12, CP22]
constituent_vnfs: [sample-vnfd1, sample-vnfd2]
members: [Forwarding_path1]
VNFFG2:
type: tosca.groups.nfv.VNFFG
description: HTTP to Corporate Net
properties:
vendor: tacker
version: 1.0
number_of_endpoints: 1
dependent_virtual_link: [VL1]
connection_point: [CP12]
constituent_vnfs: [sample-vnfd1]
members: [Forwarding_path2]

View File

@ -15,6 +15,7 @@
import time
import yaml
from glanceclient.v2 import client as glance_client
from keystoneauth1.identity import v3
from keystoneauth1 import session
from neutronclient.v2_0 import client as neutron_client
@ -105,6 +106,19 @@ class BaseTackerTest(base.BaseTestCase):
data['project_domain_name'] = domain_name
return clients.OpenstackClients(auth_attr=data).heat
@classmethod
def glanceclient(cls):
vim_params = cls.get_credentials()
auth = v3.Password(auth_url=vim_params['auth_url'],
username=vim_params['username'],
password=vim_params['password'],
project_name=vim_params['project_name'],
user_domain_name=vim_params['user_domain_name'],
project_domain_name=vim_params['project_domain_name'])
verify = 'True' == vim_params.pop('cert_verify', 'False')
auth_ses = session.Session(auth=auth, verify=verify)
return glance_client.Client(session=auth_ses)
def wait_until_vnf_status(self, vnf_id, target_status, timeout,
sleep_interval):
start_time = int(time.time())

View File

@ -27,6 +27,7 @@ CONF = cfg.CONF
class NsdTestCreate(base.BaseTackerTest):
def _test_create_tosca_vnfd(self, tosca_vnfd_file, vnfd_name):
input_yaml = read_file(tosca_vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
@ -154,6 +155,46 @@ class NsdTestCreate(base.BaseTackerTest):
self._test_delete_vnfd(vnfd1_id)
self._test_delete_vnfd(vnfd2_id)
def _test_create_delete_ns_vnffg(self, nsd_file, ns_name,
source_port_id, dest_ip_prefix):
vnfd1_id = self._test_create_tosca_vnfd(
'tosca-ns-vnffg-vnfd1-sample.yaml',
'sample-vnfd1')
vnfd2_id = self._test_create_tosca_vnfd(
'tosca-ns-vnffg-vnfd2-sample.yaml',
'sample-vnfd2')
nsd_id = self._test_create_nsd(nsd_file, ns_name)
ns_arg = {'ns': {
'nsd_id': nsd_id,
'name': ns_name,
'attributes': {"param_values": {
"nsd": {
"vl2_name": "net0",
"vl1_name": "net_mgmt",
"net_src_port_id": source_port_id,
"ip_dest_prefix": dest_ip_prefix}}}}}
ns_instance = self.client.create_ns(body=ns_arg)
ns_id = ns_instance['ns']['id']
self._wait_until_ns_status(ns_id, 'ACTIVE',
constants.NS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
ns_show_out = self.client.show_ns(ns_id)['ns']
self.assertIsNotNone(ns_show_out['mgmt_urls'])
vnffg = self.client.list_vnffgs()
self.assertIsNotNone(vnffg)
try:
self.client.delete_ns(ns_id)
except Exception as e:
print("Exception:", e)
assert False, "ns Delete failed"
self._wait_until_ns_delete(ns_id, constants.NS_DELETE_TIMEOUT)
self._test_delete_nsd(nsd_id)
self._test_delete_vnfd(vnfd1_id)
self._test_delete_vnfd(vnfd2_id)
def test_create_delete_nsd(self):
vnfd1_id = self._test_create_tosca_vnfd(
'test-nsd-vnfd1.yaml',
@ -176,3 +217,45 @@ class NsdTestCreate(base.BaseTackerTest):
self._test_create_delete_ns('test-ns-nsd.yaml',
'test-ns-inline',
template_source='inline')
def _wait_for_server_active(self, server_id, target_status='ACTIVE',
timeout=60, sleep_interval=2):
start_time = int(time.time())
while True:
server_info = self.novaclient().servers.get(server_id)
if (server_info.status == target_status) or (
(int(time.time()) - start_time) > timeout):
break
time.sleep(sleep_interval)
def test_create_delete_ns_vnffg(self):
net = self.neutronclient().list_networks()
for network in net['networks']:
if network['name'] == 'net0':
net_id = network['id']
networks = [{'net-id': net_id}]
img = self.glanceclient().images.list(
name='cirros-0.3.5-x86_64-disk').next()
http_client = self.novaclient().servers.create(name='http_client',
image=img['id'],
flavor=1,
nics=networks)
http_server = self.novaclient().servers.create(name='http_server',
image=img['id'],
flavor=1,
nics=networks)
self._wait_for_server_active(http_client.id)
self._wait_for_server_active(http_server.id)
port_list = self.neutronclient().list_ports()
source_port_id = None
dest_ip_prefix = http_server.networks['net0'][0] + '/24'
for port in port_list['ports']:
if port['fixed_ips'][0]['ip_address'] == \
http_client.networks['net0'][0]:
source_port_id = port['id']
self._test_create_delete_ns_vnffg('tosca-ns-vnffg.yaml',
'tosca-ns-vnffg',
source_port_id, dest_ip_prefix)
self.novaclient().servers.delete(http_server.id)
self.novaclient().servers.delete(http_client.id)