Add tacker create vnf test
Adding create vnf test in functional testcases of tacker Closes-Bug:1498203 Change-Id: I1553afc6076067908be3e8f3eb627999b91e71f3
This commit is contained in:
parent
f8bc9cc05c
commit
b7070363d8
|
@ -0,0 +1,33 @@
|
||||||
|
template_name: sample-vnfd-no-monitoring
|
||||||
|
description: demo-example
|
||||||
|
|
||||||
|
service_properties:
|
||||||
|
Id: sample-vnfd
|
||||||
|
vendor: tacker
|
||||||
|
version: 1
|
||||||
|
type:
|
||||||
|
- firewall
|
||||||
|
|
||||||
|
vdus:
|
||||||
|
vdu1:
|
||||||
|
id: vdu1
|
||||||
|
vm_image: cirros-0.3.4-x86_64-uec
|
||||||
|
instance_type: m1.tiny
|
||||||
|
|
||||||
|
network_interfaces:
|
||||||
|
management:
|
||||||
|
network: net_mgmt
|
||||||
|
management: true
|
||||||
|
pkt_in:
|
||||||
|
network: net0
|
||||||
|
pkt_out:
|
||||||
|
network: net1
|
||||||
|
|
||||||
|
placement_policy:
|
||||||
|
availability_zone: nova
|
||||||
|
|
||||||
|
auto-scaling: noop
|
||||||
|
|
||||||
|
config:
|
||||||
|
param0: key0
|
||||||
|
param1: key1
|
|
@ -12,11 +12,13 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from tempest_lib.tests import base
|
||||||
|
|
||||||
from tacker import version
|
from tacker import version
|
||||||
from tackerclient.v1_0 import client as tacker_client
|
from tackerclient.v1_0 import client as tacker_client
|
||||||
from tempest_lib.tests import base
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
@ -60,3 +62,18 @@ class BaseTackerTest(base.TestCase):
|
||||||
return tacker_client.Client(username=username, password=password,
|
return tacker_client.Client(username=username, password=password,
|
||||||
tenant_name=tenant_name,
|
tenant_name=tenant_name,
|
||||||
auth_url=auth_uri)
|
auth_url=auth_uri)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def wait_until_vnf_status(cls, vnf_id, target_status, timeout):
|
||||||
|
start_time = int(time.time())
|
||||||
|
while True:
|
||||||
|
vnf_result = cls.client.show_vnf(vnf_id)
|
||||||
|
status = vnf_result['vnf']['status']
|
||||||
|
if (status == target_status) or ((int(time.time()) -
|
||||||
|
start_time) > timeout):
|
||||||
|
break
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def wait_until_vnf_active(cls, vnf_id, timeout):
|
||||||
|
cls.wait_until_vnf_status(vnf_id,'ACTIVE',timeout)
|
|
@ -0,0 +1,63 @@
|
||||||
|
# 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 oslo_config import cfg
|
||||||
|
|
||||||
|
from tacker.tests.functional.vnfd import base
|
||||||
|
from tacker.tests.utils import read_file
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
VNF_CIRROS_CREATE_TIMEOUT = 120
|
||||||
|
|
||||||
|
|
||||||
|
class VnfTestJSON(base.BaseTackerTest):
|
||||||
|
def test_create_delete_vnf_no_monitoring(self):
|
||||||
|
data = dict()
|
||||||
|
data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml')
|
||||||
|
toscal = data['tosca']
|
||||||
|
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
|
||||||
|
|
||||||
|
##Create vnfd with tosca template
|
||||||
|
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
|
||||||
|
self.assertIsNotNone(vnfd_instance)
|
||||||
|
|
||||||
|
##Create vnf with vnfd_id
|
||||||
|
vnfd_id = vnfd_instance['vnfd']['id']
|
||||||
|
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
|
||||||
|
"test_vnf_with_cirros_no_monitoring"}}
|
||||||
|
vnf_instance = self.client.create_vnf(body = vnf_arg)
|
||||||
|
self.assertIsNotNone(vnf_instance)
|
||||||
|
self.assertIsNotNone(vnf_instance['vnf']['id'])
|
||||||
|
self.assertIsNotNone(vnf_instance['vnf']['instance_id'])
|
||||||
|
self.assertEqual(vnf_instance['vnf']['vnfd_id'], vnfd_instance[
|
||||||
|
'vnfd']['id'])
|
||||||
|
|
||||||
|
vnf_id = vnf_instance['vnf']['id']
|
||||||
|
self.wait_until_vnf_active(vnf_id, VNF_CIRROS_CREATE_TIMEOUT)
|
||||||
|
self.assertEqual(self.client.show_vnf(vnf_id)['vnf']['status'],
|
||||||
|
'ACTIVE')
|
||||||
|
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||||
|
|
||||||
|
##Delete vnf_instance with vnf_id
|
||||||
|
try:
|
||||||
|
self.client.delete_vnf(vnf_id)
|
||||||
|
except Exception:
|
||||||
|
assert False, "vnf Delete failed"
|
||||||
|
|
||||||
|
##Delete vnfd_instance
|
||||||
|
try:
|
||||||
|
self.client.delete_vnfd(vnfd_id)
|
||||||
|
except Exception:
|
||||||
|
assert False, "vnfd Delete failed"
|
|
@ -12,23 +12,18 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from tacker.tests.functional.vnfd import base
|
from tacker.tests.functional.vnfd import base
|
||||||
|
from tacker.tests.utils import read_file
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class VnfTestJSON(base.BaseTackerTest):
|
class VnfdTestJSON(base.BaseTackerTest):
|
||||||
def test_create_list_delete_vnfd(self):
|
def test_create_list_delete_vnfd(self):
|
||||||
data = dict()
|
data = dict()
|
||||||
yaml_file = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
data['tosca'] = read_file('sample_cirros_vnf.yaml')
|
||||||
"../../etc/samples/"
|
|
||||||
"sample_cirros_vnf.yaml"))
|
|
||||||
toscal_str = open(yaml_file).read()
|
|
||||||
data['tosca'] = toscal_str
|
|
||||||
toscal = data['tosca']
|
toscal = data['tosca']
|
||||||
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
|
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
|
||||||
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
|
vnfd_instance = self.client.create_vnfd(body=tosca_arg)
|
||||||
|
@ -41,4 +36,4 @@ class VnfTestJSON(base.BaseTackerTest):
|
||||||
try:
|
try:
|
||||||
self.client.delete_vnfd(vnfd_id)
|
self.client.delete_vnfd(vnfd_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
assert False, "vnfd Delete failed"
|
assert False, "vnfd Delete failed"
|
|
@ -0,0 +1,22 @@
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def read_file(input_file):
|
||||||
|
yaml_file = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
|
'etc/samples/' + str(input_file)))
|
||||||
|
with open(yaml_file, 'r') as f:
|
||||||
|
return f.read()
|
Loading…
Reference in New Issue