Refactor duplicate methods in functional tests
This patch includes the following changes. * Move BaseSolV2Test and BaseVnfLcmKubernetesV2Test duplicate methods to BaseTackerTestV2. * Rename duplicate method names in BaseSolV2Test and BaseVnfLcmKubernetesV2Test. * Define a repeat execution method of LCM operation in BaseTackerTestV2. And remove this processing from each FT. * Change sleep times used in v2 API FT to the following constant. - WAIT_LCMOCC_UPDATE_TIME - WAIT_NOTIFICATION_TIME - WAIT_TEST_NOTIFICATION_TIME - WAIT_CREATE_THRESHOLD_TIME - WAIT_AUTO_HEAL_TIME - SERVER_NOTIFICATION_INTERVAL * Change versions used in v2 API FT to the following constant. - VNFLCM_V2_VERSION = "2.0.0" - VNFFM_V1_VERSION = "1.3.0" - VNFPM_V2_VERSION = "2.1.0" * Rename VNF Package and VNFD ID used in the FT of the v2 API to something that is easy to understand. Co-Author: Ai Hamano <ai.hamano@ntt-at.co.jp> Change-Id: I6230ab56dec3a5c96cd123c62168a6495d8f7092
This commit is contained in:
parent
0becf595f4
commit
7eaf841525
@ -32,6 +32,8 @@ domain_name = "Default"
|
||||
user_domain_name = "Default"
|
||||
project_domain_name = "Default"
|
||||
|
||||
VNFLCM_V2_VERSION = "2.0.0"
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
@ -55,82 +57,85 @@ class Client(object):
|
||||
|
||||
def create(self, req_body):
|
||||
resp, body = self.client.do_request(
|
||||
self.path, "POST", body=req_body, version="2.0.0")
|
||||
self.path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def list(self, req_body):
|
||||
if req_body is not None:
|
||||
resp, body = self.client.do_request(
|
||||
self.path, "GET", version="2.0.0", params=req_body)
|
||||
self.path, "GET", version=VNFLCM_V2_VERSION, params=req_body)
|
||||
else:
|
||||
resp, body = self.client.do_request(
|
||||
self.path, "GET", version="2.0.0")
|
||||
self.path, "GET", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def show(self, id):
|
||||
resp, body = self.client.do_request(
|
||||
self.path + '/' + id, "GET", version="2.0.0")
|
||||
self.path + '/' + id, "GET", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def delete(self, id):
|
||||
resp, body = self.client.do_request(
|
||||
self.path + '/' + id, "DELETE", version="2.0.0")
|
||||
self.path + '/' + id, "DELETE", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def update(self, id, req_body):
|
||||
resp, body = self.client.do_request(
|
||||
self.path + '/' + id, "PATCH", body=req_body, version="2.0.0")
|
||||
resp, body = self.client.do_request(self.path + '/' + id,
|
||||
"PATCH", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def inst(self, id, req_body):
|
||||
path = self.path + '/' + id + '/instantiate'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def term(self, id, req_body):
|
||||
path = self.path + '/' + id + '/terminate'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def scale(self, id, req_body):
|
||||
path = self.path + '/' + id + '/scale'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def heal(self, id, req_body):
|
||||
path = self.path + '/' + id + '/heal'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def chg_ext_conn(self, id, req_body):
|
||||
path = self.path + '/' + id + '/change_ext_conn'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def change_vnfpkg(self, id, req_body):
|
||||
path = self.path + '/' + id + '/change_vnfpkg'
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def retry(self, id):
|
||||
path = self.path + '/' + id + '/retry'
|
||||
resp, body = self.client.do_request(path, "POST", version="2.0.0")
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def rollback(self, id):
|
||||
path = self.path + '/' + id + '/rollback'
|
||||
resp, body = self.client.do_request(path, "POST", version="2.0.0")
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
def fail(self, id):
|
||||
path = self.path + '/' + id + '/fail'
|
||||
resp, body = self.client.do_request(path, "POST", version="2.0.0")
|
||||
resp, body = self.client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
self.print(resp, body)
|
||||
|
||||
|
||||
|
433
tacker/tests/functional/base_v2.py
Normal file
433
tacker/tests/functional/base_v2.py
Normal file
@ -0,0 +1,433 @@
|
||||
# Copyright (C) 2023 Nippon Telegraph and Telephone Corporation
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import urllib
|
||||
import yaml
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
from tempest.lib import base
|
||||
|
||||
from tacker.sol_refactored.common import http_client
|
||||
from tacker.sol_refactored import objects
|
||||
from tacker.tests.functional.common.fake_server import FakeServerManager
|
||||
from tacker.tests.functional.sol_v2_common import utils
|
||||
from tacker.tests import utils as base_utils
|
||||
from tacker import version
|
||||
|
||||
FAKE_SERVER_MANAGER = FakeServerManager()
|
||||
MOCK_NOTIFY_CALLBACK_URL = '/notification/callback'
|
||||
|
||||
RETRY_WAIT_TIME = 3
|
||||
VNF_PACKAGE_UPLOAD_TIMEOUT = 300
|
||||
|
||||
VNFLCM_V2_VERSION = "2.0.0"
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class BaseTackerTestV2(base.BaseTestCase):
|
||||
"""Base test case class for SOL v2 functional tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseTackerTestV2, cls).setUpClass()
|
||||
|
||||
FAKE_SERVER_MANAGER.prepare_http_server()
|
||||
if getattr(cls, 'is_https', False):
|
||||
FAKE_SERVER_MANAGER.set_https_server()
|
||||
FAKE_SERVER_MANAGER.start_server()
|
||||
|
||||
cfg.CONF(args=['--config-file', '/etc/tacker/tacker.conf'],
|
||||
project='tacker',
|
||||
version=f'%%prog {version.version_info.release_string()}')
|
||||
objects.register_all()
|
||||
|
||||
vim_info = cls.get_vim_info()
|
||||
cls.auth_handle = http_client.KeystonePasswordAuthHandle(
|
||||
auth_url=vim_info.interfaceInfo['endpoint'],
|
||||
username=vim_info.accessInfo['username'],
|
||||
password=vim_info.accessInfo['password'],
|
||||
project_name=vim_info.accessInfo['project'],
|
||||
user_domain_name=vim_info.accessInfo['userDomain'],
|
||||
project_domain_name=vim_info.accessInfo['projectDomain']
|
||||
)
|
||||
cls.tacker_client = http_client.HttpClient(cls.auth_handle)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(BaseTackerTestV2, cls).tearDownClass()
|
||||
FAKE_SERVER_MANAGER.stop_server()
|
||||
|
||||
@classmethod
|
||||
def get_vim_info(cls):
|
||||
vim_params = yaml.safe_load(base_utils.read_file('local-vim.yaml'))
|
||||
vim_params['auth_url'] = f"{vim_params['auth_url']}/v3"
|
||||
|
||||
vim_info = objects.VimConnectionInfo(
|
||||
interfaceInfo={'endpoint': vim_params['auth_url']},
|
||||
accessInfo={
|
||||
'region': 'RegionOne',
|
||||
'project': vim_params['project_name'],
|
||||
'username': vim_params['username'],
|
||||
'password': vim_params['password'],
|
||||
'userDomain': vim_params['user_domain_name'],
|
||||
'projectDomain': vim_params['project_domain_name']
|
||||
}
|
||||
)
|
||||
|
||||
return vim_info
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
callback_url = os.path.join(
|
||||
MOCK_NOTIFY_CALLBACK_URL,
|
||||
self._testMethodName)
|
||||
FAKE_SERVER_MANAGER.clear_history(callback_url)
|
||||
FAKE_SERVER_MANAGER.set_callback('POST', callback_url, status_code=204)
|
||||
FAKE_SERVER_MANAGER.set_callback('GET', callback_url, status_code=204)
|
||||
|
||||
def get_notify_callback_url(self):
|
||||
return MOCK_NOTIFY_CALLBACK_URL
|
||||
|
||||
def get_server_port(self):
|
||||
return FAKE_SERVER_MANAGER.SERVER_PORT
|
||||
|
||||
def set_server_callback(self, method, uri, **kwargs):
|
||||
FAKE_SERVER_MANAGER.set_callback(method, uri, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def create_vnf_package(cls, sample_path, user_data={},
|
||||
image_path=None, nfvo=False, userdata_path=None,
|
||||
provider=None, namespace=None):
|
||||
|
||||
vnfd_id = uuidutils.generate_uuid()
|
||||
tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
utils.make_zip(sample_path, tmp_dir, vnfd_id, image_path,
|
||||
userdata_path, provider, namespace)
|
||||
|
||||
zip_file_name = f"{os.path.basename(os.path.abspath(sample_path))}.zip"
|
||||
zip_file_path = os.path.join(tmp_dir, zip_file_name)
|
||||
|
||||
if nfvo:
|
||||
return zip_file_path, vnfd_id
|
||||
|
||||
path = "/vnfpkgm/v1/vnf_packages"
|
||||
req_body = {'userDefinedData': user_data}
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "POST", expected_status=[201], body=req_body)
|
||||
|
||||
pkg_id = body['id']
|
||||
|
||||
with open(zip_file_path, 'rb') as fp:
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}/package_content"
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "PUT", body=fp, content_type='application/zip',
|
||||
expected_status=[202])
|
||||
|
||||
# wait for onboard
|
||||
timeout = VNF_PACKAGE_UPLOAD_TIMEOUT
|
||||
start_time = int(time.time())
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
while True:
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200])
|
||||
if body['onboardingState'] == "ONBOARDED":
|
||||
break
|
||||
|
||||
if int(time.time()) - start_time > timeout:
|
||||
raise Exception("Failed to onboard vnf package")
|
||||
|
||||
time.sleep(RETRY_WAIT_TIME)
|
||||
|
||||
shutil.rmtree(tmp_dir)
|
||||
|
||||
return pkg_id, vnfd_id
|
||||
|
||||
def get_vnf_package(self, pkg_id):
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
return body
|
||||
|
||||
@classmethod
|
||||
def delete_vnf_package(cls, pkg_id):
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
req_body = {"operationalState": "DISABLED"}
|
||||
resp, _ = cls.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body)
|
||||
if resp.status_code != 200:
|
||||
LOG.error("failed to set operationalState to DISABLED")
|
||||
return
|
||||
|
||||
cls.tacker_client.do_request(path, "DELETE")
|
||||
|
||||
def create_vnf_instance(self, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def instantiate_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/instantiate"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def terminate_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/terminate"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def heal_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/heal"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def delete_vnf_instance(self, inst_id):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def show_vnf_instance(self, inst_id):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def list_vnf_instance(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def scale_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/scale"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def change_vnfpkg(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/change_vnfpkg"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def show_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def list_lcmocc(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def retry_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/retry"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def fail_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/fail"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def rollback_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/rollback"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def create_subscription(self, req_body):
|
||||
path = "/vnflcm/v2/subscriptions"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def delete_subscription(self, sub_id):
|
||||
path = f"/vnflcm/v2/subscriptions/{sub_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def show_subscription(self, sub_id):
|
||||
path = f"/vnflcm/v2/subscriptions/{sub_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def list_subscriptions(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/subscriptions"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
|
||||
def exec_lcm_operation(self, func, *args):
|
||||
for _ in range(3):
|
||||
resp, body = func(*args)
|
||||
if resp.status_code == 409:
|
||||
# may happen. there is a bit time between lcmocc become
|
||||
# COMPLETED and lock of terminate is freed.
|
||||
time.sleep(RETRY_WAIT_TIME)
|
||||
else:
|
||||
return resp, body
|
||||
self.fail()
|
||||
|
||||
def wait_lcmocc_complete(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(RETRY_WAIT_TIME)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version=VNFLCM_V2_VERSION)
|
||||
state = body['operationState']
|
||||
if state == 'COMPLETED':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
else: # FAILED_TEMP or ROLLED_BACK
|
||||
raise Exception(f"Operation failed. state: {state}")
|
||||
|
||||
def wait_lcmocc_failed_temp(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(RETRY_WAIT_TIME)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version=VNFLCM_V2_VERSION)
|
||||
state = body['operationState']
|
||||
if state == 'FAILED_TEMP':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
elif state == 'COMPLETED':
|
||||
raise Exception("Operation unexpected COMPLETED.")
|
||||
else: # ROLLED_BACK
|
||||
raise Exception(f"Operation failed. state: {state}")
|
||||
|
||||
def wait_lcmocc_rolled_back(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(RETRY_WAIT_TIME)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version=VNFLCM_V2_VERSION)
|
||||
state = body['operationState']
|
||||
if state == 'ROLLED_BACK':
|
||||
return
|
||||
if state == 'ROLLING_BACK':
|
||||
continue
|
||||
|
||||
raise Exception(f"Operation failed. state: {state}")
|
||||
|
||||
def put_fail_file(self, operation):
|
||||
with open(f'/tmp/{operation}', 'w'):
|
||||
pass
|
||||
|
||||
def rm_fail_file(self, operation):
|
||||
os.remove(f'/tmp/{operation}')
|
||||
|
||||
def assert_notification_get(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
|
||||
def _check_notification(self, callback_url, notify_type):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
self.assertEqual(notify_type, notify_mock_responses[0].request_body[
|
||||
'notificationType'])
|
||||
|
||||
def _check_no_notification(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
self.assertEqual(0, len(notify_mock_responses))
|
||||
|
||||
def _get_crossing_direction(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
return notify_mock_responses[0].request_body['crossingDirection']
|
||||
|
||||
def prometheus_auto_scaling_alert(self, req_body):
|
||||
path = "/alert/auto_scaling"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def prometheus_auto_healing_alert(self, req_body):
|
||||
path = "/alert/auto_healing"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def check_resp_headers_in_create(self, resp):
|
||||
# includes location header and response body
|
||||
supported_headers = ['Version', 'Location', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_operation_task(self, resp):
|
||||
# includes location header and no response body
|
||||
supported_headers = ['Version', 'Location']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_get(self, resp):
|
||||
# includes a single data in response body and no location header
|
||||
supported_headers = ['Version', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_index(self, resp):
|
||||
# includes some data in response body and no location header
|
||||
supported_headers = ['Version', 'Content-Type',
|
||||
'Accept-Ranges', 'Link']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_delete(self, resp):
|
||||
# no location header and response body
|
||||
supported_headers = ['Version']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_body(self, body, expected_attrs):
|
||||
for attr in expected_attrs:
|
||||
if attr not in body:
|
||||
raise Exception(f"Expected attribute doesn't exist: {attr}")
|
||||
|
||||
def _check_resp_headers(self, resp, supported_headers):
|
||||
unsupported_headers = ['Retry-After',
|
||||
'Content-Range', 'WWW-Authenticate']
|
||||
for s in supported_headers:
|
||||
if s not in resp.headers:
|
||||
raise Exception(f"Supported header doesn't exist: {s}")
|
||||
for u in unsupported_headers:
|
||||
if u in resp.headers:
|
||||
raise Exception(f"Unsupported header exist: {u}")
|
||||
|
||||
def check_package_usage(self, package_id, state='NOT_IN_USE',
|
||||
is_nfvo=False):
|
||||
if not is_nfvo:
|
||||
usage_state = self.get_vnf_package(package_id)['usageState']
|
||||
self.assertEqual(state, usage_state)
|
@ -21,12 +21,13 @@ from tacker.sol_refactored.common import http_client
|
||||
from tacker.sol_refactored import objects
|
||||
from tacker.tests.functional.sol_enhanced_policy.base import (
|
||||
BaseEnhancedPolicyTest)
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common.test_vnflcm_basic_common import (
|
||||
CommonVnfLcmTest)
|
||||
from tacker.tests import utils as base_utils
|
||||
|
||||
WAIT_LCMOCC_UPDATE_TIME = 3
|
||||
|
||||
|
||||
class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
|
||||
@ -335,7 +336,7 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and instantiate completion.
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
def _step_lcm_show(self, username, inst_id, expected_status_code):
|
||||
self.tacker_client = self.get_tk_http_client_by_user(username)
|
||||
@ -363,7 +364,7 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
if expected_status_code == 202:
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
def _step_lcm_update(self, username, inst_id, update_vnfd_id,
|
||||
expected_status_code):
|
||||
@ -424,7 +425,7 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and change_vnfpkg completion.
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
def _step_lcm_change_ext_conn(self, username, inst_id, area,
|
||||
zone_name_list, expected_status_code):
|
||||
@ -490,7 +491,7 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
if expected_status_code == 202:
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
def _step_lcm_terminate(self, username, inst_id, expected_status_code):
|
||||
self.tacker_client = self.get_tk_http_client_by_user(username)
|
||||
@ -502,23 +503,20 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
def _step_lcm_delete(self, username, inst_id, expected_status_code):
|
||||
self.tacker_client = self.get_tk_http_client_by_user(username)
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance,
|
||||
inst_id)
|
||||
self.assertEqual(expected_status_code, resp.status_code)
|
||||
|
||||
def vnflcm_apis_v2_vnf_test_before_instantiate(self):
|
||||
# Create subscription
|
||||
self.tacker_client = self.get_tk_http_client_by_user('user_all')
|
||||
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -530,7 +528,7 @@ class VnflcmAPIsV2VNFBase(CommonVnfLcmTest, BaseEnhancedPolicyTest):
|
||||
# Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(False, self.vnf_pkg_a)
|
||||
self.check_package_usage(self.vnf_pkg_a)
|
||||
|
||||
# step 1 LCM-CreateV2, Resource Group A / User Group A
|
||||
inst_id_a = self._step_lcm_create('user_a', self.vnfd_id_a, 201)
|
||||
@ -820,10 +818,10 @@ class VnflcmAPIsV2VNFInstanceWithoutArea(VnflcmAPIsV2VNFBase):
|
||||
# Create subscription
|
||||
self.tacker_client = self.get_tk_http_client_by_user('user_all')
|
||||
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -835,7 +833,7 @@ class VnflcmAPIsV2VNFInstanceWithoutArea(VnflcmAPIsV2VNFBase):
|
||||
# Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(False, self.vnf_pkg_c)
|
||||
self.check_package_usage(self.vnf_pkg_c)
|
||||
|
||||
# step 1 LCM-CreateV2, Resource Group C / User Group C
|
||||
inst_id_c = self._step_lcm_create('user_c', self.vnfd_id_c, 201)
|
||||
|
@ -26,6 +26,9 @@ from tacker.tests.functional.sol_kubernetes_v2.base_v2 import (
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
from tacker.tests import utils as base_utils
|
||||
|
||||
VNFLCM_V2_VERSION = "2.0.0"
|
||||
WAIT_LCMOCC_UPDATE_TIME = 3
|
||||
|
||||
|
||||
class VnflcmAPIsV2CNFBase(BaseVnfLcmKubernetesV2Test, BaseEnhancedPolicyTest):
|
||||
|
||||
@ -245,7 +248,7 @@ class VnflcmAPIsV2CNFBase(BaseVnfLcmKubernetesV2Test, BaseEnhancedPolicyTest):
|
||||
self.tacker_client = self.get_tk_http_client_by_user(username)
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
resp, vnf_instances = self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
path, "GET", version=VNFLCM_V2_VERSION)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
inst_ids = set([inst.get('id') for inst in vnf_instances])
|
||||
for inst_id in expected_inst_list:
|
||||
@ -377,7 +380,7 @@ class VnflcmAPIsV2CNFBase(BaseVnfLcmKubernetesV2Test, BaseEnhancedPolicyTest):
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and change_vnfpkg completion.
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
def _step_lcm_update(self, username, inst_id,
|
||||
expected_status_code):
|
||||
@ -387,7 +390,7 @@ class VnflcmAPIsV2CNFBase(BaseVnfLcmKubernetesV2Test, BaseEnhancedPolicyTest):
|
||||
}
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
resp, body = self.tacker_client.do_request(
|
||||
path, "PATCH", body=update_req, version="2.0.0")
|
||||
path, "PATCH", body=update_req, version=VNFLCM_V2_VERSION)
|
||||
self.assertEqual(expected_status_code, resp.status_code)
|
||||
if expected_status_code == 202:
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
@ -439,14 +442,11 @@ class VnflcmAPIsV2CNFBase(BaseVnfLcmKubernetesV2Test, BaseEnhancedPolicyTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
def _step_lcm_delete(self, username, inst_id, expected_status_code):
|
||||
self.tacker_client = self.get_tk_http_client_by_user(username)
|
||||
# Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance,
|
||||
inst_id)
|
||||
self.assertEqual(expected_status_code, resp.status_code)
|
||||
if expected_status_code == 204:
|
||||
# check deletion of VNF instance
|
||||
|
@ -24,11 +24,14 @@ from tacker.sol_refactored.common import config
|
||||
from tacker.sol_refactored.conductor import conductor_rpc_v2
|
||||
from tacker.tests.functional.sol_https_v2 import paramgen
|
||||
from tacker.tests.functional.sol_separated_nfvo_v2 import fake_grant_v2
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
VNFFM_V1_VERSION = "1.3.0"
|
||||
WAIT_NOTIFICATION_TIME = 5
|
||||
WAIT_TEST_NOTIFICATION_TIME = 10
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
@ -49,27 +52,17 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
def _create_fm_subscription(self, req_body):
|
||||
path = "/vnffm/v1/subscriptions"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="1.3.0")
|
||||
path, "POST", body=req_body, version=VNFFM_V1_VERSION)
|
||||
|
||||
def _delete_fm_subscription(self, sub_id):
|
||||
path = "/vnffm/v1/subscriptions/{}".format(sub_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="1.3.0")
|
||||
path, "DELETE", version=VNFFM_V1_VERSION)
|
||||
|
||||
def _create_fm_alarm(self, req_body):
|
||||
path = "/alert"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="1.3.0")
|
||||
|
||||
def _check_notification(self, callback_url, notify_type):
|
||||
notify_mock_responses = base_v2.FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
base_v2.FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
self.assertEqual(notify_type, notify_mock_responses[0].request_body[
|
||||
'notificationType'])
|
||||
path, "POST", body=req_body, version=VNFFM_V1_VERSION)
|
||||
|
||||
def test_fm_notification_over_https_no_auth(self):
|
||||
"""Test FM operations over https with no auth
|
||||
@ -95,11 +88,11 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
@ -107,7 +100,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
zone_name_list = self.get_zone_list()
|
||||
|
||||
# 1. LCM-Create
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -125,10 +118,10 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 3. FM-Create-Subscription
|
||||
expected_inst_attrs = ['id', 'callbackUri', '_links']
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_https_no_auth(callback_uri)
|
||||
resp, body = self._create_fm_subscription(sub_req)
|
||||
@ -144,7 +137,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
alarm = paramgen.alarm(inst_id)
|
||||
r.store_alarm_info(ctx, alarm)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmNotification')
|
||||
|
||||
# 5. FM-Delete-Subscription
|
||||
@ -160,10 +153,6 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -171,7 +160,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -202,11 +191,11 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
@ -214,7 +203,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
zone_name_list = self.get_zone_list()
|
||||
|
||||
# 1. LCM-Create
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -234,10 +223,10 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 3. FM-Create-Subscription
|
||||
expected_inst_attrs = ['id', 'callbackUri', '_links']
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_https_basic_auth(
|
||||
callback_uri)
|
||||
@ -254,7 +243,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
alarm = paramgen.alarm(inst_id)
|
||||
r.store_alarm_info(ctx, alarm)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmNotification')
|
||||
|
||||
# 5. FM-Delete-Subscription
|
||||
@ -270,10 +259,6 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -281,7 +266,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -312,11 +297,11 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
@ -324,7 +309,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
zone_name_list = self.get_zone_list()
|
||||
|
||||
# 1. LCM-Create
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -345,10 +330,10 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 3. FM-Create-Subscription
|
||||
expected_inst_attrs = ['id', 'callbackUri', '_links']
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_https_oauth2_auth(
|
||||
callback_uri)
|
||||
@ -357,7 +342,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.check_resp_headers_in_create(resp)
|
||||
sub_id = body['id']
|
||||
self.check_resp_body(body, expected_inst_attrs)
|
||||
time.sleep(10)
|
||||
time.sleep(WAIT_TEST_NOTIFICATION_TIME)
|
||||
# Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
|
||||
@ -366,7 +351,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
alarm = paramgen.alarm(inst_id)
|
||||
r.store_alarm_info(ctx, alarm)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmNotification')
|
||||
|
||||
# 5. FM-Delete-Subscription
|
||||
@ -382,10 +367,6 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -393,7 +374,7 @@ class VnfFmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -15,15 +15,12 @@
|
||||
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
from tacker.sol_refactored.common import config
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_https_v2 import paramgen
|
||||
from tacker.tests.functional.sol_separated_nfvo_v2 import fake_grant_v2
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
CONF = config.CONF
|
||||
@ -68,12 +65,12 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
@ -81,13 +78,13 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create-Subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_https_no_auth(callback_uri)
|
||||
@ -156,10 +153,6 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -169,7 +162,7 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -211,12 +204,12 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
@ -224,13 +217,13 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create-Subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_https_basic_auth(callback_uri)
|
||||
resp, body = self.create_subscription(sub_req)
|
||||
@ -297,10 +290,6 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -310,7 +299,7 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -352,12 +341,12 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
@ -365,13 +354,13 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create-Subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_https_oauth2_auth(callback_uri)
|
||||
resp, body = self.create_subscription(sub_req)
|
||||
@ -438,10 +427,6 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -451,7 +436,7 @@ class VnfLcmWithHttpsRequest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -23,11 +23,13 @@ from tacker.sol_refactored.common import config
|
||||
from tacker.sol_refactored.conductor import conductor_rpc_v2
|
||||
from tacker.tests.functional.sol_https_v2 import paramgen
|
||||
from tacker.tests.functional.sol_separated_nfvo_v2 import fake_grant_v2
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
VNFPM_V2_VERSION = "2.1.0"
|
||||
WAIT_NOTIFICATION_TIME = 5
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
@ -45,7 +47,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
def setUp(self):
|
||||
super(VnfPmWithHttpsRequestTest, self).setUp()
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'PUT', "/-/reload", status_code=202,
|
||||
response_headers={"Content-Type": "text/plain"})
|
||||
|
||||
@ -62,27 +64,17 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
def _create_pm_job(self, req_body):
|
||||
path = "/vnfpm/v2/pm_jobs"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def _create_pm_event(self, req_body):
|
||||
path = "/pm_event"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
|
||||
def _check_notification(self, callback_url, notify_type):
|
||||
notify_mock_responses = base_v2.FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
base_v2.FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
self.assertEqual(notify_type, notify_mock_responses[0].request_body[
|
||||
'notificationType'])
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def _delete_pm_job(self, pm_job_id):
|
||||
path = f"/vnfpm/v2/pm_jobs/{pm_job_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.1.0")
|
||||
path, "DELETE", version=VNFPM_V2_VERSION)
|
||||
|
||||
def test_pm_notification_over_https_no_auth(self):
|
||||
"""Test PM operations over https with no auth
|
||||
@ -107,23 +99,23 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create
|
||||
self._set_grant_response(
|
||||
True, 'INSTANTIATE', glance_image=glance_image,
|
||||
flavour_vdu_dict=flavour_vdu_dict, zone_name_list=zone_name_list)
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -148,10 +140,10 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_job_https_no_auth(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -168,7 +160,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
entries = paramgen.entries(body, inst_id)
|
||||
r.store_job_info(ctx, entries)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'PerformanceInformationAvailableNotification')
|
||||
|
||||
@ -186,10 +178,6 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -199,7 +187,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -230,20 +218,20 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -266,10 +254,10 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_job_https_basic_auth(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -286,7 +274,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
entries = paramgen.entries(body, inst_id)
|
||||
r.store_job_info(ctx, entries)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'PerformanceInformationAvailableNotification')
|
||||
|
||||
@ -303,10 +291,6 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -316,7 +300,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -348,23 +332,23 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
cur_dir = os.path.dirname(__file__)
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(min_vnfd_id,
|
||||
min_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
|
||||
# 1. LCM-Create
|
||||
self._set_grant_response(
|
||||
True, 'INSTANTIATE', glance_image=glance_image,
|
||||
flavour_vdu_dict=flavour_vdu_dict, zone_name_list=zone_name_list)
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -384,10 +368,10 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('https://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_job_https_oauth2_auth(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -404,7 +388,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
ctx = context.get_admin_context()
|
||||
entries = paramgen.entries(body, inst_id)
|
||||
r.store_job_info(ctx, entries)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'PerformanceInformationAvailableNotification')
|
||||
|
||||
@ -422,10 +406,6 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_name = "vnf-{}".format(inst_id)
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -435,7 +415,7 @@ class VnfPmWithHttpsRequestTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 7. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
import copy
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.tests.functional.sol_kubernetes_oidc_auth.vnflcm_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
@ -33,14 +32,14 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(cur_dir,
|
||||
"../../sol_kubernetes_v2/samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmKubernetesTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfLcmKubernetesTest, self).setUp()
|
||||
@ -84,7 +83,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -92,8 +91,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
vim_id = self.get_k8s_vim_id()
|
||||
@ -130,12 +128,8 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# 5. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -144,8 +138,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'NOT_IN_USE')
|
||||
|
||||
def test_instantiationV2_with_bad_oidc_auth_info(self):
|
||||
"""Test CNF LCM v2 with bad OIDC auth
|
||||
@ -183,7 +176,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -191,8 +184,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
k8s_vim_info = copy.deepcopy(self.k8s_vim_info)
|
||||
@ -251,5 +243,4 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2OidcTest):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'NOT_IN_USE')
|
||||
|
@ -13,97 +13,35 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import urllib
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from tempest.lib import base
|
||||
import yaml
|
||||
|
||||
from tacker.sol_refactored.common import http_client
|
||||
from tacker.sol_refactored import objects
|
||||
from tacker.tests.functional.common.fake_server import FakeServerManager
|
||||
from tacker.tests.functional.sol_v2_common import utils
|
||||
from tacker.tests.functional import base_v2
|
||||
from tacker.tests import utils as base_utils
|
||||
from tacker import version
|
||||
|
||||
FAKE_SERVER_MANAGER = FakeServerManager()
|
||||
MOCK_NOTIFY_CALLBACK_URL = '/notification/callback'
|
||||
|
||||
VNF_PACKAGE_UPLOAD_TIMEOUT = 300
|
||||
VNF_INSTANTIATE_TIMEOUT = 600
|
||||
VNF_TERMINATE_TIMEOUT = 600
|
||||
RETRY_WAIT_TIME = 5
|
||||
VNFPM_V2_VERSION = "2.1.0"
|
||||
VNFFM_V1_VERSION = "1.3.0"
|
||||
|
||||
|
||||
class BaseVnfLcmKubernetesV2Test(base.BaseTestCase):
|
||||
class BaseVnfLcmKubernetesV2Test(base_v2.BaseTackerTestV2):
|
||||
"""Base test case class for SOL v2 kubernetes functional tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseVnfLcmKubernetesV2Test, cls).setUpClass()
|
||||
"""Base test case class for SOL v2 kubernetes functional tests."""
|
||||
|
||||
FAKE_SERVER_MANAGER.prepare_http_server()
|
||||
FAKE_SERVER_MANAGER.start_server()
|
||||
|
||||
cfg.CONF(args=['--config-file', '/etc/tacker/tacker.conf'],
|
||||
project='tacker',
|
||||
version='%%prog %s' % version.version_info.release_string())
|
||||
objects.register_all()
|
||||
|
||||
k8s_vim_info = cls.get_k8s_vim_info()
|
||||
cls.auth_url = k8s_vim_info.interfaceInfo['endpoint']
|
||||
cls.bearer_token = k8s_vim_info.accessInfo['bearer_token']
|
||||
cls.ssl_ca_cert = k8s_vim_info.interfaceInfo['ssl_ca_cert']
|
||||
|
||||
vim_info = cls.get_vim_info()
|
||||
auth = http_client.KeystonePasswordAuthHandle(
|
||||
auth_url=vim_info.interfaceInfo['endpoint'],
|
||||
username=vim_info.accessInfo['username'],
|
||||
password=vim_info.accessInfo['password'],
|
||||
project_name=vim_info.accessInfo['project'],
|
||||
user_domain_name=vim_info.accessInfo['userDomain'],
|
||||
project_domain_name=vim_info.accessInfo['projectDomain']
|
||||
)
|
||||
cls.tacker_client = http_client.HttpClient(auth)
|
||||
cls.fake_prometheus_ip = cls.get_controller_tacker_ip()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(BaseVnfLcmKubernetesV2Test, cls).tearDownClass()
|
||||
FAKE_SERVER_MANAGER.stop_server()
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
callback_url = os.path.join(
|
||||
MOCK_NOTIFY_CALLBACK_URL,
|
||||
self._testMethodName)
|
||||
FAKE_SERVER_MANAGER.clear_history(callback_url)
|
||||
FAKE_SERVER_MANAGER.set_callback('POST', callback_url, status_code=204)
|
||||
FAKE_SERVER_MANAGER.set_callback('GET', callback_url, status_code=204)
|
||||
|
||||
@classmethod
|
||||
def get_vim_info(cls):
|
||||
vim_params = yaml.safe_load(base_utils.read_file('local-vim.yaml'))
|
||||
vim_params['auth_url'] += '/v3'
|
||||
|
||||
vim_info = objects.VimConnectionInfo(
|
||||
interfaceInfo={'endpoint': vim_params['auth_url']},
|
||||
accessInfo={
|
||||
'region': 'RegionOne',
|
||||
'project': vim_params['project_name'],
|
||||
'username': vim_params['username'],
|
||||
'password': vim_params['password'],
|
||||
'userDomain': vim_params['user_domain_name'],
|
||||
'projectDomain': vim_params['project_domain_name']
|
||||
}
|
||||
)
|
||||
|
||||
return vim_info
|
||||
|
||||
@classmethod
|
||||
def get_k8s_vim_info(cls):
|
||||
@ -138,46 +76,11 @@ class BaseVnfLcmKubernetesV2Test(base.BaseTestCase):
|
||||
@classmethod
|
||||
def create_vnf_package(cls, sample_path, user_data={}, image_path=None,
|
||||
provider=None, namespace=None):
|
||||
vnfd_id = uuidutils.generate_uuid()
|
||||
tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
utils.make_zip(sample_path, tmp_dir, vnfd_id, image_path,
|
||||
provider=provider, namespace=namespace)
|
||||
|
||||
zip_file_name = os.path.basename(os.path.abspath(sample_path)) + ".zip"
|
||||
zip_file_path = os.path.join(tmp_dir, zip_file_name)
|
||||
|
||||
path = "/vnfpkgm/v1/vnf_packages"
|
||||
req_body = {'userDefinedData': user_data}
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "POST", expected_status=[201], body=req_body)
|
||||
|
||||
pkg_id = body['id']
|
||||
|
||||
with open(zip_file_path, 'rb') as fp:
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}/package_content"
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "PUT", body=fp, content_type='application/zip',
|
||||
expected_status=[202])
|
||||
|
||||
# wait for onboard
|
||||
timeout = VNF_PACKAGE_UPLOAD_TIMEOUT
|
||||
start_time = int(time.time())
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
while True:
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200])
|
||||
if body['onboardingState'] == "ONBOARDED":
|
||||
break
|
||||
|
||||
if ((int(time.time()) - start_time) > timeout):
|
||||
raise Exception("Failed to onboard vnf package")
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
shutil.rmtree(tmp_dir)
|
||||
|
||||
return pkg_id, vnfd_id
|
||||
return super().create_vnf_package(sample_path, user_data=user_data,
|
||||
image_path=image_path,
|
||||
provider=provider,
|
||||
namespace=namespace)
|
||||
|
||||
@classmethod
|
||||
def get_controller_tacker_ip(cls):
|
||||
@ -190,330 +93,121 @@ class BaseVnfLcmKubernetesV2Test(base.BaseTestCase):
|
||||
'http://')[1].split('"')[0]
|
||||
return ip
|
||||
|
||||
def assert_notification_get(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
|
||||
def _check_notification(self, callback_url, notify_type):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
self.assertEqual(notify_type, notify_mock_responses[0].request_body[
|
||||
'notificationType'])
|
||||
|
||||
def _check_no_notification(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
self.assertEqual(0, len(notify_mock_responses))
|
||||
|
||||
def _get_crossing_direction(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
return notify_mock_responses[0].request_body['crossingDirection']
|
||||
|
||||
@classmethod
|
||||
def delete_vnf_package(cls, pkg_id):
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
req_body = {"operationalState": "DISABLED"}
|
||||
resp, _ = cls.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body)
|
||||
if resp.status_code != 200:
|
||||
print("failed to set operationalState to DISABLED")
|
||||
return
|
||||
|
||||
cls.tacker_client.do_request(path, "DELETE")
|
||||
|
||||
def list_vims(self):
|
||||
path = "/v1.0/vims.json"
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
return body
|
||||
|
||||
def get_vnf_package(self, pkg_id):
|
||||
path = f"/vnfpkgm/v1/vnf_packages/{pkg_id}"
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
return body
|
||||
|
||||
def create_vnf_instance(self, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def delete_vnf_instance(self, inst_id):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.0.0")
|
||||
|
||||
def show_vnf_instance(self, inst_id):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def instantiate_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/instantiate"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def scale_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/scale"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def heal_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/heal"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def change_vnfpkg(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/change_vnfpkg"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def terminate_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/terminate"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def rollback_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/rollback"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def retry_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/retry"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def fail_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/fail"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def show_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def list_lcmocc(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def create_subscription(self, req_body):
|
||||
def create_fm_subscription(self, req_body):
|
||||
path = "/vnffm/v1/subscriptions"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="1.3.0")
|
||||
path, "POST", body=req_body, version=VNFFM_V1_VERSION)
|
||||
|
||||
def list_subscriptions(self, filter_expr=None):
|
||||
def list_fm_subscriptions(self, filter_expr=None):
|
||||
path = "/vnffm/v1/subscriptions"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="1.3.0")
|
||||
path, "GET", version=VNFFM_V1_VERSION)
|
||||
|
||||
def show_subscription(self, subscription_id):
|
||||
def show_fm_subscription(self, subscription_id):
|
||||
path = f"/vnffm/v1/subscriptions/{subscription_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="1.3.0")
|
||||
path, "GET", version=VNFFM_V1_VERSION)
|
||||
|
||||
def delete_subscription(self, subscription_id):
|
||||
def delete_fm_subscription(self, subscription_id):
|
||||
path = f"/vnffm/v1/subscriptions/{subscription_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="1.3.0")
|
||||
path, "DELETE", version=VNFFM_V1_VERSION)
|
||||
|
||||
def create_fm_alarm(self, req_body):
|
||||
path = "/alert"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="1.3.0")
|
||||
path, "POST", body=req_body, version=VNFFM_V1_VERSION)
|
||||
|
||||
def list_fm_alarm(self, filter_expr=None):
|
||||
path = "/vnffm/v1/alarms"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="1.3.0")
|
||||
path, "GET", version=VNFFM_V1_VERSION)
|
||||
|
||||
def show_fm_alarm(self, alarm_id):
|
||||
path = f"/vnffm/v1/alarms/{alarm_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="1.3.0")
|
||||
path, "GET", version=VNFFM_V1_VERSION)
|
||||
|
||||
def update_fm_alarm(self, alarm_id, req_body):
|
||||
path = f"/vnffm/v1/alarms/{alarm_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body, version="1.3.0")
|
||||
path, "PATCH", body=req_body, version=VNFFM_V1_VERSION)
|
||||
|
||||
def create_pm_job(self, req_body):
|
||||
path = "/vnfpm/v2/pm_jobs"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def update_pm_job(self, pm_job_id, req_body):
|
||||
path = f"/vnfpm/v2/pm_jobs/{pm_job_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body, version="2.1.0")
|
||||
path, "PATCH", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def create_pm_event(self, req_body):
|
||||
path = "/pm_event"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def list_pm_job(self, filter_expr=None):
|
||||
path = "/vnfpm/v2/pm_jobs"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.1.0")
|
||||
path, "GET", version=VNFPM_V2_VERSION)
|
||||
|
||||
def show_pm_job(self, pm_job_id):
|
||||
path = f"/vnfpm/v2/pm_jobs/{pm_job_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.1.0")
|
||||
path, "GET", version=VNFPM_V2_VERSION)
|
||||
|
||||
def show_pm_job_report(self, pm_job_id, report_id):
|
||||
path = f"/vnfpm/v2/pm_jobs/{pm_job_id}/reports/{report_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.1.0")
|
||||
path, "GET", version=VNFPM_V2_VERSION)
|
||||
|
||||
def delete_pm_job(self, pm_job_id):
|
||||
path = f"/vnfpm/v2/pm_jobs/{pm_job_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.1.0")
|
||||
path, "DELETE", version=VNFPM_V2_VERSION)
|
||||
|
||||
def create_pm_threshold(self, req_body):
|
||||
path = "/vnfpm/v2/thresholds"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def update_pm_threshold(self, pm_threshold_id, req_body):
|
||||
path = f"/vnfpm/v2/thresholds/{pm_threshold_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body, version="2.1.0",
|
||||
path, "PATCH", body=req_body, version=VNFPM_V2_VERSION,
|
||||
content_type="application/mergepatch+json")
|
||||
|
||||
def pm_threshold(self, req_body):
|
||||
path = "/pm_threshold"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.1.0")
|
||||
path, "POST", body=req_body, version=VNFPM_V2_VERSION)
|
||||
|
||||
def list_pm_threshold(self, filter_expr=None):
|
||||
path = "/vnfpm/v2/thresholds"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.1.0")
|
||||
path, "GET", version=VNFPM_V2_VERSION)
|
||||
|
||||
def show_pm_threshold(self, pm_threshold_id):
|
||||
path = f"/vnfpm/v2/thresholds/{pm_threshold_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.1.0")
|
||||
path, "GET", version=VNFPM_V2_VERSION)
|
||||
|
||||
def delete_pm_threshold(self, pm_threshold_id):
|
||||
path = f"/vnfpm/v2/thresholds/{pm_threshold_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.1.0")
|
||||
|
||||
def prometheus_auto_scaling_alert(self, req_body):
|
||||
path = "/alert/auto_scaling"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def prometheus_auto_healing_alert(self, req_body):
|
||||
path = "/alert/auto_healing"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def _check_resp_headers(self, resp, supported_headers):
|
||||
unsupported_headers = ['Link', 'Retry-After',
|
||||
'Content-Range', 'WWW-Authenticate']
|
||||
for s in supported_headers:
|
||||
if s not in resp.headers:
|
||||
raise Exception("Supported header doesn't exist: %s" % s)
|
||||
for u in unsupported_headers:
|
||||
if u in resp.headers:
|
||||
raise Exception("Unsupported header exist: %s" % u)
|
||||
|
||||
def check_resp_headers_in_create(self, resp):
|
||||
# includes location header and response body
|
||||
supported_headers = ['Version', 'Location', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_body(self, body, expected_attrs):
|
||||
for attr in expected_attrs:
|
||||
if attr not in body:
|
||||
raise Exception("Expected attribute doesn't exist: %s" % attr)
|
||||
|
||||
def check_resp_headers_in_operation_task(self, resp):
|
||||
# includes location header and no response body
|
||||
supported_headers = ['Version', 'Location']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_get(self, resp):
|
||||
# includes response body and no location header
|
||||
supported_headers = ['Version', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_delete(self, resp):
|
||||
# no location header and response body
|
||||
supported_headers = ['Version']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def wait_lcmocc_complete(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'COMPLETED':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
else: # FAILED_TEMP or ROLLED_BACK
|
||||
raise Exception("Operation failed. state: %s" % state)
|
||||
|
||||
def wait_lcmocc_failed_temp(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'FAILED_TEMP':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
elif state == 'COMPLETED':
|
||||
raise Exception("Operation unexpected COMPLETED.")
|
||||
else: # ROLLED_BACK
|
||||
raise Exception("Operation failed. state: %s" % state)
|
||||
|
||||
def wait_lcmocc_rolled_back(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'ROLLED_BACK':
|
||||
return
|
||||
if state in ['ROLLING_BACK']:
|
||||
continue
|
||||
|
||||
raise Exception(f"Operation failed. state: {state}")
|
||||
path, "DELETE", version=VNFPM_V2_VERSION)
|
||||
|
@ -19,6 +19,8 @@ import time
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
WAIT_LCMOCC_UPDATE_TIME = 3
|
||||
|
||||
|
||||
class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
@ -30,20 +32,20 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.old_pkg, cls.old_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
test_change_vnf_pkg_with_deployment_path = os.path.join(
|
||||
cur_dir, "samples/test_change_vnf_pkg_with_deployment")
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.new_pkg, cls.new_vnfd_id = cls.create_vnf_package(
|
||||
test_change_vnf_pkg_with_deployment_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmKubernetesChangeVnfpkgTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.old_pkg)
|
||||
cls.delete_vnf_package(cls.new_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfLcmKubernetesChangeVnfpkgTest, self).setUp()
|
||||
@ -83,7 +85,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.old_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -91,8 +93,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.old_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
instantiate_req = paramgen.change_vnfpkg_instantiate(
|
||||
@ -121,21 +122,20 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(2, len(before_resource_ids))
|
||||
|
||||
# 4. Change Current VNF Package
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.vnfd_id_2)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.new_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.old_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2).get('usageState')
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.new_pkg, 'IN_USE')
|
||||
|
||||
# 5. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -163,12 +163,8 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 7. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -177,8 +173,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.new_pkg, 'NOT_IN_USE')
|
||||
|
||||
def test_change_vnfpkg_failed_and_rollback(self):
|
||||
"""Test LCM operations error handing
|
||||
@ -216,7 +211,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.old_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -224,8 +219,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.old_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
instantiate_req = paramgen.change_vnfpkg_instantiate(
|
||||
@ -253,7 +247,7 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
for vnfc_info in vnfc_resource_infos]
|
||||
|
||||
# 4. Change Current VNF Package (will fail)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg_error(self.vnfd_id_2)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg_error(self.new_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -292,12 +286,8 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 8. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -306,5 +296,4 @@ class VnfLcmKubernetesChangeVnfpkgTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.new_pkg, 'NOT_IN_USE')
|
||||
|
@ -19,6 +19,8 @@ import time
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
WAIT_LCMOCC_UPDATE_TIME = 3
|
||||
|
||||
|
||||
class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
@ -30,12 +32,12 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_helm_instantiate_path = os.path.join(
|
||||
cur_dir, "samples/test_helm_instantiate")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.helm_pkg, cls.helm_vnfd_id = cls.create_vnf_package(
|
||||
test_helm_instantiate_path)
|
||||
|
||||
test_helm_change_vnf_pkg_path = os.path.join(
|
||||
cur_dir, "samples/test_helm_change_vnf_pkg")
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.new_pkg, cls.new_vnfd_id = cls.create_vnf_package(
|
||||
test_helm_change_vnf_pkg_path)
|
||||
cls.helm_vim_id = cls.get_k8s_vim_id(use_helm=True)
|
||||
|
||||
@ -43,8 +45,8 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmHelmTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.helm_pkg)
|
||||
cls.delete_vnf_package(cls.new_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfLcmHelmTest, self).setUp()
|
||||
@ -96,7 +98,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_helm_instantiate_create(
|
||||
self.vnfd_id_1)
|
||||
self.helm_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -104,8 +106,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.helm_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
if not use_register_vim:
|
||||
@ -217,21 +218,20 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
vnfc_resource_infos = body['instantiatedVnfInfo']['vnfcResourceInfo']
|
||||
before_vdu2_ids = [vnfc_info['id'] for vnfc_info in vnfc_resource_infos
|
||||
if vnfc_info['vduId'] == 'VDU2']
|
||||
change_vnfpkg_req = paramgen.helm_change_vnfpkg(self.vnfd_id_2)
|
||||
change_vnfpkg_req = paramgen.helm_change_vnfpkg(self.new_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
time.sleep(3)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.helm_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2).get('usageState')
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.new_pkg, 'IN_USE')
|
||||
|
||||
# 11. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -259,12 +259,8 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 13. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -273,15 +269,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
|
||||
def _put_fail_file(self, operation):
|
||||
with open(f'/tmp/{operation}', 'w'):
|
||||
pass
|
||||
|
||||
def _rm_fail_file(self, operation):
|
||||
os.remove(f'/tmp/{operation}')
|
||||
self.check_package_usage(self.helm_pkg, 'NOT_IN_USE')
|
||||
|
||||
def test_instantiate_rollback(self):
|
||||
"""Test LCM operations with all attributes set
|
||||
@ -298,14 +286,14 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 1. Create a new VNF instance resource
|
||||
create_req = paramgen.test_helm_instantiate_create(
|
||||
self.vnfd_id_1)
|
||||
self.helm_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
inst_id = body['id']
|
||||
|
||||
# 2. Instantiate a VNF instance => FAILED_TEMP
|
||||
self._put_fail_file('instantiate_end')
|
||||
self.put_fail_file('instantiate_end')
|
||||
instantiate_req = paramgen.helm_instantiate(
|
||||
self.auth_url, self.bearer_token, self.ssl_ca_cert)
|
||||
resp, body = self.instantiate_vnf_instance(inst_id, instantiate_req)
|
||||
@ -314,7 +302,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('instantiate_end')
|
||||
self.rm_fail_file('instantiate_end')
|
||||
|
||||
# 3. Show VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -355,7 +343,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 1. Create a new VNF instance resource
|
||||
create_req = paramgen.test_helm_instantiate_create(
|
||||
self.vnfd_id_1)
|
||||
self.helm_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -382,7 +370,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(1, len(vdu2_ids_0))
|
||||
|
||||
# 4. Scale out a VNF instance => FAILED_TEMP
|
||||
self._put_fail_file('scale_end')
|
||||
self.put_fail_file('scale_end')
|
||||
scale_out_req = paramgen.helm_scale_out()
|
||||
resp, body = self.scale_vnf_instance(inst_id, scale_out_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
@ -390,7 +378,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('scale_end')
|
||||
self.rm_fail_file('scale_end')
|
||||
|
||||
# 5. Rollback scale out
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -416,12 +404,8 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 8. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -461,7 +445,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_helm_instantiate_create(
|
||||
self.vnfd_id_1)
|
||||
self.helm_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -469,8 +453,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.helm_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
instantiate_req = paramgen.helm_instantiate(
|
||||
@ -499,7 +482,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 4. Change Current VNF Package => FAILED_TEMP
|
||||
change_vnfpkg_req = paramgen.helm_error_handling_change_vnfpkg(
|
||||
self.vnfd_id_2)
|
||||
self.new_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -514,8 +497,7 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.wait_lcmocc_rolled_back(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.new_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 6. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -542,12 +524,8 @@ class VnfLcmHelmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 8. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -38,14 +38,14 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(PromAutoScaleHealTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(PromAutoScaleHealTest, self).setUp()
|
||||
@ -69,7 +69,8 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
"""
|
||||
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -95,8 +96,9 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 4-5. Send alert and auto heal
|
||||
affected_vnfcs = body['resourceChanges']['affectedVnfcs']
|
||||
vnfc_info_id = (affected_vnfcs[0]['vduId'] + '-'
|
||||
+ affected_vnfcs[0]['id'])
|
||||
vnfc_info_id = (f"{affected_vnfcs[0]['vduId']}-"
|
||||
f"{affected_vnfcs[0]['id']}")
|
||||
|
||||
alert = paramgen.prometheus_auto_healing_alert(inst_id, vnfc_info_id)
|
||||
resp, body = self.prometheus_auto_healing_alert(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
@ -134,8 +136,8 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
if vnfc['changeType'] == 'REMOVED']
|
||||
self.assertEqual(1, len(removed_vnfcs))
|
||||
|
||||
removed_vnfc_info_id = (affected_vnfcs[0]['vduId'] + '-'
|
||||
+ affected_vnfcs[0]['id'])
|
||||
removed_vnfc_info_id = (f"{affected_vnfcs[0]['vduId']}-"
|
||||
f"{affected_vnfcs[0]['id']}")
|
||||
self.assertEqual(vnfc_info_id, removed_vnfc_info_id)
|
||||
|
||||
# 7. Send alert
|
||||
@ -190,8 +192,8 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(2, len(removed_vnfcs))
|
||||
|
||||
removed_vnfc_info_ids = [
|
||||
removed_vnfcs[0]['vduId'] + '-' + removed_vnfcs[0]['id'],
|
||||
removed_vnfcs[1]['vduId'] + '-' + removed_vnfcs[1]['id']
|
||||
f"{removed_vnfcs[0]['vduId']}-{removed_vnfcs[0]['id']}",
|
||||
f"{removed_vnfcs[1]['vduId']}-{removed_vnfcs[1]['id']}"
|
||||
]
|
||||
self.assertCountEqual(
|
||||
[vnfc_info_id_1, vnfc_info_id_2], removed_vnfc_info_ids)
|
||||
@ -204,10 +206,6 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# 12. LCM-Show-OpOccV2: Show OpOcc
|
||||
resp, body = self.show_lcmocc(lcmocc_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -215,7 +213,7 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual('TERMINATE', body['operation'])
|
||||
|
||||
# 13. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -240,7 +238,8 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
"""
|
||||
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -336,10 +335,6 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# 11. LCM-Show-OpOccV2: Show OpOcc
|
||||
resp, body = self.show_lcmocc(lcmocc_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -347,7 +342,7 @@ class PromAutoScaleHealTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual('TERMINATE', body['operation'])
|
||||
|
||||
# 12. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -17,11 +17,10 @@ import os
|
||||
import time
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.common.fake_server import FakeServerManager
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
FAKE_SERVER_MANAGER = FakeServerManager()
|
||||
WAIT_CREATE_THRESHOLD_TIME = 5
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
@ -35,19 +34,18 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfPmThresholdTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfPmThresholdTest, self).setUp()
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'PUT', "/-/reload",
|
||||
status_code=202,
|
||||
self.set_server_callback(
|
||||
'PUT', "/-/reload", status_code=202,
|
||||
response_headers={"Content-Type": "text/plain"})
|
||||
|
||||
def test_pm_threshold_autoscaling_min(self):
|
||||
@ -109,7 +107,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
"""
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -138,10 +136,10 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_threshold_min(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip
|
||||
@ -160,7 +158,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -206,7 +204,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -235,7 +233,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -264,7 +262,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -293,10 +291,6 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -305,7 +299,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 13. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -375,7 +369,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -404,10 +398,10 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_threshold_max(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -425,7 +419,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -472,7 +466,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -502,7 +496,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -532,7 +526,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -561,10 +555,6 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -574,14 +564,14 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
|
||||
# 13. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
def test_pm_threshold_with_all_attibutes(self):
|
||||
def test_pm_threshold_with_all_attributes(self):
|
||||
"""Test PM Threshold operations with all attributes set
|
||||
|
||||
* About attributes:
|
||||
@ -632,7 +622,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -660,10 +650,10 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_threshold_max(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip
|
||||
@ -680,9 +670,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
sub_req = paramgen.pm_threshold(pm_threshold_id_5, inst_id)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('UP', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -694,9 +684,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self._check_no_notification(callback_url)
|
||||
|
||||
# 6. PM-Threshold 5-3
|
||||
@ -706,9 +696,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self._check_no_notification(callback_url)
|
||||
|
||||
# 7. PM-Threshold 5-4
|
||||
@ -718,9 +708,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self._check_no_notification(callback_url)
|
||||
|
||||
# 8. PM-Threshold 5-5
|
||||
@ -730,9 +720,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self.assertEqual('DOWN', self._get_crossing_direction(callback_url))
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
@ -744,9 +734,9 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(5)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(WAIT_CREATE_THRESHOLD_TIME)
|
||||
self._check_no_notification(callback_url)
|
||||
|
||||
resp, body = self.delete_pm_threshold(pm_threshold_id_5)
|
||||
@ -761,10 +751,6 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -774,7 +760,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
)
|
||||
|
||||
# 11. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -20,6 +20,8 @@ from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
WAIT_NOTIFICATION_TIME = 5
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
@ -32,14 +34,14 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfFmTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfFmTest, self).setUp()
|
||||
@ -77,7 +79,8 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -103,33 +106,33 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 3. FM-Create-Subscription: Create a new subscription
|
||||
expected_inst_attrs = ['id', 'callbackUri', '_links']
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
resp, body = self.create_subscription(sub_req)
|
||||
resp, body = self.create_fm_subscription(sub_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
sub_id = body['id']
|
||||
self.check_resp_body(body, expected_inst_attrs)
|
||||
# Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
self.addCleanup(self.delete_subscription, sub_id)
|
||||
self.addCleanup(self.delete_fm_subscription, sub_id)
|
||||
|
||||
# 4. FM-List-Subscription: List subscription with attribute-based
|
||||
# filtering
|
||||
expected_attrs = ['id', 'callbackUri', '_links']
|
||||
resp, body = self.list_subscriptions()
|
||||
resp, body = self.list_fm_subscriptions()
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
for sbsc in body:
|
||||
self.check_resp_body(sbsc, expected_attrs)
|
||||
|
||||
# 5. FM-Show-Subscription: Show subscription
|
||||
resp, body = self.show_subscription(sub_id)
|
||||
resp, body = self.show_fm_subscription(sub_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
self.check_resp_body(body, expected_attrs)
|
||||
@ -138,7 +141,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
alert = paramgen.alert_event_firing(inst_id, pod_name)
|
||||
resp, body = self.create_fm_alarm(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmNotification')
|
||||
|
||||
# 7. FM-List-Alarm
|
||||
@ -201,7 +204,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
alert = paramgen.alert_event_resolved(inst_id, pod_name)
|
||||
resp, body = self.create_fm_alarm(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmClearedNotification')
|
||||
|
||||
# 12. FM-Show-Alarm
|
||||
@ -211,7 +214,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.check_resp_body(body, alarm_expected_attrs)
|
||||
|
||||
# 13. FM-Delete-Subscription: Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
resp, body = self.delete_fm_subscription(sub_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -223,10 +226,6 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -234,7 +233,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 15. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -274,7 +273,8 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -300,14 +300,14 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 3. FM-Create-Subscription: Create a new subscription
|
||||
expected_inst_attrs = ['id', 'callbackUri', '_links', 'filter']
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.sub_create_max(
|
||||
callback_uri, self.vnfd_id_1, inst_id)
|
||||
resp, body = self.create_subscription(sub_req)
|
||||
callback_uri, self.cnf_vnfd_id, inst_id)
|
||||
resp, body = self.create_fm_subscription(sub_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
sub_id = body['id']
|
||||
@ -321,14 +321,14 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
filter_expr = {
|
||||
'filter': f'(eq,id,{sub_id})'
|
||||
}
|
||||
resp, body = self.list_subscriptions(filter_expr)
|
||||
resp, body = self.list_fm_subscriptions(filter_expr)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
for sbsc in body:
|
||||
self.check_resp_body(sbsc, expected_attrs)
|
||||
|
||||
# 5. FM-Show-Subscription: Show subscription
|
||||
resp, body = self.show_subscription(sub_id)
|
||||
resp, body = self.show_fm_subscription(sub_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
self.check_resp_body(body, expected_attrs)
|
||||
@ -337,7 +337,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
alert = paramgen.alert_event_firing(inst_id, pod_name)
|
||||
resp, body = self.create_fm_alarm(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmNotification')
|
||||
|
||||
# 7. FM-List-Alarm
|
||||
@ -399,7 +399,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
alert = paramgen.alert_event_resolved(inst_id, pod_name)
|
||||
resp, body = self.create_fm_alarm(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(callback_url, 'AlarmClearedNotification')
|
||||
|
||||
# 12. FM-Show-Alarm
|
||||
@ -409,7 +409,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.check_resp_body(body, alarm_expected_attrs)
|
||||
|
||||
# 13. FM-Delete-Subscription: Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
resp, body = self.delete_fm_subscription(sub_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -421,10 +421,6 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -432,7 +428,7 @@ class VnfFmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 15. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
@ -32,14 +31,14 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmKubernetesTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfLcmKubernetesTest, self).setUp()
|
||||
@ -91,7 +90,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -99,8 +98,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
instantiate_req = paramgen.max_sample_instantiate(
|
||||
@ -225,12 +223,8 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 11. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -239,8 +233,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'NOT_IN_USE')
|
||||
|
||||
def test_basic_lcms_min(self):
|
||||
"""Test LCM operations with all attributes set
|
||||
@ -281,7 +274,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -289,8 +282,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.cnf_pkg, 'IN_USE')
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
vim_id = self.get_k8s_vim_id()
|
||||
@ -327,12 +319,8 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 5. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -341,15 +329,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1).get('usageState')
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
|
||||
def _put_fail_file(self, operation):
|
||||
with open(f'/tmp/{operation}', 'w'):
|
||||
pass
|
||||
|
||||
def _rm_fail_file(self, operation):
|
||||
os.remove(f'/tmp/{operation}')
|
||||
self.check_package_usage(self.cnf_pkg, 'NOT_IN_USE')
|
||||
|
||||
def test_instantiate_rollback(self):
|
||||
"""Test LCM operations with all attributes set
|
||||
@ -366,14 +346,14 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 1. Create a new VNF instance resource
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
inst_id = body['id']
|
||||
|
||||
# 2. Instantiate a VNF instance
|
||||
self._put_fail_file('instantiate_end')
|
||||
self.put_fail_file('instantiate_end')
|
||||
instantiate_req = paramgen.error_handling_instantiate(
|
||||
self.auth_url, self.bearer_token)
|
||||
resp, body = self.instantiate_vnf_instance(inst_id, instantiate_req)
|
||||
@ -382,7 +362,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('instantiate_end')
|
||||
self.rm_fail_file('instantiate_end')
|
||||
|
||||
# 3. Show VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -423,7 +403,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 1. Create a new VNF instance resource
|
||||
create_req = paramgen.test_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -450,7 +430,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
self.assertEqual(2, len(vdu2_ids_0))
|
||||
|
||||
# 4. Scale out a VNF instance
|
||||
self._put_fail_file('scale_end')
|
||||
self.put_fail_file('scale_end')
|
||||
scale_out_req = paramgen.error_handling_scale_out()
|
||||
resp, body = self.scale_vnf_instance(inst_id, scale_out_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
@ -458,7 +438,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('scale_end')
|
||||
self.rm_fail_file('scale_end')
|
||||
|
||||
# 5. Rollback instantiate
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -484,11 +464,7 @@ class VnfLcmKubernetesTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(3)
|
||||
|
||||
# 8. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
@ -20,6 +20,8 @@ from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
WAIT_NOTIFICATION_TIME = 5
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
@ -32,17 +34,17 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfPmTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfPmTest, self).setUp()
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'PUT', "/-/reload", status_code=202,
|
||||
response_headers={"Content-Type": "text/plain"})
|
||||
|
||||
@ -75,7 +77,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -100,10 +102,10 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_job_min(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -116,16 +118,14 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
pm_job_id = body.get('id')
|
||||
|
||||
# 4. PMJob-Update
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_url = callback_url + '_1'
|
||||
callback_url = f"{callback_url}_1"
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'GET', callback_url, status_code=204)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'POST', callback_url, status_code=204)
|
||||
self.set_server_callback('GET', callback_url, status_code=204)
|
||||
self.set_server_callback('POST', callback_url, status_code=204)
|
||||
update_req = paramgen.update_pm_job(callback_uri)
|
||||
resp, body = self.update_pm_job(pm_job_id, update_req)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -137,7 +137,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
sub_req = paramgen.pm_event(pm_job_id, inst_id)
|
||||
resp, body = self.create_pm_event(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'PerformanceInformationAvailableNotification')
|
||||
|
||||
@ -177,10 +177,6 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -188,7 +184,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 11. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -223,7 +219,8 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -248,10 +245,10 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_job_max(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -264,16 +261,14 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
pm_job_id = body.get('id')
|
||||
|
||||
# 4. PMJob-Update
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_url = callback_url + '_1'
|
||||
callback_url = f"{callback_url}_1"
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'GET', callback_url, status_code=204)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'POST', callback_url, status_code=204)
|
||||
self.set_server_callback('GET', callback_url, status_code=204)
|
||||
self.set_server_callback('POST', callback_url, status_code=204)
|
||||
update_req = paramgen.update_pm_job(callback_uri)
|
||||
resp, body = self.update_pm_job(pm_job_id, update_req)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -285,7 +280,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
sub_req = paramgen.pm_event(pm_job_id, inst_id)
|
||||
resp, body = self.create_pm_event(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'PerformanceInformationAvailableNotification')
|
||||
|
||||
@ -326,10 +321,6 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -337,7 +328,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 11. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -359,7 +350,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
"""
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -387,10 +378,10 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
pm_job_list = paramgen.pm_job_external(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip, rsc)
|
||||
@ -417,10 +408,6 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -428,7 +415,7 @@ class VnfPmTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 6. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -20,6 +20,8 @@ from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import base_v2
|
||||
from tacker.tests.functional.sol_kubernetes_v2 import paramgen
|
||||
|
||||
WAIT_NOTIFICATION_TIME = 5
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
@ -32,19 +34,18 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
test_instantiate_cnf_resources_path = os.path.join(
|
||||
cur_dir, "samples/test_instantiate_cnf_resources")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.cnf_pkg, cls.cnf_vnfd_id = cls.create_vnf_package(
|
||||
test_instantiate_cnf_resources_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfPmThresholdTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.cnf_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(VnfPmThresholdTest, self).setUp()
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'PUT', "/-/reload",
|
||||
status_code=202,
|
||||
self.set_server_callback(
|
||||
'PUT', "/-/reload", status_code=202,
|
||||
response_headers={"Content-Type": "text/plain"})
|
||||
|
||||
def test_pm_threshold_interface_min(self):
|
||||
@ -73,7 +74,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.pm_instantiate_cnf_resources_create(
|
||||
self.vnfd_id_1)
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -98,10 +99,10 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_threshold_min(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip
|
||||
@ -116,19 +117,17 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
|
||||
# 4. PMThreshold-Update
|
||||
callback_url = os.path.join(
|
||||
base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
self.get_notify_callback_url(),
|
||||
self._testMethodName
|
||||
)
|
||||
callback_url = f'{callback_url}_1'
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
# Because the update of the threshold is executed, the 'callback_url'
|
||||
# is updated, so the url of the fake server needs to be modified.
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'GET', callback_url, status_code=204)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'POST', callback_url, status_code=204)
|
||||
self.set_server_callback('GET', callback_url, status_code=204)
|
||||
self.set_server_callback('POST', callback_url, status_code=204)
|
||||
update_req = paramgen.update_pm_threshold(callback_uri)
|
||||
resp, body = self.update_pm_threshold(pm_threshold_id, update_req)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -141,9 +140,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
sub_req = paramgen.pm_threshold(pm_threshold_id, inst_id)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
|
||||
@ -173,10 +170,6 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -185,7 +178,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 10. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -219,7 +212,8 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
# 1. LCM-Create: Create a new VNF instance resource
|
||||
# NOTE: extensions and vnfConfigurableProperties are omitted
|
||||
# because they are commented out in etsi_nfv_sol001.
|
||||
create_req = paramgen.instantiate_cnf_resources_create(self.vnfd_id_1)
|
||||
create_req = paramgen.instantiate_cnf_resources_create(
|
||||
self.cnf_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -244,10 +238,10 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
'callbackUri',
|
||||
'_links'
|
||||
]
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
sub_req = paramgen.pm_threshold_max(
|
||||
callback_uri, inst_id, self.fake_prometheus_ip)
|
||||
@ -260,18 +254,16 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
pm_threshold_id = body.get('id')
|
||||
|
||||
# 4. PMThreshold-Update
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_url = f'{callback_url}_1'
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
# Because the update of the threshold is executed, the 'callback_url'
|
||||
# is updated, so the url of the fake server needs to be modified.
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'GET', callback_url, status_code=204)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
'POST', callback_url, status_code=204)
|
||||
self.set_server_callback('GET', callback_url, status_code=204)
|
||||
self.set_server_callback('POST', callback_url, status_code=204)
|
||||
update_req = paramgen.update_pm_threshold(callback_uri)
|
||||
resp, body = self.update_pm_threshold(pm_threshold_id, update_req)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -284,9 +276,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
sub_req = paramgen.pm_threshold(pm_threshold_id, inst_id)
|
||||
resp, body = self.pm_threshold(sub_req)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
# The creation of "pm_threshold" will be asynchronous
|
||||
# and wait for the creation to end
|
||||
time.sleep(5)
|
||||
time.sleep(WAIT_NOTIFICATION_TIME)
|
||||
self._check_notification(
|
||||
callback_url, 'ThresholdCrossedNotification')
|
||||
|
||||
@ -317,10 +307,6 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -328,7 +314,7 @@ class VnfPmThresholdTest(base_v2.BaseVnfLcmKubernetesV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 10. LCM-Delete: Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -49,7 +49,7 @@ class GrantV2:
|
||||
"userDomain": "Default"
|
||||
}
|
||||
vim_params = yaml.safe_load(base_utils.read_file('local-vim.yaml'))
|
||||
vim_params['auth_url'] += '/v3'
|
||||
vim_params['auth_url'] = f"{vim_params['auth_url']}/v3"
|
||||
return {
|
||||
"vim1": {
|
||||
"vimId": uuidsentinel.vim_connection_id,
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
@ -39,35 +38,35 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
change_vnfpkg_from_image_to_image_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/"
|
||||
"test_instantiate_vnf_with_old_image_or_volume")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.old_pkg, cls.old_vnfd_id = cls.create_vnf_package(
|
||||
change_vnfpkg_from_image_to_image_path)
|
||||
|
||||
change_vnfpkg_from_image_to_image_path_2 = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/"
|
||||
"test_change_vnf_pkg_with_new_image")
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.new_image_pkg, cls.new_image_vnfd_id = cls.create_vnf_package(
|
||||
change_vnfpkg_from_image_to_image_path_2, image_path=image_path)
|
||||
|
||||
change_vnfpkg_from_image_to_volume_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/"
|
||||
"test_change_vnf_pkg_with_new_volume")
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(
|
||||
cls.new_volume_pkg, cls.new_volume_vnfd_id = cls.create_vnf_package(
|
||||
change_vnfpkg_from_image_to_volume_path, image_path=image_path)
|
||||
|
||||
change_vnfpkg_failed_in_update_path = os.path.join(
|
||||
cur_dir, "../sol_v2_common/samples/"
|
||||
"test_change_vnf_pkg_with_update_failed")
|
||||
cls.vnf_pkg_4, cls.vnfd_id_4 = cls.create_vnf_package(
|
||||
cls.failed_pkg, cls.failed_vnfd_id = cls.create_vnf_package(
|
||||
change_vnfpkg_failed_in_update_path, image_path=image_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(ChangeVnfPkgVnfLcmTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_4)
|
||||
cls.delete_vnf_package(cls.old_pkg)
|
||||
cls.delete_vnf_package(cls.new_image_pkg)
|
||||
cls.delete_vnf_package(cls.new_volume_pkg)
|
||||
cls.delete_vnf_package(cls.failed_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super(ChangeVnfPkgVnfLcmTest, self).setUp()
|
||||
@ -76,7 +75,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.change_vnfpkg_from_image_to_image_common_test()
|
||||
|
||||
def test_change_vnfpkg_from_volume_to_volume(self):
|
||||
create_req = paramgen.change_vnfpkg_create(self.vnfd_id_1)
|
||||
create_req = paramgen.change_vnfpkg_create(self.old_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
expected_inst_attrs = [
|
||||
'id',
|
||||
@ -132,7 +131,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.check_resp_headers_in_get(resp_1)
|
||||
self.check_resp_body(body_1, expected_inst_attrs)
|
||||
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.vnfd_id_3)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.new_volume_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -165,16 +164,12 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
def test_change_vnfpkg_failed_in_update(self):
|
||||
create_req = paramgen.change_vnfpkg_create(self.vnfd_id_1)
|
||||
create_req = paramgen.change_vnfpkg_create(self.old_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
expected_inst_attrs = [
|
||||
'id',
|
||||
@ -221,7 +216,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.check_resp_headers_in_get(resp_1)
|
||||
self.check_resp_body(body_1, expected_inst_attrs)
|
||||
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.vnfd_id_4)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.failed_vnfd_id)
|
||||
del change_vnfpkg_req['additionalParams']['vdu_params'][1]
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
@ -230,7 +225,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
|
||||
resp, body = self.rollback(lcmocc_id)
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.wait_lcmocc_rolled_back(lcmocc_id)
|
||||
|
||||
@ -250,16 +245,12 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
def test_change_vnfpkg_failed_with_error_coordinate_vnf(self):
|
||||
create_req = paramgen.change_vnfpkg_create(self.vnfd_id_1)
|
||||
create_req = paramgen.change_vnfpkg_create(self.old_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
expected_inst_attrs = [
|
||||
'id',
|
||||
@ -312,7 +303,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.check_resp_headers_in_get(resp_1)
|
||||
self.check_resp_body(body_1, expected_inst_attrs)
|
||||
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.vnfd_id_3)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg(self.new_volume_vnfd_id)
|
||||
change_vnfpkg_req['additionalParams'][
|
||||
'lcm-operation-coordinate-new-vnf'
|
||||
] = "./Scripts/error_coordinate_new_vnf.py"
|
||||
@ -324,7 +315,7 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
|
||||
resp, body = self.rollback(lcmocc_id)
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.wait_lcmocc_rolled_back(lcmocc_id)
|
||||
|
||||
@ -351,10 +342,6 @@ class ChangeVnfPkgVnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
@ -14,14 +14,12 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
|
||||
def create_coordinate_response(req_header, req_body):
|
||||
def _create_coordinate_response(req_header, req_body):
|
||||
|
||||
resp_body = {
|
||||
'id': 'aeca5328-085c-4cd6-a6f4-c010e9082528',
|
||||
@ -60,38 +58,31 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# main vnf package for StandardUserData test
|
||||
pkg_path_1 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/userdata_standard")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.standard_pkg, cls.standard_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_1, image_path=image_path, userdata_path=userdata_path)
|
||||
|
||||
# for change_vnfpkg test
|
||||
pkg_path_2 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/userdata_standard_change_vnfpkg")
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.new_pkg, cls.new_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_2, image_path=image_path, userdata_path=userdata_path)
|
||||
|
||||
# for change_vnfpkg network/flavor change test
|
||||
pkg_path_3 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/userdata_standard_change_vnfpkg_nw")
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(
|
||||
cls.new_nw_pkg, cls.new_nw_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_3, image_path=image_path, userdata_path=userdata_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(IndividualVnfcMgmtTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.standard_pkg)
|
||||
cls.delete_vnf_package(cls.new_pkg)
|
||||
cls.delete_vnf_package(cls.new_nw_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
def _put_fail_file(self, operation):
|
||||
with open(f'/tmp/{operation}', 'w'):
|
||||
pass
|
||||
|
||||
def _rm_fail_file(self, operation):
|
||||
os.remove(f'/tmp/{operation}')
|
||||
|
||||
def _get_vdu_indexes(self, inst, vdu):
|
||||
return {
|
||||
vnfc['metadata'].get('vdu_idx')
|
||||
@ -159,19 +150,6 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# must exist
|
||||
return vnfc['metadata']['flavor']
|
||||
|
||||
def _delete_instance(self, inst_id):
|
||||
for _ in range(3):
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
if resp.status_code == 204: # OK
|
||||
return
|
||||
elif resp.status_code == 409:
|
||||
# may happen. there is a bit time between lcmocc become
|
||||
# COMPLETED and lock of terminate is freed.
|
||||
time.sleep(3)
|
||||
else:
|
||||
break
|
||||
self.assertTrue(False)
|
||||
|
||||
def test_basic_operations(self):
|
||||
"""Test basic operations using StandardUserData
|
||||
|
||||
@ -202,7 +180,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
subnet_ids = self.get_subnet_ids(['subnet0', 'subnet1'])
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample3_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample3_create(self.standard_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -322,20 +300,20 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self._get_vnfc_cp_net_id(inst_5, 'VDU2', 0, 'VDU2_CP1'))
|
||||
|
||||
# 6. Change_vnfpkg operation
|
||||
change_vnfpkg_req = paramgen.sample4_change_vnfpkg(self.vnfd_id_2,
|
||||
change_vnfpkg_req = paramgen.sample4_change_vnfpkg(self.new_vnfd_id,
|
||||
net_ids, subnet_ids)
|
||||
|
||||
for vdu_param in change_vnfpkg_req['additionalParams']['vdu_params']:
|
||||
vdu_param['new_vnfc_param']['endpoint'] = (
|
||||
f'http://localhost:{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}')
|
||||
f'http://localhost:{self.get_server_port()}')
|
||||
|
||||
# Prepare coordination
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
'/lcmcoord/v1/coordinations',
|
||||
status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
callback=create_coordinate_response
|
||||
callback=_create_coordinate_response
|
||||
)
|
||||
|
||||
with open('/tmp/change_vnfpkg_coordination', 'w'):
|
||||
@ -355,7 +333,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# check vnfdId is changed
|
||||
self.assertEqual(self.vnfd_id_2, inst_6['vnfdId'])
|
||||
self.assertEqual(self.new_vnfd_id, inst_6['vnfdId'])
|
||||
# check images are changed
|
||||
self.assertNotEqual(self._get_vnfc_image(inst_5, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_6, 'VDU1', 0))
|
||||
@ -390,7 +368,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_rollback_operations(self):
|
||||
"""Test rollback operations using StandardUserData
|
||||
@ -421,7 +399,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
subnet_ids = self.get_subnet_ids(['subnet0', 'subnet1'])
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample3_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample3_create(self.standard_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -440,14 +418,14 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# 1. Scale out operation
|
||||
self._put_fail_file('scale_end')
|
||||
self.put_fail_file('scale_end')
|
||||
scale_out_req = paramgen.sample3_scale_out()
|
||||
resp, body = self.scale_vnf_instance(inst_id, scale_out_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('scale_end')
|
||||
self.rm_fail_file('scale_end')
|
||||
|
||||
# Rollback
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -469,14 +447,14 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self._get_vnfc_id(inst_1, 'VDU2', 0))
|
||||
|
||||
# 2. Change_ext_conn operation
|
||||
self._put_fail_file('change_external_connectivity_end')
|
||||
self.put_fail_file('change_external_connectivity_end')
|
||||
change_ext_conn_req = paramgen.sample3_change_ext_conn(net_ids)
|
||||
resp, body = self.change_ext_conn(inst_id, change_ext_conn_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('change_external_connectivity_end')
|
||||
self.rm_fail_file('change_external_connectivity_end')
|
||||
|
||||
# Rollback
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -494,23 +472,23 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self._get_vnfc_cp_net_id(inst_2, 'VDU2', 0, 'VDU2_CP1'))
|
||||
|
||||
# 3. Change_vnfpkg operation
|
||||
self._put_fail_file('change_vnfpkg')
|
||||
self.put_fail_file('change_vnfpkg')
|
||||
with open('/tmp/change_vnfpkg_coordination', 'w'):
|
||||
pass
|
||||
|
||||
change_vnfpkg_req = paramgen.sample4_change_vnfpkg(self.vnfd_id_2,
|
||||
change_vnfpkg_req = paramgen.sample4_change_vnfpkg(self.new_vnfd_id,
|
||||
net_ids, subnet_ids)
|
||||
for vdu_param in change_vnfpkg_req['additionalParams']['vdu_params']:
|
||||
vdu_param['old_vnfc_param']['endpoint'] = (
|
||||
f'http://localhost:{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}')
|
||||
f'http://localhost:{self.get_server_port()}')
|
||||
|
||||
# Prepare coordination
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
'/lcmcoord/v1/coordinations',
|
||||
status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
callback=create_coordinate_response
|
||||
callback=_create_coordinate_response
|
||||
)
|
||||
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
@ -518,7 +496,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('change_vnfpkg')
|
||||
self.rm_fail_file('change_vnfpkg')
|
||||
|
||||
# Rollback
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -532,7 +510,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# check vnfdId is not changed
|
||||
self.assertEqual(self.vnfd_id_1, inst_3['vnfdId'])
|
||||
self.assertEqual(self.standard_vnfd_id, inst_3['vnfdId'])
|
||||
# check images are not changed
|
||||
self.assertEqual(self._get_vnfc_image(inst_2, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_3, 'VDU1', 0))
|
||||
@ -553,7 +531,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_heal_vnfc_after_image_change(self):
|
||||
"""Test heal operation after image change using StandardUserData
|
||||
@ -579,7 +557,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
subnet_ids = self.get_subnet_ids(['subnet0', 'subnet1'])
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample3_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample3_create(self.standard_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -603,7 +581,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual({0}, self._get_vdu_indexes(inst_1, 'VDU2'))
|
||||
|
||||
# 2. Update VNF instance
|
||||
update_req = paramgen.sample3_update_vnf_vnfd_id(self.vnfd_id_2)
|
||||
update_req = paramgen.sample3_update_vnf_vnfd_id(self.new_vnfd_id)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
|
||||
@ -619,7 +597,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual({0}, self._get_vdu_indexes(inst_2, 'VDU2'))
|
||||
|
||||
# check vnfdId is changed
|
||||
self.assertEqual(self.vnfd_id_2, inst_2['vnfdId'])
|
||||
self.assertEqual(self.new_vnfd_id, inst_2['vnfdId'])
|
||||
|
||||
# 3. Heal operation
|
||||
heal_req = paramgen.sample3_heal()
|
||||
@ -661,7 +639,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_change_vnfpkg_nw(self):
|
||||
"""Test change_vnfpkg with additional functions
|
||||
@ -689,7 +667,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
subnet_ids = self.get_subnet_ids(['subnet0', 'subnet1'])
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample3_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample3_create(self.standard_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -713,7 +691,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual({0}, self._get_vdu_indexes(inst_1, 'VDU2'))
|
||||
|
||||
# 2. Change_vnfpkg operation
|
||||
change_vnfpkg_req = paramgen.sample5_change_vnfpkg(self.vnfd_id_3,
|
||||
change_vnfpkg_req = paramgen.sample5_change_vnfpkg(self.new_nw_vnfd_id,
|
||||
net_ids, subnet_ids)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
@ -726,7 +704,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# check vnfdId is changed
|
||||
self.assertEqual(self.vnfd_id_3, inst_2['vnfdId'])
|
||||
self.assertEqual(self.new_nw_vnfd_id, inst_2['vnfdId'])
|
||||
# check images are changed
|
||||
self.assertNotEqual(self._get_vnfc_image(inst_1, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_2, 'VDU1', 0))
|
||||
@ -773,7 +751,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_change_vnfpkg_nw_rollback(self):
|
||||
"""Test rollback of change_vnfpkg with additional functions
|
||||
@ -803,7 +781,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
subnet_ids = self.get_subnet_ids(['subnet0', 'subnet1'])
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample3_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample3_create(self.standard_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -827,15 +805,15 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual({0}, self._get_vdu_indexes(inst_1, 'VDU2'))
|
||||
|
||||
# 2. Change_vnfpkg operation
|
||||
self._put_fail_file('change_vnfpkg')
|
||||
change_vnfpkg_req = paramgen.sample5_change_vnfpkg(self.vnfd_id_3,
|
||||
self.put_fail_file('change_vnfpkg')
|
||||
change_vnfpkg_req = paramgen.sample5_change_vnfpkg(self.new_nw_vnfd_id,
|
||||
net_ids, subnet_ids)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnfpkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('change_vnfpkg')
|
||||
self.rm_fail_file('change_vnfpkg')
|
||||
|
||||
# Rollback
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -847,7 +825,7 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(200, resp.status_code)
|
||||
|
||||
# check vnfdId is not changed
|
||||
self.assertEqual(self.vnfd_id_1, inst_2['vnfdId'])
|
||||
self.assertEqual(self.standard_vnfd_id, inst_2['vnfdId'])
|
||||
# check images are not changed
|
||||
self.assertEqual(self._get_vnfc_image(inst_1, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_2, 'VDU1', 0))
|
||||
@ -882,4 +860,4 @@ class IndividualVnfcMgmtTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
@ -98,8 +98,8 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 4-5. Send alert and auto heal
|
||||
affected_vnfcs = body['resourceChanges']['affectedVnfcs']
|
||||
vnfc_info_id = (affected_vnfcs[0]['vduId'] + '-'
|
||||
+ affected_vnfcs[0]['id'])
|
||||
vnfc_info_id = (f"{affected_vnfcs[0]['vduId']}-"
|
||||
f"{affected_vnfcs[0]['id']}")
|
||||
alert = paramgen.prometheus_auto_healing_alert(inst_id, vnfc_info_id)
|
||||
resp, body = self.prometheus_auto_healing_alert(alert)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
@ -137,8 +137,8 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
if vnfc['changeType'] == 'REMOVED']
|
||||
self.assertEqual(1, len(removed_vnfcs))
|
||||
|
||||
removed_vnfc_info_id = (affected_vnfcs[0]['vduId'] + '-'
|
||||
+ affected_vnfcs[0]['id'])
|
||||
removed_vnfc_info_id = (f"{affected_vnfcs[0]['vduId']}-"
|
||||
f"{affected_vnfcs[0]['id']}")
|
||||
self.assertEqual(vnfc_info_id, removed_vnfc_info_id)
|
||||
|
||||
# 7. Send alert
|
||||
@ -193,8 +193,8 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(2, len(removed_vnfcs))
|
||||
|
||||
removed_vnfc_info_ids = [
|
||||
removed_vnfcs[0]['vduId'] + '-' + removed_vnfcs[0]['id'],
|
||||
removed_vnfcs[1]['vduId'] + '-' + removed_vnfcs[1]['id']
|
||||
f"{removed_vnfcs[0]['vduId']}-{removed_vnfcs[0]['id']}",
|
||||
f"{removed_vnfcs[1]['vduId']}-{removed_vnfcs[1]['id']}"
|
||||
]
|
||||
self.assertCountEqual(
|
||||
[vnfc_info_id_1, vnfc_info_id_2], removed_vnfc_info_ids)
|
||||
@ -207,10 +207,6 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# 12. Show OpOcc
|
||||
resp, body = self.show_lcmocc(lcmocc_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -218,7 +214,7 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual('TERMINATE', body['operation'])
|
||||
|
||||
# 13. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
@ -342,10 +338,6 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# 11. Show OpOcc
|
||||
resp, body = self.show_lcmocc(lcmocc_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -353,7 +345,7 @@ class PromAutoScaleHealTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual('TERMINATE', body['operation'])
|
||||
|
||||
# 12. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
||||
# check deletion of VNF instance
|
||||
|
@ -18,18 +18,19 @@ import os
|
||||
import time
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
test_count = 0
|
||||
TEST_COUNT = 0
|
||||
RETRY_LIMIT = 10
|
||||
RETRY_TIMEOUT = 3
|
||||
WAIT_AUTO_HEAL_TIME = 60
|
||||
SERVER_NOTIFICATION_INTERVAL = 1
|
||||
|
||||
|
||||
def make_alarm_id(header, body):
|
||||
def _make_alarm_id(header, body):
|
||||
from tacker.tests.functional.sol_v2 import test_server_notification
|
||||
id = 'alarm_id_' + str(test_server_notification.test_count)
|
||||
id = f"alarm_id_{test_server_notification.TEST_COUNT}"
|
||||
return {'alarm_id': id}
|
||||
|
||||
|
||||
@ -49,21 +50,22 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# for basic lcms tests max pattern
|
||||
basic_lcms_max_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/basic_lcms_max")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.max_pkg, cls.max_vnfd_id = cls.create_vnf_package(
|
||||
basic_lcms_max_path, image_path=image_path)
|
||||
|
||||
# for basic lcms tests min pattern
|
||||
basic_lcms_min_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/basic_lcms_min")
|
||||
# no image contained
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.min_pkg, cls.min_vnfd_id = cls.create_vnf_package(
|
||||
basic_lcms_min_path)
|
||||
|
||||
# for update vnf test
|
||||
update_vnf_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/update_vnf")
|
||||
# no image contained
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(update_vnf_path)
|
||||
cls.upd_pkg, cls.upd_vnfd_id = cls.create_vnf_package(
|
||||
update_vnf_path)
|
||||
|
||||
# for server_notification test
|
||||
server_notification_path = os.path.join(
|
||||
@ -75,19 +77,14 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(ServerNotificationTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.max_pkg)
|
||||
cls.delete_vnf_package(cls.min_pkg)
|
||||
cls.delete_vnf_package(cls.upd_pkg)
|
||||
cls.delete_vnf_package(cls.svn_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
def _check_package_usage(self, is_nfvo, package_id, state='NOT_IN_USE'):
|
||||
if not is_nfvo:
|
||||
usage_state = self.get_vnf_package(package_id)['usageState']
|
||||
self.assertEqual(state, usage_state)
|
||||
|
||||
def fault_notification_queueing_test(self):
|
||||
"""Test Fault Notification with queueing
|
||||
|
||||
@ -152,21 +149,21 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
create_req = paramgen.create_vnf_min(self.svn_id)
|
||||
|
||||
# Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
server_notification_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
'/server_notification')
|
||||
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
'/server_notification',
|
||||
status_code=200,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
callback=make_alarm_id
|
||||
callback=_make_alarm_id
|
||||
)
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -197,7 +194,7 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.svn_pkg, 'IN_USE')
|
||||
self.check_package_usage(self.svn_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -262,11 +259,11 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
resp, body = self.server_notification(
|
||||
inst_id, 'server_id', fault_notification_param)
|
||||
self.assertTrue(resp.status_code == 204 or resp.status_code == 404)
|
||||
time.sleep(1)
|
||||
time.sleep(SERVER_NOTIFICATION_INTERVAL)
|
||||
|
||||
if is_autoheal_enabled:
|
||||
# waiting for auto healing process complete after packing timer.
|
||||
time.sleep(60)
|
||||
time.sleep(WAIT_AUTO_HEAL_TIME)
|
||||
|
||||
# 4. LCM-Heal
|
||||
nested_stacks = self.heat_client.get_resources(stack_name)
|
||||
@ -326,8 +323,8 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(is_nfvo, self.svn_pkg, 'IN_USE')
|
||||
# check usageState of server notification VNF Package
|
||||
self.check_package_usage(self.svn_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
self.assertEqual(self.svn_id, body['vnfdId'])
|
||||
|
||||
@ -442,10 +439,6 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(20)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
self.assertIsNone(stack_status)
|
||||
@ -457,7 +450,7 @@ class ServerNotificationTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 8. LCM-Delete
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -15,10 +15,8 @@
|
||||
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
@ -40,28 +38,28 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# for basic lcms tests max pattern
|
||||
basic_lcms_max_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/basic_lcms_max")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.max_pkg, cls.max_vnfd_id = cls.create_vnf_package(
|
||||
basic_lcms_max_path, image_path=image_path)
|
||||
|
||||
# for basic lcms tests min pattern
|
||||
basic_lcms_min_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/basic_lcms_min")
|
||||
# no image contained
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.min_pkg, cls.min_vnfd_id = cls.create_vnf_package(
|
||||
basic_lcms_min_path)
|
||||
|
||||
# for update vnf test
|
||||
update_vnf_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/update_vnf")
|
||||
# no image contained
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(update_vnf_path)
|
||||
cls.upd_pkg, cls.upd_vnfd_id = cls.create_vnf_package(update_vnf_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.max_pkg)
|
||||
cls.delete_vnf_package(cls.min_pkg)
|
||||
cls.delete_vnf_package(cls.upd_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@ -75,8 +73,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
- 2. Show VNFLCM API versions
|
||||
"""
|
||||
path = "/vnflcm/api_versions"
|
||||
resp, body = self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
expected_body = {
|
||||
@ -89,8 +86,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(body, expected_body)
|
||||
|
||||
path = "/vnflcm/v2/api_versions"
|
||||
resp, body = self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.check_resp_headers_in_get(resp)
|
||||
expected_body = {
|
||||
@ -129,10 +125,10 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
"""
|
||||
|
||||
# 0. Pre-setting
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -236,10 +232,10 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -269,7 +265,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -313,16 +309,14 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 5. Update VNF
|
||||
# check attribute value before update VNF
|
||||
# check usageState of VNF Package 1
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check vnfd id
|
||||
self.assertEqual(self.vnfd_id_1, body['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, body['vnfdId'])
|
||||
|
||||
# check vnfc info
|
||||
vnfc_info = body['instantiatedVnfInfo']['vnfcInfo']
|
||||
@ -334,7 +328,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertIsNotNone(vnfc.get('vnfcState'))
|
||||
self.assertIsNone(vnfc.get('vnfcConfigurableProperties'))
|
||||
|
||||
update_req = paramgen.update_vnf_max(self.vnfd_id_3, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(self.upd_vnfd_id, vnfc_ids)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -357,16 +351,14 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 1
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
# check usageState of update pattern VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE')
|
||||
|
||||
# check the specified attribute after update VNF
|
||||
self.assertEqual(self.vnfd_id_3, body['vnfdId'])
|
||||
self.assertEqual(self.upd_vnfd_id, body['vnfdId'])
|
||||
self.assertEqual('new name', body['vnfInstanceName'])
|
||||
self.assertEqual('new description', body['vnfInstanceDescription'])
|
||||
dummy_key_value = {'dummy-key': 'dummy-value'}
|
||||
@ -421,10 +413,6 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -432,7 +420,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 9. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -502,10 +490,10 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -535,7 +523,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -543,8 +531,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -588,18 +575,16 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
|
||||
# 5. Update VNF
|
||||
# check attribute value before update VNF
|
||||
# check usageState of VNF Package 1
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check vnfd id
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(self.vnfd_id_1, body['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, body['vnfdId'])
|
||||
|
||||
# check vnfc info
|
||||
vnfc_info = body['instantiatedVnfInfo']['vnfcInfo']
|
||||
@ -611,7 +596,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertIsNotNone(vnfc.get('vnfcState'))
|
||||
self.assertIsNone(vnfc.get('vnfcConfigurableProperties'))
|
||||
|
||||
update_req = paramgen.update_vnf_max(self.vnfd_id_3, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(self.upd_vnfd_id, vnfc_ids)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -634,16 +619,14 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 1
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'NOT_IN_USE')
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE')
|
||||
|
||||
# check the specified attribute after update VNF
|
||||
self.assertEqual(self.vnfd_id_3, body['vnfdId'])
|
||||
self.assertEqual(self.upd_vnfd_id, body['vnfdId'])
|
||||
self.assertEqual('new name', body['vnfInstanceName'])
|
||||
self.assertEqual('new description', body['vnfInstanceDescription'])
|
||||
dummy_key_value = {'dummy-key': 'dummy-value'}
|
||||
@ -823,10 +806,6 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -834,7 +813,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 11. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -905,10 +884,10 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -938,7 +917,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -946,8 +925,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -1097,10 +1075,6 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
self.assertIsNone(stack_status)
|
||||
@ -1112,7 +1086,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 12. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -1125,7 +1099,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
"""Test the sequence of scale out/in and the other LCM operations
|
||||
|
||||
The change_ext_conn can't be tested in test_basic_lcms_min method
|
||||
because VNF package 2 don't have external connectivity.
|
||||
because min pattern VNF package don't have external connectivity.
|
||||
So moved it here to test min pattern change_ext_conn.
|
||||
|
||||
* About attributes:
|
||||
@ -1212,10 +1186,10 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -1245,7 +1219,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -1253,8 +1227,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_1)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -1585,10 +1558,6 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
self.assertIsNone(stack_status)
|
||||
@ -1600,7 +1569,7 @@ class VnfLcmTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 17. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
|
@ -15,10 +15,8 @@
|
||||
|
||||
import ddt
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
|
||||
@ -41,14 +39,14 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# Scale operation will fail
|
||||
scale_ng_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/scale_ng")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.scale_ng_pkg, cls.scale_ng_vnfd_id = cls.create_vnf_package(
|
||||
scale_ng_path, image_path=image_path)
|
||||
|
||||
# Instantiate VNF will fail
|
||||
error_network_path = os.path.join(cur_dir, "../sol_v2_common/"
|
||||
"samples/error_network")
|
||||
# no image contained
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.err_nw_pkg, cls.err_nw_vnfd_id = cls.create_vnf_package(
|
||||
error_network_path)
|
||||
|
||||
# update VNF or change external VNF connectivity will fail
|
||||
@ -56,16 +54,16 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
"../sol_v2_common/"
|
||||
"samples/basic_lcms_min")
|
||||
# no image contained
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(
|
||||
cls.min_pkg, cls.min_vnfd_id = cls.create_vnf_package(
|
||||
update_change_ng_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(VnfLcmErrorHandlingTest, cls).tearDownClass()
|
||||
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.scale_ng_pkg)
|
||||
cls.delete_vnf_package(cls.err_nw_pkg)
|
||||
cls.delete_vnf_package(cls.min_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@ -97,10 +95,10 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
"""
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -112,8 +110,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.err_nw_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -134,7 +131,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
create_req = paramgen.create_vnf_min(self.err_nw_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -142,8 +139,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.err_nw_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -159,8 +155,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.err_nw_pkg, 'IN_USE')
|
||||
|
||||
# 5. Show VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -240,8 +235,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_2)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.err_nw_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 10. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
@ -277,10 +271,10 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
"""
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -292,8 +286,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -314,7 +307,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_3)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -322,8 +315,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -339,8 +331,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# 5. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -425,13 +416,8 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -440,13 +426,12 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 11. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 12. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
@ -505,10 +490,10 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
'ft-ipv6-subnet1'])
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -520,8 +505,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -542,7 +526,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# 'extensions', # omitted
|
||||
'_links'
|
||||
]
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_3)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
self.check_resp_headers_in_create(resp)
|
||||
@ -550,8 +534,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -567,8 +550,7 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# 5. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -652,13 +634,8 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -667,13 +644,12 @@ class VnfLcmErrorHandlingTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
body['instantiationState'])
|
||||
|
||||
# 11. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
# check usageState of VNF Package
|
||||
usage_state = self.get_vnf_package(self.vnf_pkg_3)['usageState']
|
||||
self.assertEqual('NOT_IN_USE', usage_state)
|
||||
self.check_package_usage(self.min_pkg, 'NOT_IN_USE')
|
||||
|
||||
# 12. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
from tacker.tests.functional.sol_v2_common import test_vnflcm_basic_common
|
||||
@ -44,13 +43,13 @@ class AzRetryTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
# for update_stack_retry test
|
||||
pkg_path_1 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/userdata_standard_az_retry")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.az_retry_pkg, cls.az_retry_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_1, image_path=image_path, userdata_path=userdata_path)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(AzRetryTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.az_retry_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@ -72,19 +71,6 @@ class AzRetryTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
vnfc = self._get_vnfc_by_vdu_index(inst, vdu, index)
|
||||
return vnfc['metadata'].get('zone')
|
||||
|
||||
def _delete_instance(self, inst_id):
|
||||
for _ in range(3):
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
if resp.status_code == 204: # OK
|
||||
return
|
||||
elif resp.status_code == 409:
|
||||
# may happen. there is a bit time between lcmocc become
|
||||
# COMPLETED and lock of terminate is freed.
|
||||
time.sleep(3)
|
||||
else:
|
||||
break
|
||||
self.assertTrue(False)
|
||||
|
||||
def test_update_stack_retry(self):
|
||||
"""Test _update_stack_retry function using StandardUserData
|
||||
|
||||
@ -117,7 +103,7 @@ class AzRetryTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
MAX_SCALE_COUNT = 4
|
||||
|
||||
# Create VNF instance
|
||||
create_req = paramgen.sample6_create(self.vnfd_id_1)
|
||||
create_req = paramgen.sample6_create(self.az_retry_vnfd_id)
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
self.assertEqual(201, resp.status_code)
|
||||
inst_id = body['id']
|
||||
@ -177,4 +163,5 @@ class AzRetryTest(test_vnflcm_basic_common.CommonVnfLcmTest):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# Delete VNF instance
|
||||
self._delete_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
|
@ -13,176 +13,48 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import urllib
|
||||
import yaml
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
from tempest.lib import base
|
||||
|
||||
from tacker.common import utils as common_utils
|
||||
from tacker.sol_refactored.common import http_client
|
||||
from tacker.sol_refactored.infra_drivers.openstack import heat_utils
|
||||
from tacker.sol_refactored.nfvo import glance_utils
|
||||
from tacker.sol_refactored import objects
|
||||
from tacker.tests.functional.common.fake_server import FakeServerManager
|
||||
from tacker.tests.functional.sol_v2_common import utils
|
||||
from tacker.tests import utils as base_utils
|
||||
from tacker import version
|
||||
from tacker.tests.functional import base_v2
|
||||
|
||||
FAKE_SERVER_MANAGER = FakeServerManager()
|
||||
MOCK_NOTIFY_CALLBACK_URL = '/notification/callback'
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
VNF_PACKAGE_UPLOAD_TIMEOUT = 300
|
||||
VNFLCM_V2_VERSION = "2.0.0"
|
||||
|
||||
|
||||
class BaseSolV2Test(base.BaseTestCase):
|
||||
class BaseSolV2Test(base_v2.BaseTackerTestV2):
|
||||
"""Base test case class for SOL v2 functional tests."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(BaseSolV2Test, cls).setUpClass()
|
||||
|
||||
FAKE_SERVER_MANAGER.prepare_http_server()
|
||||
if getattr(cls, 'is_https', False):
|
||||
FAKE_SERVER_MANAGER.set_https_server()
|
||||
FAKE_SERVER_MANAGER.start_server()
|
||||
|
||||
cfg.CONF(args=['--config-file', '/etc/tacker/tacker.conf'],
|
||||
project='tacker',
|
||||
version='%%prog %s' % version.version_info.release_string())
|
||||
objects.register_all()
|
||||
|
||||
vim_info = cls.get_vim_info()
|
||||
cls.auth_url = vim_info.interfaceInfo['endpoint']
|
||||
|
||||
auth = http_client.KeystonePasswordAuthHandle(
|
||||
auth_url=vim_info.interfaceInfo['endpoint'],
|
||||
username=vim_info.accessInfo['username'],
|
||||
password=vim_info.accessInfo['password'],
|
||||
project_name=vim_info.accessInfo['project'],
|
||||
user_domain_name=vim_info.accessInfo['userDomain'],
|
||||
project_domain_name=vim_info.accessInfo['projectDomain']
|
||||
)
|
||||
cls.tacker_client = http_client.HttpClient(auth)
|
||||
cls.neutron_client = http_client.HttpClient(auth,
|
||||
cls.neutron_client = http_client.HttpClient(cls.auth_handle,
|
||||
service_type='network')
|
||||
cls.glance_client = http_client.HttpClient(auth,
|
||||
cls.glance_client = http_client.HttpClient(cls.auth_handle,
|
||||
service_type='image')
|
||||
cls.nova_client = http_client.HttpClient(auth,
|
||||
cls.nova_client = http_client.HttpClient(cls.auth_handle,
|
||||
service_type='compute')
|
||||
cls.heat_client = heat_utils.HeatClient(vim_info)
|
||||
|
||||
cls.cinder_client = http_client.HttpClient(
|
||||
auth, service_type='block-storage')
|
||||
cls.auth_handle, service_type='block-storage')
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(BaseSolV2Test, cls).tearDownClass()
|
||||
FAKE_SERVER_MANAGER.stop_server()
|
||||
|
||||
@classmethod
|
||||
def get_vim_info(cls):
|
||||
vim_params = yaml.safe_load(base_utils.read_file('local-vim.yaml'))
|
||||
vim_params['auth_url'] += '/v3'
|
||||
|
||||
vim_info = objects.VimConnectionInfo(
|
||||
interfaceInfo={'endpoint': vim_params['auth_url']},
|
||||
accessInfo={
|
||||
'region': 'RegionOne',
|
||||
'project': vim_params['project_name'],
|
||||
'username': vim_params['username'],
|
||||
'password': vim_params['password'],
|
||||
'userDomain': vim_params['user_domain_name'],
|
||||
'projectDomain': vim_params['project_domain_name']
|
||||
}
|
||||
)
|
||||
|
||||
return vim_info
|
||||
|
||||
@classmethod
|
||||
def create_vnf_package(cls, sample_path, user_data={},
|
||||
image_path=None, nfvo=False, userdata_path=None,
|
||||
provider=None):
|
||||
vnfd_id = uuidutils.generate_uuid()
|
||||
tmp_dir = tempfile.mkdtemp()
|
||||
|
||||
utils.make_zip(sample_path, tmp_dir, vnfd_id, image_path,
|
||||
userdata_path, provider)
|
||||
|
||||
zip_file_name = os.path.basename(os.path.abspath(sample_path)) + ".zip"
|
||||
zip_file_path = os.path.join(tmp_dir, zip_file_name)
|
||||
|
||||
if nfvo:
|
||||
return zip_file_path, vnfd_id
|
||||
|
||||
else:
|
||||
path = "/vnfpkgm/v1/vnf_packages"
|
||||
req_body = {'userDefinedData': user_data}
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "POST", expected_status=[201], body=req_body)
|
||||
|
||||
pkg_id = body['id']
|
||||
|
||||
with open(zip_file_path, 'rb') as fp:
|
||||
path = "/vnfpkgm/v1/vnf_packages/{}/package_content".format(
|
||||
pkg_id)
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "PUT", body=fp, content_type='application/zip',
|
||||
expected_status=[202])
|
||||
|
||||
# wait for onboard
|
||||
timeout = VNF_PACKAGE_UPLOAD_TIMEOUT
|
||||
start_time = int(time.time())
|
||||
path = "/vnfpkgm/v1/vnf_packages/{}".format(pkg_id)
|
||||
while True:
|
||||
resp, body = cls.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200])
|
||||
if body['onboardingState'] == "ONBOARDED":
|
||||
break
|
||||
|
||||
if ((int(time.time()) - start_time) > timeout):
|
||||
raise Exception("Failed to onboard vnf package")
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
shutil.rmtree(tmp_dir)
|
||||
|
||||
return pkg_id, vnfd_id
|
||||
|
||||
@classmethod
|
||||
def delete_vnf_package(cls, pkg_id):
|
||||
path = "/vnfpkgm/v1/vnf_packages/{}".format(pkg_id)
|
||||
req_body = {"operationalState": "DISABLED"}
|
||||
resp, _ = cls.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body)
|
||||
if resp.status_code != 200:
|
||||
LOG.error("failed to set operationalState to DISABLED")
|
||||
return
|
||||
|
||||
cls.tacker_client.do_request(path, "DELETE")
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
callback_url = os.path.join(
|
||||
MOCK_NOTIFY_CALLBACK_URL,
|
||||
self._testMethodName)
|
||||
FAKE_SERVER_MANAGER.clear_history(callback_url)
|
||||
FAKE_SERVER_MANAGER.set_callback('POST', callback_url, status_code=204)
|
||||
FAKE_SERVER_MANAGER.set_callback('GET', callback_url, status_code=204)
|
||||
|
||||
def get_vnf_package(self, pkg_id):
|
||||
path = "/vnfpkgm/v1/vnf_packages/{}".format(pkg_id)
|
||||
resp, body = self.tacker_client.do_request(path, "GET")
|
||||
return body
|
||||
return super().create_vnf_package(sample_path, user_data=user_data,
|
||||
image_path=image_path, nfvo=nfvo,
|
||||
userdata_path=userdata_path,
|
||||
provider=provider)
|
||||
|
||||
def get_network_ids(self, networks):
|
||||
path = "/v2.0/networks"
|
||||
@ -359,227 +231,15 @@ class BaseSolV2Test(base.BaseTestCase):
|
||||
for image_id in image_ids:
|
||||
glance_client.delete_image(image_id)
|
||||
|
||||
def create_vnf_instance(self, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def delete_vnf_instance(self, inst_id):
|
||||
path = "/vnflcm/v2/vnf_instances/{}".format(inst_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.0.0")
|
||||
|
||||
def show_vnf_instance(self, inst_id):
|
||||
path = "/vnflcm/v2/vnf_instances/{}".format(inst_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def list_vnf_instance(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/vnf_instances"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def instantiate_vnf_instance(self, inst_id, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances/{}/instantiate".format(inst_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def scale_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/scale"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def update_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}"
|
||||
return self.tacker_client.do_request(
|
||||
path, "PATCH", body=req_body, version="2.0.0")
|
||||
|
||||
def heal_vnf_instance(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/heal"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
path, "PATCH", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def change_ext_conn(self, inst_id, req_body):
|
||||
path = f"/vnflcm/v2/vnf_instances/{inst_id}/change_ext_conn"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def change_vnfpkg(self, inst_id, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances/{}/change_vnfpkg".format(inst_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def terminate_vnf_instance(self, inst_id, req_body):
|
||||
path = "/vnflcm/v2/vnf_instances/{}/terminate".format(inst_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def rollback(self, lcmocc_id):
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs/{}/rollback".format(lcmocc_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def wait_lcmocc_complete(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs/{}".format(lcmocc_id)
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'COMPLETED':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
else: # FAILED_TEMP or ROLLED_BACK
|
||||
raise Exception("Operation failed. state: %s" % state)
|
||||
|
||||
def wait_lcmocc_failed_temp(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs/{}".format(lcmocc_id)
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'FAILED_TEMP':
|
||||
return
|
||||
elif state in ['STARTING', 'PROCESSING']:
|
||||
continue
|
||||
elif state == 'COMPLETED':
|
||||
raise Exception("Operation unexpected COMPLETED.")
|
||||
else: # ROLLED_BACK
|
||||
raise Exception("Operation failed. state: %s" % state)
|
||||
|
||||
def wait_lcmocc_rolled_back(self, lcmocc_id):
|
||||
# NOTE: It is not necessary to set timeout because the operation
|
||||
# itself set timeout and the state will become 'FAILED_TEMP'.
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}"
|
||||
while True:
|
||||
time.sleep(5)
|
||||
_, body = self.tacker_client.do_request(
|
||||
path, "GET", expected_status=[200], version="2.0.0")
|
||||
state = body['operationState']
|
||||
if state == 'ROLLED_BACK':
|
||||
return
|
||||
if state in ['ROLLING_BACK']:
|
||||
continue
|
||||
|
||||
raise Exception(f"Operation failed. state: {state}")
|
||||
|
||||
def show_lcmocc(self, lcmocc_id):
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs/{}".format(lcmocc_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def list_lcmocc(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/vnf_lcm_op_occs"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def rollback_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/rollback"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def retry_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/retry"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def fail_lcmocc(self, lcmocc_id):
|
||||
path = f"/vnflcm/v2/vnf_lcm_op_occs/{lcmocc_id}/fail"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", version="2.0.0")
|
||||
|
||||
def prometheus_auto_healing_alert(self, req_body):
|
||||
path = "/alert/auto_healing"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def prometheus_auto_scaling_alert(self, req_body):
|
||||
path = "/alert/auto_scaling"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body)
|
||||
|
||||
def create_subscription(self, req_body):
|
||||
path = "/vnflcm/v2/subscriptions"
|
||||
return self.tacker_client.do_request(
|
||||
path, "POST", body=req_body, version="2.0.0")
|
||||
|
||||
def delete_subscription(self, sub_id):
|
||||
path = "/vnflcm/v2/subscriptions/{}".format(sub_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "DELETE", version="2.0.0")
|
||||
|
||||
def show_subscription(self, sub_id):
|
||||
path = "/vnflcm/v2/subscriptions/{}".format(sub_id)
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def list_subscriptions(self, filter_expr=None):
|
||||
path = "/vnflcm/v2/subscriptions"
|
||||
if filter_expr:
|
||||
path = "{}?{}".format(path, urllib.parse.urlencode(filter_expr))
|
||||
return self.tacker_client.do_request(
|
||||
path, "GET", version="2.0.0")
|
||||
|
||||
def _check_resp_headers(self, resp, supported_headers):
|
||||
unsupported_headers = ['Retry-After',
|
||||
'Content-Range', 'WWW-Authenticate']
|
||||
for s in supported_headers:
|
||||
if s not in resp.headers:
|
||||
raise Exception("Supported header doesn't exist: %s" % s)
|
||||
for u in unsupported_headers:
|
||||
if u in resp.headers:
|
||||
raise Exception("Unsupported header exist: %s" % u)
|
||||
|
||||
def check_resp_headers_in_create(self, resp):
|
||||
# includes location header and response body
|
||||
supported_headers = ['Version', 'Location', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_operation_task(self, resp):
|
||||
# includes location header and no response body
|
||||
supported_headers = ['Version', 'Location']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_get(self, resp):
|
||||
# includes a single data in response body and no location header
|
||||
supported_headers = ['Version', 'Content-Type',
|
||||
'Accept-Ranges']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_index(self, resp):
|
||||
# includes some data in response body and no location header
|
||||
supported_headers = ['Version', 'Content-Type',
|
||||
'Accept-Ranges', 'Link']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_headers_in_delete(self, resp):
|
||||
# no location header and response body
|
||||
supported_headers = ['Version']
|
||||
self._check_resp_headers(resp, supported_headers)
|
||||
|
||||
def check_resp_body(self, body, expected_attrs):
|
||||
for attr in expected_attrs:
|
||||
if attr not in body:
|
||||
raise Exception("Expected attribute doesn't exist: %s" % attr)
|
||||
|
||||
def assert_notification_get(self, callback_url):
|
||||
notify_mock_responses = FAKE_SERVER_MANAGER.get_history(
|
||||
callback_url)
|
||||
FAKE_SERVER_MANAGER.clear_history(
|
||||
callback_url)
|
||||
self.assertEqual(1, len(notify_mock_responses))
|
||||
self.assertEqual(204, notify_mock_responses[0].status_code)
|
||||
path, "POST", body=req_body, version=VNFLCM_V2_VERSION)
|
||||
|
||||
def get_current_vdu_image(
|
||||
self, stack_id, stack_name, resource_name):
|
||||
|
@ -22,6 +22,8 @@ from tacker.tests.functional.sol_separated_nfvo_v2 import fake_vnfpkgm_v2
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
from tacker.tests.functional.sol_v2_common import paramgen
|
||||
|
||||
WAIT_LCMOCC_UPDATE_TIME = 10
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
@ -45,7 +47,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
Response: VNF Package information
|
||||
"""
|
||||
# Set Token
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST', fake_grant_v2.GrantV2.TOKEN,
|
||||
status_code=200,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
@ -53,7 +55,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
)
|
||||
|
||||
# Set "VNF Package content" response
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'GET',
|
||||
os.path.join(
|
||||
'/vnfpkgm/v2/onboarded_vnf_packages',
|
||||
@ -64,7 +66,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
)
|
||||
|
||||
# Set "Individual VNF package" response
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'GET',
|
||||
os.path.join(
|
||||
'/vnfpkgm/v2/onboarded_vnf_packages',
|
||||
@ -76,7 +78,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
)
|
||||
|
||||
# Set "VNFD of individual VNF package" response
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'GET',
|
||||
os.path.join(
|
||||
'/vnfpkgm/v2/onboarded_vnf_packages',
|
||||
@ -86,17 +88,12 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
content=package_path
|
||||
)
|
||||
|
||||
def _check_package_usage(self, is_nfvo, package_id, state='NOT_IN_USE'):
|
||||
if not is_nfvo:
|
||||
usage_state = self.get_vnf_package(package_id)['usageState']
|
||||
self.assertEqual(state, usage_state)
|
||||
|
||||
def _set_grant_response(self, is_nfvo, operation, glance_image=None,
|
||||
flavour_vdu_dict=None, zone_name_list=None):
|
||||
if is_nfvo:
|
||||
if operation == 'INSTANTIATE':
|
||||
# Set Fake server response for Grant-Req(Instantiate)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST', fake_grant_v2.GrantV2.GRANT_REQ_PATH,
|
||||
status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
@ -106,7 +103,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
zone_name_list))
|
||||
elif operation == 'TERMINATE':
|
||||
# Set Fake server response for Grant-Req(Terminate)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
fake_grant_v2.GrantV2.GRANT_REQ_PATH,
|
||||
status_code=201,
|
||||
@ -116,7 +113,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
req_body))
|
||||
elif operation == 'SCALE':
|
||||
# Set Fake server response for Grant-Req(Scale)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
fake_grant_v2.GrantV2.GRANT_REQ_PATH, status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
@ -126,7 +123,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
flavour_vdu_dict, zone_name_list))
|
||||
elif operation == 'HEAL':
|
||||
# Set Fake server response for Grant-Req(Heal)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
fake_grant_v2.GrantV2.GRANT_REQ_PATH, status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
@ -136,7 +133,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
flavour_vdu_dict, zone_name_list))
|
||||
elif operation == 'CHANGE_EXT_CONN':
|
||||
# Set Fake server response for Grant-Req(change_ext_conn)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
fake_grant_v2.GrantV2.GRANT_REQ_PATH, status_code=201,
|
||||
response_headers={"Content-Type": "application/json"},
|
||||
@ -145,7 +142,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
req_body, zone_name_list))
|
||||
elif operation == 'CHANGE_VNFPKG':
|
||||
# Set Fake server response for Grant-Req(Change_vnfpkg)
|
||||
base_v2.FAKE_SERVER_MANAGER.set_callback(
|
||||
self.set_server_callback(
|
||||
'POST',
|
||||
fake_grant_v2.GrantV2.GRANT_REQ_PATH,
|
||||
status_code=201,
|
||||
@ -218,15 +215,15 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
update_vnf_path = os.path.join(
|
||||
cur_dir, "samples/update_vnf")
|
||||
vnfd_path = "contents/Definitions/v2_sample1_df_simple.yaml"
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
max_zip_path, max_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_max_path, image_path=image_path, nfvo=True)
|
||||
zip_path_file_2, vnfd_id_2 = self.create_vnf_package(
|
||||
upd_zip_path, upd_vnfd_id = self.create_vnf_package(
|
||||
update_vnf_path, nfvo=True)
|
||||
|
||||
self._register_vnf_package_mock_response(vnfd_id_1,
|
||||
zip_path_file_1)
|
||||
self._register_vnf_package_mock_response(vnfd_id_2,
|
||||
zip_path_file_2)
|
||||
self._register_vnf_package_mock_response(max_vnfd_id,
|
||||
max_zip_path)
|
||||
self._register_vnf_package_mock_response(upd_vnfd_id,
|
||||
upd_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_max_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
@ -234,14 +231,14 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
zone_name_list = self.get_zone_list()
|
||||
sw_data = fake_grant_v2.GrantV2.get_sw_data(
|
||||
basic_lcms_max_path, vnfd_path)
|
||||
create_req = paramgen.create_vnf_max(vnfd_id_1)
|
||||
self.vnf_pkg_1 = None
|
||||
self.vnf_pkg_3 = None
|
||||
create_req = paramgen.create_vnf_max(max_vnfd_id)
|
||||
self.max_pkg = None
|
||||
self.upd_pkg = None
|
||||
else:
|
||||
glance_image = None
|
||||
flavour_vdu_dict = None
|
||||
zone_name_list = None
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
# Create a new network and subnet to check the IP allocation of
|
||||
# IPv4 and IPv6
|
||||
ft_net0_name = 'ft-net0'
|
||||
@ -295,10 +292,10 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -311,7 +308,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assert_notification_get(callback_url)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1)
|
||||
self.check_package_usage(self.max_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 3. Show subscription
|
||||
expected_attrs = [
|
||||
@ -360,7 +357,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -377,7 +374,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
image_path, sw_data, inst_id, num_vdu=2)
|
||||
glance_image['VDU1-VirtualStorage'] = image_1_id
|
||||
glance_image['VDU2-VirtualStorage'] = image_2_id
|
||||
time.sleep(10)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
self._set_grant_response(
|
||||
is_nfvo, 'INSTANTIATE', glance_image=glance_image,
|
||||
@ -781,7 +778,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check stack info
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -902,7 +899,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check stack info
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -945,7 +942,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check stack info
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -999,7 +996,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check stack info
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -1037,19 +1034,19 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
|
||||
# 23. Update VNF
|
||||
# check attribute value before update VNF
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3)
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# check vnfd id
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
if not is_nfvo:
|
||||
self.assertEqual(self.vnfd_id_1, body['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, body['vnfdId'])
|
||||
else:
|
||||
self.assertEqual(vnfd_id_1, body['vnfdId'])
|
||||
self.assertEqual(max_vnfd_id, body['vnfdId'])
|
||||
|
||||
# check vnfc info
|
||||
vnfc_info = body['instantiatedVnfInfo']['vnfcInfo']
|
||||
@ -1062,9 +1059,9 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertIsNone(vnfc.get('vnfcConfigurableProperties'))
|
||||
|
||||
if not is_nfvo:
|
||||
update_req = paramgen.update_vnf_max(self.vnfd_id_3, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(self.upd_vnfd_id, vnfc_ids)
|
||||
else:
|
||||
update_req = paramgen.update_vnf_max(vnfd_id_2, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(upd_vnfd_id, vnfc_ids)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -1087,17 +1084,17 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3, 'IN_USE')
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
if not is_nfvo:
|
||||
# check the specified attribute after update VNF
|
||||
self.assertEqual(self.vnfd_id_3, body['vnfdId'])
|
||||
self.assertEqual(self.upd_vnfd_id, body['vnfdId'])
|
||||
else:
|
||||
self.assertEqual(vnfd_id_2, body['vnfdId'])
|
||||
self.assertEqual(upd_vnfd_id, body['vnfdId'])
|
||||
self.assertEqual('new name', body['vnfInstanceName'])
|
||||
self.assertEqual('new description', body['vnfInstanceDescription'])
|
||||
dummy_key_value = {'dummy-key': 'dummy-value'}
|
||||
@ -1147,7 +1144,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
@ -1160,7 +1157,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertIsNone(image_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3, 'IN_USE')
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -1175,9 +1172,10 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# execute "update vnf" again to update the vnfd_id to the
|
||||
# original vnfd_id
|
||||
if not is_nfvo:
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_1)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(
|
||||
self.max_vnfd_id)
|
||||
else:
|
||||
update_req = paramgen.update_vnf_min_with_parameter(vnfd_id_1)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(max_vnfd_id)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -1202,12 +1200,8 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# 29. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -1216,7 +1210,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3)
|
||||
self.check_package_usage(self.upd_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 31. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
@ -1236,8 +1230,9 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
def basic_lcms_min_common_test(self, is_nfvo=False):
|
||||
"""Test LCM operations with omitting except for required attributes
|
||||
|
||||
The change_ext_conn can't be tested here because VNF package 2 don't
|
||||
have external connectivity. So moved it to the test_scale_other_lcm().
|
||||
The change_ext_conn can't be tested here because min pattern VNF
|
||||
package don't have external connectivity. So moved it to
|
||||
the test_scale_other_lcm().
|
||||
|
||||
* About attributes:
|
||||
Omit except for required attributes.
|
||||
@ -1274,38 +1269,39 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# for basic lcms tests min pattern
|
||||
basic_lcms_min_path = os.path.join(
|
||||
cur_dir, "samples/basic_lcms_min")
|
||||
zip_path_file_1, vnfd_id_1 = self.create_vnf_package(
|
||||
min_zip_path, min_vnfd_id = self.create_vnf_package(
|
||||
basic_lcms_min_path, nfvo=True)
|
||||
update_vnf_path = os.path.join(
|
||||
cur_dir, "samples/update_vnf")
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
zip_path_file_2, vnfd_id_2 = self.create_vnf_package(
|
||||
upd_zip_path, upd_vnfd_id = self.create_vnf_package(
|
||||
update_vnf_path, nfvo=True)
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_1, zip_path_file_1)
|
||||
min_vnfd_id, min_zip_path)
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_2, zip_path_file_2)
|
||||
upd_vnfd_id, upd_zip_path)
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
flavour_vdu_dict = fake_grant_v2.GrantV2.get_compute_flavor(
|
||||
basic_lcms_min_path, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(vnfd_id_2)
|
||||
self.vnf_pkg_2 = None
|
||||
self.vnf_pkg_3 = None
|
||||
create_req = paramgen.create_vnf_min(min_vnfd_id)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(upd_vnfd_id)
|
||||
self.min_pkg = None
|
||||
self.upd_pkg = None
|
||||
else:
|
||||
glance_image = None
|
||||
flavour_vdu_dict = None
|
||||
zone_name_list = None
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_3)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(
|
||||
self.upd_vnfd_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -1317,7 +1313,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2)
|
||||
self.check_package_usage(self.min_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -1345,7 +1341,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2, 'IN_USE')
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -1457,18 +1453,18 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2, 'IN_USE')
|
||||
# check usageState of min pattern VNF Package
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3)
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
if not is_nfvo:
|
||||
# check vnfd id
|
||||
self.assertEqual(self.vnfd_id_2, body['vnfdId'])
|
||||
self.assertEqual(self.min_vnfd_id, body['vnfdId'])
|
||||
else:
|
||||
# check vnfd id
|
||||
self.assertEqual(vnfd_id_1, body['vnfdId'])
|
||||
self.assertEqual(min_vnfd_id, body['vnfdId'])
|
||||
|
||||
# 8. Update VNF
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
@ -1478,21 +1474,21 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2)
|
||||
# check usageState of min pattern VNF Package
|
||||
self.check_package_usage(self.min_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3, 'IN_USE')
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE', is_nfvo)
|
||||
if not is_nfvo:
|
||||
# check vnfd id
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(self.vnfd_id_3, body['vnfdId'])
|
||||
self.assertEqual(self.upd_vnfd_id, body['vnfdId'])
|
||||
else:
|
||||
# check vnfd id
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(vnfd_id_2, body['vnfdId'])
|
||||
self.assertEqual(upd_vnfd_id, body['vnfdId'])
|
||||
|
||||
# 9. Heal VNF(vnfc)
|
||||
self._set_grant_response(
|
||||
@ -1547,8 +1543,8 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(fields.VnfOperationalStateType.STARTED,
|
||||
body['instantiatedVnfInfo']['vnfState'])
|
||||
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3, 'IN_USE')
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# 11. Scale out operation
|
||||
self._set_grant_response(
|
||||
@ -1614,16 +1610,12 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# check deletion of Heat-stack
|
||||
stack_status, _ = self.heat_client.get_status(stack_name)
|
||||
self.assertIsNone(stack_status)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3, 'IN_USE')
|
||||
self.check_package_usage(self.upd_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -1638,10 +1630,12 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# execute "update vnf" again to update the vnfd_id to the
|
||||
# original vnfd_id
|
||||
if not is_nfvo:
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_2)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(
|
||||
self.min_vnfd_id)
|
||||
else:
|
||||
update_req = paramgen.update_vnf_min_with_parameter(vnfd_id_1)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(min_vnfd_id)
|
||||
resp, body = self.exec_lcm_operation(self.update_vnf_instance,
|
||||
inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
|
||||
@ -1665,12 +1659,8 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# 18. Delete a VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -1679,7 +1669,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(404, resp.status_code)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_3)
|
||||
self.check_package_usage(self.upd_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 19. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
@ -1732,7 +1722,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
change_vnfpkg_from_image_to_image_path = os.path.join(
|
||||
cur_dir,
|
||||
"samples/test_instantiate_vnf_with_old_image_or_volume")
|
||||
zip_file_path_1, vnfd_id_1 = self.create_vnf_package(
|
||||
old_zip_path, old_vnfd_id = self.create_vnf_package(
|
||||
change_vnfpkg_from_image_to_image_path, nfvo=True)
|
||||
change_vnfpkg_from_image_to_image_path_2 = os.path.join(
|
||||
cur_dir, "samples/test_change_vnf_pkg_with_new_image")
|
||||
@ -1740,7 +1730,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
cur_dir, "../../etc/samples/etsi/nfv/common/Files/images")
|
||||
image_file = "cirros-0.5.2-x86_64-disk.img"
|
||||
image_path = os.path.abspath(os.path.join(image_dir, image_file))
|
||||
zip_file_path_2, vnfd_id_2 = self.create_vnf_package(
|
||||
new_image_zip_path, new_image_vnfd_id = self.create_vnf_package(
|
||||
change_vnfpkg_from_image_to_image_path_2,
|
||||
image_path=image_path, nfvo=True)
|
||||
package_dir = os.path.join(
|
||||
@ -1762,17 +1752,17 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
package_dir, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_1, zip_file_path_1)
|
||||
create_req = paramgen.change_vnfpkg_create(vnfd_id_1)
|
||||
old_vnfd_id, old_zip_path)
|
||||
create_req = paramgen.change_vnfpkg_create(old_vnfd_id)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg_with_ext_vl(
|
||||
vnfd_id_2, self.get_network_ids(['net1']))
|
||||
new_image_vnfd_id, self.get_network_ids(['net1']))
|
||||
else:
|
||||
glance_image = None
|
||||
flavour_vdu_dict = None
|
||||
zone_name_list = None
|
||||
create_req = paramgen.change_vnfpkg_create(self.vnfd_id_1)
|
||||
create_req = paramgen.change_vnfpkg_create(self.old_vnfd_id)
|
||||
change_vnfpkg_req = paramgen.change_vnfpkg_with_ext_vl(
|
||||
self.vnfd_id_2, self.get_network_ids(['net1']))
|
||||
self.new_image_vnfd_id, self.get_network_ids(['net1']))
|
||||
|
||||
# 1. Create VNF instance
|
||||
resp, body = self.create_vnf_instance(create_req)
|
||||
@ -1835,7 +1825,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# 4. Change Current VNF Package
|
||||
if is_nfvo:
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_2, zip_file_path_2)
|
||||
new_image_vnfd_id, new_image_zip_path)
|
||||
g_image_id_1, g_image_id_2 = self.glance_create_image(
|
||||
instantiate_req.get("vimConnectionInfo").get("vim1"),
|
||||
image_path, sw_data, inst_id, num_vdu=2)
|
||||
@ -1873,12 +1863,8 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# wait a bit because there is a bit time lag between lcmocc DB
|
||||
# update and terminate completion.
|
||||
time.sleep(10)
|
||||
|
||||
# 7. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
@ -1929,7 +1915,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
|
||||
# Scale operation will fail
|
||||
scale_ng_path = os.path.join(cur_dir, "samples/scale_ng")
|
||||
zip_file_path_1, vnfd_id_1 = self.create_vnf_package(
|
||||
scale_ng_zip_path, scale_ng_vnfd_id = self.create_vnf_package(
|
||||
scale_ng_path, image_path=image_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample1_df_simple.yaml"
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
@ -1940,14 +1926,14 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
sw_data = fake_grant_v2.GrantV2.get_sw_data(scale_ng_path,
|
||||
vnfd_path)
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_1, zip_file_path_1)
|
||||
create_req = paramgen.create_vnf_max(vnfd_id_1)
|
||||
self.vnf_pkg_1 = None
|
||||
scale_ng_vnfd_id, scale_ng_zip_path)
|
||||
create_req = paramgen.create_vnf_max(scale_ng_vnfd_id)
|
||||
self.scale_ng_pkg = None
|
||||
else:
|
||||
glance_image = None
|
||||
flavour_vdu_dict = None
|
||||
zone_name_list = None
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.scale_ng_vnfd_id)
|
||||
# Create a new network and subnet to check the IP allocation of
|
||||
# IPv4 and IPv6
|
||||
ft_net0_name = 'ft-net0'
|
||||
@ -1981,10 +1967,10 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.addCleanup(self.delete_port, port_id)
|
||||
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_max(callback_uri)
|
||||
@ -1996,7 +1982,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1)
|
||||
self.check_package_usage(self.scale_ng_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -2024,7 +2010,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.scale_ng_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -2039,7 +2025,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
image_path, sw_data, inst_id, num_vdu=2)
|
||||
glance_image['VDU1-VirtualStorage'] = image_1_id
|
||||
glance_image['VDU2-VirtualStorage'] = image_2_id
|
||||
time.sleep(10)
|
||||
time.sleep(WAIT_LCMOCC_UPDATE_TIME)
|
||||
|
||||
self._set_grant_response(
|
||||
is_nfvo, 'INSTANTIATE', glance_image=glance_image,
|
||||
@ -2052,7 +2038,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.scale_ng_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# 5. Show VNF instance
|
||||
additional_inst_attrs = [
|
||||
@ -2087,7 +2073,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.scale_ng_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# 7. Show VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -2174,7 +2160,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1, 'IN_USE')
|
||||
self.check_package_usage(self.scale_ng_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -2182,17 +2168,13 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
body.get('instantiationState'))
|
||||
|
||||
# wait a bit because there is a bit time lag between vnf instance DB
|
||||
# terminate and delete completion.
|
||||
time.sleep(5)
|
||||
|
||||
# 13. Delete VNF instance
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
resp, body = self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
self.assertEqual(204, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_1)
|
||||
self.check_package_usage(self.scale_ng_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 14. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
@ -2237,7 +2219,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
error_network_path = os.path.join(
|
||||
cur_dir, "samples/error_network")
|
||||
# no image contained
|
||||
zip_file_path_1, vnfd_id_1 = self.create_vnf_package(
|
||||
err_nw_zip_path, err_nw_vnfd_id = self.create_vnf_package(
|
||||
error_network_path, nfvo=True)
|
||||
vnfd_path = "contents/Definitions/v2_sample2_df_simple.yaml"
|
||||
glance_image = fake_grant_v2.GrantV2.get_sw_image(
|
||||
@ -2246,19 +2228,19 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
error_network_path, vnfd_path)
|
||||
zone_name_list = self.get_zone_list()
|
||||
self._register_vnf_package_mock_response(
|
||||
vnfd_id_1, zip_file_path_1)
|
||||
create_req = paramgen.create_vnf_min(vnfd_id_1)
|
||||
self.vnf_pkg_2 = None
|
||||
err_nw_vnfd_id, err_nw_zip_path)
|
||||
create_req = paramgen.create_vnf_min(err_nw_vnfd_id)
|
||||
self.err_nw_pkg = None
|
||||
else:
|
||||
glance_image = None
|
||||
flavour_vdu_dict = None
|
||||
zone_name_list = None
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
create_req = paramgen.create_vnf_min(self.err_nw_vnfd_id)
|
||||
# 1. Create subscription
|
||||
callback_url = os.path.join(base_v2.MOCK_NOTIFY_CALLBACK_URL,
|
||||
callback_url = os.path.join(self.get_notify_callback_url(),
|
||||
self._testMethodName)
|
||||
callback_uri = ('http://localhost:'
|
||||
f'{base_v2.FAKE_SERVER_MANAGER.SERVER_PORT}'
|
||||
f'{self.get_server_port()}'
|
||||
f'{callback_url}')
|
||||
|
||||
sub_req = paramgen.sub_create_min(callback_uri)
|
||||
@ -2270,7 +2252,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
# 2. Test notification
|
||||
self.assert_notification_get(callback_url)
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2)
|
||||
self.check_package_usage(self.err_nw_pkg, is_nfvo=is_nfvo)
|
||||
|
||||
# 3. Create VNF instance
|
||||
# ETSI NFV SOL003 v3.3.1 5.5.2.2 VnfInstance
|
||||
@ -2298,7 +2280,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
inst_id = body['id']
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2, 'IN_USE')
|
||||
self.check_package_usage(self.err_nw_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# check instantiationState of VNF
|
||||
self.assertEqual(fields.VnfInstanceState.NOT_INSTANTIATED,
|
||||
@ -2317,7 +2299,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2, 'IN_USE')
|
||||
self.check_package_usage(self.err_nw_pkg, 'IN_USE', is_nfvo)
|
||||
|
||||
# 5. Show VNF instance
|
||||
resp, body = self.show_vnf_instance(inst_id)
|
||||
@ -2401,7 +2383,7 @@ class CommonVnfLcmTest(base_v2.BaseSolV2Test):
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
|
||||
# check usageState of VNF Package
|
||||
self._check_package_usage(is_nfvo, self.vnf_pkg_2, 'NOT_IN_USE')
|
||||
self.check_package_usage(self.err_nw_pkg, 'NOT_IN_USE', is_nfvo)
|
||||
|
||||
# 10. Delete subscription
|
||||
resp, body = self.delete_subscription(sub_id)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from tacker.objects import fields
|
||||
from tacker.tests.functional.sol_v2_common import base_v2
|
||||
@ -45,27 +44,27 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
# vnf package for basic lcms tests max pattern
|
||||
pkg_path_1 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/basic_lcms_max_individual_vnfc")
|
||||
cls.vnf_pkg_1, cls.vnfd_id_1 = cls.create_vnf_package(
|
||||
cls.max_pkg, cls.max_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_1, image_path=image_path,
|
||||
userdata_path=userdata_path)
|
||||
|
||||
# vnf package for basic lcms tests min pattern
|
||||
pkg_path_2 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/basic_lcms_min_individual_vnfc")
|
||||
cls.vnf_pkg_2, cls.vnfd_id_2 = cls.create_vnf_package(
|
||||
cls.min_pkg, cls.min_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_2, userdata_path=userdata_path)
|
||||
|
||||
# vnf package for update vnf max pattern
|
||||
pkg_path_3 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/update_vnf_max_individual_vnfc")
|
||||
cls.vnf_pkg_3, cls.vnfd_id_3 = cls.create_vnf_package(
|
||||
cls.upd_max_pkg, cls.upd_max_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_3, image_path=image_path,
|
||||
userdata_path=userdata_path)
|
||||
|
||||
# vnf package for change vnf package max pattern
|
||||
pkg_path_4 = os.path.join(cur_dir,
|
||||
"../sol_v2_common/samples/change_vnfpkg_max_individual_vnfc")
|
||||
cls.vnf_pkg_4, cls.vnfd_id_4 = cls.create_vnf_package(
|
||||
cls.new_max_pkg, cls.new_max_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_4, userdata_path=userdata_path)
|
||||
|
||||
# vnf package for change vnf package or update min pattern
|
||||
@ -73,7 +72,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
cur_dir,
|
||||
"../sol_v2_common/samples/"
|
||||
"change_vnfpkg_or_update_min_individual_vnfc")
|
||||
cls.vnf_pkg_5, cls.vnfd_id_5 = cls.create_vnf_package(
|
||||
cls.upd_new_min_pkg, cls.upd_new_min_vnfd_id = cls.create_vnf_package(
|
||||
pkg_path_5, image_path=image_path, userdata_path=userdata_path)
|
||||
|
||||
cls.expected_list_attrs = [
|
||||
@ -102,11 +101,11 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(IndividualVnfcMgmtBasicTest, cls).tearDownClass()
|
||||
cls.delete_vnf_package(cls.vnf_pkg_1)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_2)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_3)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_4)
|
||||
cls.delete_vnf_package(cls.vnf_pkg_5)
|
||||
cls.delete_vnf_package(cls.max_pkg)
|
||||
cls.delete_vnf_package(cls.min_pkg)
|
||||
cls.delete_vnf_package(cls.upd_max_pkg)
|
||||
cls.delete_vnf_package(cls.new_max_pkg)
|
||||
cls.delete_vnf_package(cls.upd_new_min_pkg)
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
@ -158,13 +157,6 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
cls, ['subnet0', 'subnet1', 'ft-ipv4-subnet0', 'ft-ipv6-subnet0',
|
||||
'ft-ipv4-subnet1', 'ft-ipv6-subnet1'])
|
||||
|
||||
def _put_fail_file(self, operation):
|
||||
with open(f'/tmp/{operation}', 'w'):
|
||||
pass
|
||||
|
||||
def _rm_fail_file(self, operation):
|
||||
os.remove(f'/tmp/{operation}')
|
||||
|
||||
def _get_vdu_indexes(self, inst, vdu):
|
||||
return {
|
||||
vnfc['metadata'].get('vdu_idx')
|
||||
@ -294,23 +286,6 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
|
||||
return body
|
||||
|
||||
def _check_package_usage(self, package_id, state='NOT_IN_USE'):
|
||||
usage_state = self.get_vnf_package(package_id)['usageState']
|
||||
self.assertEqual(state, usage_state)
|
||||
|
||||
def _delete_instance(self, inst_id):
|
||||
for _ in range(3):
|
||||
resp, body = self.delete_vnf_instance(inst_id)
|
||||
if resp.status_code == 204: # OK
|
||||
return
|
||||
elif resp.status_code == 409:
|
||||
# may happen. there is a bit time between lcmocc become
|
||||
# COMPLETED and lock of terminate is freed.
|
||||
time.sleep(3)
|
||||
else:
|
||||
break
|
||||
self.assertTrue(False)
|
||||
|
||||
def test_basic_lcms_max(self):
|
||||
"""Test LCM operations for individual vnfc mgmt with all attributes set
|
||||
|
||||
@ -359,7 +334,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_max(
|
||||
self.vnfd_id_1,
|
||||
self.max_vnfd_id,
|
||||
description="test for basic_lcms_max_individual_vnfc")
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
@ -418,7 +393,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
# The Response Header will contain a 'Link' Header only when there
|
||||
# are at least two vnf instance data in the database, so it needs to
|
||||
# create an unused data.
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
_, tmp_body = self.create_vnf_instance(create_req)
|
||||
resp, body = self.list_vnf_instance()
|
||||
self.assertEqual(200, resp.status_code)
|
||||
@ -474,7 +449,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.assertNotIn('vimConnectionInfo', inst)
|
||||
self.assertNotIn('instantiatedVnfInfo', inst)
|
||||
self.assertNotIn('metadata', inst)
|
||||
self._delete_instance(tmp_body['id'])
|
||||
self.delete_vnf_instance(tmp_body['id'])
|
||||
|
||||
# 4. Show VNF LCM operation occurrence
|
||||
expected_attrs = [
|
||||
@ -765,16 +740,16 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self._get_vnfc_storage_ids(inst_23, 'VDU2', 0))
|
||||
# 24. Update VNF
|
||||
# check attribute value before update VNF
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1, 'IN_USE')
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
# check usageState of update VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg)
|
||||
# check vnfd id
|
||||
self.assertEqual(self.vnfd_id_1, inst_23['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, inst_23['vnfdId'])
|
||||
|
||||
vnfc_info = inst_23['instantiatedVnfInfo']['vnfcInfo']
|
||||
vnfc_ids = [vnfc['id'] for vnfc in vnfc_info]
|
||||
update_req = paramgen.update_vnf_max(self.vnfd_id_3, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(self.upd_max_vnfd_id, vnfc_ids)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -786,11 +761,11 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
vdu_result = {'VDU1': {0}, 'VDU2': {0}}
|
||||
inst_25 = self._check_for_show_operation(
|
||||
'MODIFY_INFO', expected_inst_attrs, inst_id, vdu_result)
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1)
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3, 'IN_USE')
|
||||
self.assertEqual(self.vnfd_id_3, inst_25['vnfdId'])
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg)
|
||||
# check usageState of update max pattern VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg, 'IN_USE')
|
||||
self.assertEqual(self.upd_max_vnfd_id, inst_25['vnfdId'])
|
||||
self.assertEqual('new name', inst_25['vnfInstanceName'])
|
||||
self.assertEqual('new description', inst_25['vnfInstanceDescription'])
|
||||
dummy_key_value = {'dummy-key': 'dummy-value'}
|
||||
@ -799,28 +774,28 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(dummy_key_value, inst_25['vnfConfigurableProperties'])
|
||||
|
||||
# 26. Update VNF(again)
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1)
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3, 'IN_USE')
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg)
|
||||
# check usageState of update max pattern VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg, 'IN_USE')
|
||||
# check vnfd id
|
||||
self.assertEqual(self.vnfd_id_3, inst_25['vnfdId'])
|
||||
self.assertEqual(self.upd_max_vnfd_id, inst_25['vnfdId'])
|
||||
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_1)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.max_vnfd_id)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# 27. Change current VNF Package
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1, 'IN_USE')
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3)
|
||||
# check usageState of VNF Package 4
|
||||
self._check_package_usage(self.vnf_pkg_4)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
# check usageState of update max pattern VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg)
|
||||
# check usageState of new max pattern VNF Package
|
||||
self.check_package_usage(self.new_max_pkg)
|
||||
change_vnf_pkg_req = paramgen.change_vnf_pkg_individual_vnfc_max(
|
||||
self.vnfd_id_4, self.net_ids, self.subnet_ids)
|
||||
self.new_max_vnfd_id, self.net_ids, self.subnet_ids)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnf_pkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -828,15 +803,15 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# 28. Show VNF instance(check for change-vnfpkg)
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1)
|
||||
# check usageState of VNF Package 4
|
||||
self._check_package_usage(self.vnf_pkg_4, 'IN_USE')
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg)
|
||||
# check usageState of new max pattern VNF Package
|
||||
self.check_package_usage(self.new_max_pkg, 'IN_USE')
|
||||
vdu_result = {'VDU1': {0}, 'VDU2': {0}}
|
||||
inst_28 = self._check_for_show_operation(
|
||||
'CHANGE_VNFPKG', expected_inst_attrs, inst_id, vdu_result)
|
||||
# check vnfdId
|
||||
self.assertEqual(self.vnfd_id_4, inst_28['vnfdId'])
|
||||
self.assertEqual(self.new_max_vnfd_id, inst_28['vnfdId'])
|
||||
# check all ids of VDU are changed
|
||||
self.assertNotEqual(self._get_vnfc_id(inst_25, 'VDU1', 0),
|
||||
self._get_vnfc_id(inst_28, 'VDU1', 0))
|
||||
@ -889,13 +864,13 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 30. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_basic_lcms_min(self):
|
||||
"""Test LCM operations with omitting except for required attributes
|
||||
|
||||
The change_ext_conn can't be tested here because VNF package 2 don't
|
||||
have external connectivity. So moved it to the
|
||||
The change_ext_conn can't be tested here because min pattern VNF
|
||||
package 2 don't have external connectivity. So moved it to the
|
||||
test_various_lcm_operations_before_and_after().
|
||||
|
||||
* About attributes:
|
||||
@ -928,7 +903,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
- 19. Delete VNF
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
|
||||
@ -1014,22 +989,23 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
vdu_result, image_result)
|
||||
|
||||
# 7. Update VNF
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_5)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(
|
||||
self.upd_new_min_vnfd_id)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(self.vnf_pkg_2)
|
||||
# check usageState of VNF Package 5
|
||||
self._check_package_usage(self.vnf_pkg_5, 'IN_USE')
|
||||
# check usageState of min pattern VNF Package
|
||||
self.check_package_usage(self.min_pkg)
|
||||
# check usageState of update or new min pattern VNF Package
|
||||
self.check_package_usage(self.upd_new_min_pkg, 'IN_USE')
|
||||
|
||||
# 8. Show VNF instance(check for update)
|
||||
inst_8 = self._check_for_show_operation(
|
||||
'MODIFY_INFO', expected_inst_attrs, inst_id)
|
||||
self.assertEqual(self.vnfd_id_5, inst_8['vnfdId'])
|
||||
self.assertEqual(self.upd_new_min_vnfd_id, inst_8['vnfdId'])
|
||||
|
||||
# 9. Heal VNF(vnfc)
|
||||
vnfc_info = inst_8['instantiatedVnfInfo']['vnfcInfo']
|
||||
@ -1092,17 +1068,18 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 14. Update VNF again
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.vnfd_id_2)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
update_req = paramgen.update_vnf_min_with_parameter(self.min_vnfd_id)
|
||||
resp, body = self.exec_lcm_operation(self.update_vnf_instance,
|
||||
inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(self.vnf_pkg_2, 'IN_USE')
|
||||
# check usageState of VNF Package 5
|
||||
self._check_package_usage(self.vnf_pkg_5)
|
||||
# check usageState of min pattern VNF Package
|
||||
self.check_package_usage(self.min_pkg, 'IN_USE')
|
||||
# check usageState of update or new min pattern VNF Package
|
||||
self.check_package_usage(self.upd_new_min_pkg)
|
||||
|
||||
# 15. Instantiate VNF again
|
||||
resp, body = self.instantiate_vnf_instance(
|
||||
@ -1117,7 +1094,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
|
||||
# 16. Change current VNF Package
|
||||
change_vnf_pkg_req = paramgen.change_vnf_pkg_individual_vnfc_min(
|
||||
self.vnfd_id_5)
|
||||
self.upd_new_min_vnfd_id)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnf_pkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -1125,14 +1102,14 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.wait_lcmocc_complete(lcmocc_id)
|
||||
|
||||
# 17. Show VNF instance(check for change-vnfpkg)
|
||||
# check usageState of VNF Package 2
|
||||
self._check_package_usage(self.vnf_pkg_2)
|
||||
# check usageState of VNF Package 5
|
||||
self._check_package_usage(self.vnf_pkg_5, 'IN_USE')
|
||||
# check usageState of min pattern VNF Package
|
||||
self.check_package_usage(self.min_pkg)
|
||||
# check usageState of update or new min pattern VNF Package
|
||||
self.check_package_usage(self.upd_new_min_pkg, 'IN_USE')
|
||||
inst_17 = self._check_for_show_operation(
|
||||
'CHANGE_VNFPKG', expected_inst_attrs, inst_id)
|
||||
# check vnfdId
|
||||
self.assertEqual(self.vnfd_id_5, inst_17['vnfdId'])
|
||||
self.assertEqual(self.upd_new_min_vnfd_id, inst_17['vnfdId'])
|
||||
# check ids of VDU are not changed
|
||||
self.assertEqual(self._get_vnfc_id(inst_15, 'VDU1', 0),
|
||||
self._get_vnfc_id(inst_17, 'VDU1', 0))
|
||||
@ -1163,7 +1140,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 19. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_retry_rollback_scale_out(self):
|
||||
"""Test retry and rollback scale out operations
|
||||
@ -1192,7 +1169,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_max(
|
||||
self.vnfd_id_1,
|
||||
self.max_vnfd_id,
|
||||
description="test for retry and rollback scale out")
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
@ -1231,7 +1208,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
'INSTANTIATE', expected_inst_attrs, inst_id)
|
||||
|
||||
# 3. Scale out operation(will fail)
|
||||
self._put_fail_file('scale_end')
|
||||
self.put_fail_file('scale_end')
|
||||
scaleout_req = paramgen.scaleout_vnf_max()
|
||||
self._add_additional_params(scaleout_req)
|
||||
resp, body = self.scale_vnf_instance(inst_id, scaleout_req)
|
||||
@ -1251,7 +1228,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_delete(resp)
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('scale_end')
|
||||
self.rm_fail_file('scale_end')
|
||||
|
||||
# 6. Rollback scale out operation
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -1308,7 +1285,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body.get('instantiationState'))
|
||||
|
||||
# 10. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_rollback_instantiate(self):
|
||||
"""Test rollback instantiate operation
|
||||
@ -1330,12 +1307,12 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
- 6. Delete VNF
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_min(self.vnfd_id_2)
|
||||
create_req = paramgen.create_vnf_min(self.min_vnfd_id)
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
|
||||
# 1. Instantiate VNF(will fail)
|
||||
self._put_fail_file('instantiate_end')
|
||||
self.put_fail_file('instantiate_end')
|
||||
instantiate_req = paramgen.instantiate_vnf_min()
|
||||
self._add_additional_params(instantiate_req)
|
||||
resp, body = self.instantiate_vnf_instance(
|
||||
@ -1345,7 +1322,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('instantiate_end')
|
||||
self.rm_fail_file('instantiate_end')
|
||||
|
||||
# 2. Show VNF instance
|
||||
expected_inst_attrs = [
|
||||
@ -1414,7 +1391,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.check_resp_body(lcmocc, self.expected_list_attrs)
|
||||
|
||||
# 6. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_rollback_chgextconn_and_update(self):
|
||||
"""Test rollback change_ext_conn and update operation
|
||||
@ -1444,7 +1421,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
- 12. Delete VNF
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_max(self.vnfd_id_1)
|
||||
create_req = paramgen.create_vnf_max(self.max_vnfd_id)
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
|
||||
@ -1483,7 +1460,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
'INSTANTIATE', expected_inst_attrs, inst_id)
|
||||
|
||||
# 3. Change external connectivity(will fail)
|
||||
self._put_fail_file('change_external_connectivity_end')
|
||||
self.put_fail_file('change_external_connectivity_end')
|
||||
change_ext_conn_req = paramgen.change_ext_conn_min(
|
||||
self.net_ids, self.subnet_ids)
|
||||
self._add_additional_params(change_ext_conn_req)
|
||||
@ -1492,7 +1469,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('change_external_connectivity_end')
|
||||
self.rm_fail_file('change_external_connectivity_end')
|
||||
|
||||
# 4. Rollback change_ext_conn operation
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -1539,7 +1516,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.check_resp_body(lcmocc, self.expected_list_attrs)
|
||||
|
||||
# 7. Update VNF(will fail)
|
||||
self._put_fail_file('modify_information_start')
|
||||
self.put_fail_file('modify_information_start')
|
||||
update_req = paramgen.update_vnf_min()
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
@ -1547,7 +1524,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('modify_information_start')
|
||||
self.rm_fail_file('modify_information_start')
|
||||
|
||||
# 8. Rollback update operation
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -1604,7 +1581,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 12. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_rollback_change_vnfpkg(self):
|
||||
"""Test rollback change_vnfpkg operation
|
||||
@ -1636,7 +1613,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_max(
|
||||
self.vnfd_id_1,
|
||||
self.max_vnfd_id,
|
||||
description="test for rollback change vnf package")
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
@ -1675,15 +1652,15 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
'INSTANTIATE', expected_inst_attrs, inst_id)
|
||||
|
||||
# 3. Change Current VNF Package(will fail)
|
||||
self._put_fail_file('change_vnfpkg')
|
||||
self.put_fail_file('change_vnfpkg')
|
||||
change_vnf_pkg_req = paramgen.change_vnf_pkg_individual_vnfc_max(
|
||||
self.vnfd_id_4, self.net_ids, self.subnet_ids)
|
||||
self.new_max_vnfd_id, self.net_ids, self.subnet_ids)
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnf_pkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
lcmocc_id = os.path.basename(resp.headers['Location'])
|
||||
self.wait_lcmocc_failed_temp(lcmocc_id)
|
||||
self._rm_fail_file('change_vnfpkg')
|
||||
self.rm_fail_file('change_vnfpkg')
|
||||
|
||||
# 4. Rollback change_vnfpkg operation
|
||||
resp, body = self.rollback_lcmocc(lcmocc_id)
|
||||
@ -1720,7 +1697,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
# 6. Show VNF instance
|
||||
_, inst_6 = self.show_vnf_instance(inst_id)
|
||||
# check vnfdId
|
||||
self.assertEqual(self.vnfd_id_1, inst_6['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, inst_6['vnfdId'])
|
||||
# check images of VDU are not changed
|
||||
self.assertEqual(self._get_vnfc_image(inst_2, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_6, 'VDU1', 0))
|
||||
@ -1752,7 +1729,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
# 1. change VM created by image to VM created by new image
|
||||
# 2. change VM created by volume to VM created by new volume
|
||||
change_vnf_pkg_req = paramgen.change_vnf_pkg_individual_vnfc_min(
|
||||
self.vnfd_id_5, vdu2_old_vnfc='VDU2_CP2')
|
||||
self.upd_new_min_vnfd_id, vdu2_old_vnfc='VDU2_CP2')
|
||||
resp, body = self.change_vnfpkg(inst_id, change_vnf_pkg_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -1806,7 +1783,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
# 11. Show VNF instance
|
||||
_, inst_11 = self.show_vnf_instance(inst_id)
|
||||
# check vnfdId
|
||||
self.assertEqual(self.vnfd_id_1, inst_11['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, inst_11['vnfdId'])
|
||||
# check images of VDU are not changed
|
||||
self.assertEqual(self._get_vnfc_image(inst_2, 'VDU1', 0),
|
||||
self._get_vnfc_image(inst_11, 'VDU1', 0))
|
||||
@ -1829,7 +1806,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 13. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
||||
def test_various_lcm_operations_before_and_after(self):
|
||||
"""Test various vnflcm operations before and after
|
||||
@ -1880,7 +1857,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
"""
|
||||
# 0. Create VNF
|
||||
create_req = paramgen.create_vnf_max(
|
||||
self.vnfd_id_1, description="test for various lcm operations")
|
||||
self.max_vnfd_id, description="test for various lcm operations")
|
||||
_, body = self.create_vnf_instance(create_req)
|
||||
inst_id = body['id']
|
||||
|
||||
@ -2209,12 +2186,12 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
|
||||
# 25. Update VNF
|
||||
# check attribute value before update VNF
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1, 'IN_USE')
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3)
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg, 'IN_USE')
|
||||
# check usageState of update max pattern VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg)
|
||||
# check vnfd id
|
||||
self.assertEqual(self.vnfd_id_1, inst_24['vnfdId'])
|
||||
self.assertEqual(self.max_vnfd_id, inst_24['vnfdId'])
|
||||
# check vnfc info
|
||||
vnfc_info = inst_24['instantiatedVnfInfo']['vnfcInfo']
|
||||
self.assertGreater(len(vnfc_info), 1)
|
||||
@ -2225,7 +2202,7 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
self.assertIsNotNone(vnfc.get('vnfcState'))
|
||||
self.assertIsNone(vnfc.get('vnfcConfigurableProperties'))
|
||||
|
||||
update_req = paramgen.update_vnf_max(self.vnfd_id_3, vnfc_ids)
|
||||
update_req = paramgen.update_vnf_max(self.upd_max_vnfd_id, vnfc_ids)
|
||||
resp, body = self.update_vnf_instance(inst_id, update_req)
|
||||
self.assertEqual(202, resp.status_code)
|
||||
self.check_resp_headers_in_operation_task(resp)
|
||||
@ -2237,11 +2214,11 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
vdu_result = {'VDU1': {0}, 'VDU2': {0}}
|
||||
inst_26 = self._check_for_show_operation(
|
||||
'MODIFY_INFO', expected_inst_attrs, inst_id, vdu_result)
|
||||
# check usageState of VNF Package 1
|
||||
self._check_package_usage(self.vnf_pkg_1)
|
||||
# check usageState of VNF Package 3
|
||||
self._check_package_usage(self.vnf_pkg_3, 'IN_USE')
|
||||
self.assertEqual(self.vnfd_id_3, inst_26['vnfdId'])
|
||||
# check usageState of max pattern VNF Package
|
||||
self.check_package_usage(self.max_pkg)
|
||||
# check usageState of update max pattern VNF Package
|
||||
self.check_package_usage(self.upd_max_pkg, 'IN_USE')
|
||||
self.assertEqual(self.upd_max_vnfd_id, inst_26['vnfdId'])
|
||||
self.assertEqual('new name', inst_26['vnfInstanceName'])
|
||||
self.assertEqual('new description', inst_26['vnfInstanceDescription'])
|
||||
dummy_key_value = {'dummy-key': 'dummy-value'}
|
||||
@ -2415,4 +2392,4 @@ class IndividualVnfcMgmtBasicTest(base_v2.BaseSolV2Test):
|
||||
body['instantiationState'])
|
||||
|
||||
# 32. Delete VNF
|
||||
self._delete_instance(inst_id)
|
||||
self.exec_lcm_operation(self.delete_vnf_instance, inst_id)
|
||||
|
Loading…
Reference in New Issue
Block a user