Browse Source

Merge "Func test cases for vnf and vnfd param" into stable/liberty

changes/78/265978/1
Jenkins 7 years ago committed by Gerrit Code Review
parent
commit
8d364f916d
  1. 38
      tacker/tests/etc/samples/sample_cirros_vnf_param.yaml
  2. 14
      tacker/tests/etc/samples/sample_cirros_vnf_values.yaml
  3. 99
      tacker/tests/functional/vnfm/test_vnfm_param.py

38
tacker/tests/etc/samples/sample_cirros_vnf_param.yaml

@ -0,0 +1,38 @@
template_name: tacker-test
description: tacker-test
service_properties:
Id: tacker-test
vendor: {get_input: vendor }
version: 1
type:
- router
- firewall
vdus:
vdu1:
id: vdu1
vm_image: { get_input: vm_image }
instance_type: {get_input: flavor }
service_type: {get_input: service}
mgmt_driver: noop
network_interfaces:
management:
network: { get_input: network }
management: { get_input: management }
pkt_in:
network: { get_input: pkt_in_network }
pkt_out:
network: { get_input: pkt_out_network }
placement_policy:
availability_zone: { get_input: zone }
auto-scaling: noop
monitoring_policy: noop
config:
param0: key0
param1: key1

14
tacker/tests/etc/samples/sample_cirros_vnf_values.yaml

@ -0,0 +1,14 @@
vdus:
vdu1:
param:
vm_image: cirros-0.3.4-x86_64-uec
flavor: m1.tiny
service: firewall
pkt_in_network: net0
pkt_out_network: net1
zone: nova
management: True
network: net_mgmt
service_properties:
param:
vendor: tacker

99
tacker/tests/functional/vnfm/test_vnfm_param.py

@ -0,0 +1,99 @@
# Copyright 2015 Brocade Communications System, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tacker.tests import constants
from tacker.tests.functional.vnfm import base
from tacker.tests.utils import read_file
import yaml
class VnfmTestParam(base.BaseTackerTest):
def _test_vnfd_create(self, vnfd_file):
yaml_input = dict()
yaml_input['tosca'] = read_file(vnfd_file)
toscal = yaml_input['tosca']
req_dict = {'vnfd': {'attributes': {'vnfd': toscal}}}
# Create vnfd
vnfd_instance = self.client.create_vnfd(body=req_dict)
self.assertIsNotNone(vnfd_instance)
vnfd_id = vnfd_instance['vnfd']['id']
self.assertIsNotNone(vnfd_id)
return vnfd_instance
def _test_vnfd_delete(self, vnfd_instance):
#Delete vnfd
vnfd_id = vnfd_instance['vnfd']['id']
self.assertIsNotNone(vnfd_id)
try:
self.client.delete_vnfd(vnfd_id)
except Exception:
assert False, "vnfd Delete failed"
try:
vfnd_d = self.client.show_vnfd(vnfd_id)
except Exception:
assert True, "Vnfd Delete success" + str(vfnd_d) + str(Exception)
def _test_vnf_create(self, vnfd_instance, vnf_name, vnf_value_file):
# Create the vnf with values
vnfd_id = vnfd_instance['vnfd']['id']
values_str = read_file(vnf_value_file)
#create vnf with values file
vnf_dict = dict()
vnf_dict = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name,
'attributes': {'param_values': values_str}}}
vnf_instance = self.client.create_vnf(body=vnf_dict)
self.validate_vnf_instance(vnfd_instance, vnf_instance)
vnf_id = vnf_instance['vnf']['id']
vnf_current_status = self.wait_until_vnf_active(vnf_id,
constants.VNF_CIRROS_CREATE_TIMEOUT,
constants.ACTIVE_SLEEP_TIME)
self.assertEqual('ACTIVE', vnf_current_status)
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
vnf_instance = self.client.show_vnf(vnf_id)
# Verify values dictionary is same as param values from vnf_show
input_dict = yaml.load(values_str)
param_values = vnf_instance['vnf']['attributes']['param_values']
param_values_dict = yaml.load(param_values)
self.assertEqual(input_dict, param_values_dict)
return vnf_instance
def _test_vnf_delete(self, vnf_instance):
# Delete Vnf
vnf_id = vnf_instance['vnf']['id']
try:
self.client.delete_vnf(vnf_id)
except Exception:
assert False, "vnf Delete failed"
try:
vfn_d = self.client.show_vnf(vnf_id)
except Exception:
assert True, "Vnf Delete success" + str(vfn_d) + str(Exception)
def test_vnfd_param(self):
vnfd_instance = self._test_vnfd_create('sample_cirros_vnf_param.yaml')
self._test_vnfd_delete(vnfd_instance)
def test_vnf_param(self):
vnfd_instance = self._test_vnfd_create('sample_cirros_vnf_param.yaml')
vnf_instance = self._test_vnf_create(vnfd_instance,
'test_vnf_with_parameters',
'sample_cirros_vnf_values.yaml')
self._test_vnf_delete(vnf_instance)
self._test_vnfd_delete(vnfd_instance)
Loading…
Cancel
Save