Update functional tests for tosca dict

As yaml strings had been depricated. In this patch redactor
functional test cases for depricated yaml strings and provide
tosca dict as input for create_vnfd.

Change-Id: I5d7411200c2cbff5a002dfa2d5e36a65d6b39332
Partial-Bug: #1634376
This commit is contained in:
dharmendra 2019-02-20 06:35:26 +00:00
parent e8b42ca4dd
commit 48a5f80be7
8 changed files with 36 additions and 42 deletions

View File

@ -32,12 +32,10 @@ VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfTestToscaCreate(base.BaseTackerTest):
def _test_create_vnf(self, vnfd_file, vnf_name,
template_source="onboarded"):
data = dict()
values_str = read_file(vnfd_file)
data['tosca'] = values_str
toscal = data['tosca']
input_yaml = read_file(vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
if template_source == "onboarded":
# Create vnfd with tosca template
@ -52,8 +50,7 @@ class VnfTestToscaCreate(base.BaseTackerTest):
if template_source == 'inline':
# create vnf directly from template
template = yaml.safe_load(values_str)
vnf_arg = {'vnf': {'vnfd_template': template, 'name': vnf_name}}
vnf_arg = {'vnf': {'vnfd_template': tosca_dict, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnfd_id = vnf_instance['vnf']['vnfd_id']
@ -65,8 +62,7 @@ class VnfTestToscaCreate(base.BaseTackerTest):
vnf_show_out = self.client.show_vnf(vnf_id)['vnf']
self.assertIsNotNone(vnf_show_out['mgmt_ip_address'])
input_dict = yaml.safe_load(values_str)
prop_dict = input_dict['topology_template']['node_templates'][
prop_dict = tosca_dict['topology_template']['node_templates'][
'CP1']['properties']
# Verify if ip_address is static, it is same as in show_vnf
@ -78,7 +74,7 @@ class VnfTestToscaCreate(base.BaseTackerTest):
# Verify anti spoofing settings
stack_id = vnf_show_out['instance_id']
template_dict = input_dict['topology_template']['node_templates']
template_dict = tosca_dict['topology_template']['node_templates']
for field in template_dict.keys():
prop_dict = template_dict[field]['properties']
if prop_dict.get('anti_spoofing_protection'):

View File

@ -26,12 +26,10 @@ class VnfTestAlarmMonitor(base.BaseTackerTest):
def _test_vnf_tosca_alarm(self, vnfd_file, vnf_name):
vnf_trigger_path = '/vnfs/%s/triggers'
data = dict()
data['tosca'] = read_file(vnfd_file)
tosca_dict = yaml.safe_load(data['tosca'])
toscal = data['tosca']
input_yaml = read_file(vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -29,12 +29,10 @@ VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfBlockStorageTestToscaCreate(base.BaseTackerTest):
def _test_create_vnf(self, vnfd_file, vnf_name,
template_source="onboarded"):
data = dict()
values_str = read_file(vnfd_file)
data['tosca'] = values_str
toscal = data['tosca']
input_yaml = read_file(vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
if template_source == "onboarded":
# Create vnfd with tosca template
@ -49,8 +47,7 @@ class VnfBlockStorageTestToscaCreate(base.BaseTackerTest):
if template_source == 'inline':
# create vnf directly from template
template = yaml.safe_load(values_str)
vnf_arg = {'vnf': {'vnfd_template': template, 'name': vnf_name}}
vnf_arg = {'vnf': {'vnfd_template': tosca_dict, 'name': vnf_name}}
vnf_instance = self.client.create_vnf(body=vnf_arg)
vnfd_id = vnf_instance['vnf']['vnfd_id']
@ -62,8 +59,7 @@ class VnfBlockStorageTestToscaCreate(base.BaseTackerTest):
vnf_show_out = self.client.show_vnf(vnf_id)['vnf']
self.assertIsNotNone(vnf_show_out['mgmt_ip_address'])
input_dict = yaml.safe_load(values_str)
prop_dict = input_dict['topology_template']['node_templates'][
prop_dict = tosca_dict['topology_template']['node_templates'][
'CP1']['properties']
# Verify if ip_address is static, it is same as in show_vnf
@ -75,7 +71,7 @@ class VnfBlockStorageTestToscaCreate(base.BaseTackerTest):
# Verify anti spoofing settings
stack_id = vnf_show_out['instance_id']
template_dict = input_dict['topology_template']['node_templates']
template_dict = tosca_dict['topology_template']['node_templates']
for field in template_dict.keys():
prop_dict = template_dict[field]['properties']
if prop_dict.get('anti_spoofing_protection'):

View File

@ -13,6 +13,7 @@
import json
import time
import yaml
from oslo_config import cfg
@ -28,12 +29,11 @@ CONF = cfg.CONF
class VnfTestToscaScale(base.BaseTackerTest):
def test_vnf_tosca_scale(self):
data = dict()
data['tosca'] = read_file('sample-tosca-scale-all.yaml')
input_yaml = read_file('sample-tosca-scale-all.yaml')
tosca_dict = yaml.safe_load(input_yaml)
vnfd_name = 'test_tosca_vnf_scale_all'
toscal = data['tosca']
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import yaml
from oslo_config import cfg
from tacker.plugins.common import constants as evt_constants
@ -25,11 +27,10 @@ VNF_CIRROS_CREATE_TIMEOUT = 120
class VnfTestCreate(base.BaseTackerTest):
def _test_create_delete_vnf(self, vnf_name, vnfd_name, vim_id=None):
data = dict()
data['tosca'] = read_file('sample-tosca-vnfd-no-monitor.yaml')
toscal = data['tosca']
input_yaml = read_file('sample-tosca-vnfd-no-monitor.yaml')
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import yaml
from tacker.plugins.common import constants as evt_constants
from tacker.tests import constants
from tacker.tests.functional import base
@ -21,11 +23,10 @@ from tacker.tests.utils import read_file
class VnfTestPingMonitor(base.BaseTackerTest):
def _vnfd_and_vnf_create(self, vnfd_file, vnf_name):
data = dict()
data['tosca'] = read_file(vnfd_file)
toscal = data['tosca']
input_yaml = read_file(vnfd_file)
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnf_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -11,6 +11,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import yaml
from tackerclient.common import exceptions
from tacker.tests import constants
@ -22,11 +24,10 @@ class VnfTestCreate(base.BaseTackerTest):
def _test_create_delete_vnf(self, vnf_name, vnfd_name,
placement_policy, vdu_name,
vnf_expected_status="ACTIVE"):
data = dict()
data['tosca'] = read_file(vnfd_name + '.yaml')
toscal = data['tosca']
input_yaml = read_file(vnfd_name + '.yaml')
tosca_dict = yaml.safe_load(input_yaml)
tosca_arg = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': toscal}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd with tosca template
vnfd_instance = self.client.create_vnfd(body=tosca_arg)

View File

@ -23,8 +23,9 @@ from tacker.tests.utils import read_file
class VnfmTestParam(base.BaseTackerTest):
def _test_vnfd_create(self, vnfd_file, vnfd_name):
yaml_input = read_file(vnfd_file)
tosca_dict = yaml.safe_load(yaml_input)
req_dict = {'vnfd': {'name': vnfd_name,
'attributes': {'vnfd': yaml_input}}}
'attributes': {'vnfd': tosca_dict}}}
# Create vnfd
vnfd_instance = self.client.create_vnfd(body=req_dict)