aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/vnf/router/cloudify_vrouter.py')
-rw-r--r--functest/opnfv_tests/vnf/router/cloudify_vrouter.py141
1 files changed, 32 insertions, 109 deletions
diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
index e8c8632bd..32d675347 100644
--- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
+++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
@@ -15,14 +15,13 @@ import logging
import os
import time
-from cloudify_rest_client.executions import Execution
import pkg_resources
-import scp
from functest.core import cloudify
from functest.opnfv_tests.vnf.router import vrouter_base
from functest.opnfv_tests.vnf.router.utilvnf import Utilvnf
from functest.utils import config
+from functest.utils import env
from functest.utils import functest_utils
@@ -35,23 +34,31 @@ class CloudifyVrouter(cloudify.Cloudify):
__logger = logging.getLogger(__name__)
- filename_alt = '/home/opnfv/functest/images/vyos-1.1.7.img'
+ filename_alt = '/home/opnfv/functest/images/vyos-1.1.8-amd64.qcow2'
- flavor_alt_ram = 2048
+ flavor_alt_ram = 1024
flavor_alt_vcpus = 1
- flavor_alt_disk = 50
+ flavor_alt_disk = 3
+
+ check_console_loop = 12
+
+ cop_yaml = ("https://github.com/cloudify-cosmo/cloudify-openstack-plugin/"
+ "releases/download/2.14.7/plugin.yaml")
+ cop_wgn = ("https://github.com/cloudify-cosmo/cloudify-openstack-plugin/"
+ "releases/download/2.14.7/cloudify_openstack_plugin-2.14.7-py27"
+ "-none-linux_x86_64-centos-Core.wgn")
def __init__(self, **kwargs):
if "case_name" not in kwargs:
kwargs["case_name"] = "vyos_vrouter"
- super(CloudifyVrouter, self).__init__(**kwargs)
+ super().__init__(**kwargs)
# Retrieve the configuration
try:
self.config = getattr(
- config.CONF, 'vnf_{}_config'.format(self.case_name))
- except Exception:
- raise Exception("VNF config file not found")
+ config.CONF, f'vnf_{self.case_name}_config')
+ except Exception as exc:
+ raise Exception("VNF config file not found") from exc
self.case_dir = pkg_resources.resource_filename(
'functest', 'opnfv_tests/vnf/router')
@@ -106,6 +113,13 @@ class CloudifyVrouter(cloudify.Cloudify):
self.image_alt = None
self.flavor_alt = None
+ def check_requirements(self):
+ if env.get('NEW_USER_ROLE').lower() == "admin":
+ self.__logger.warning(
+ "Defining NEW_USER_ROLE=admin will easily break the testcase "
+ "because Cloudify doesn't manage tenancy (e.g. subnet "
+ "overlapping)")
+
def execute(self):
# pylint: disable=too-many-locals,too-many-statements
"""
@@ -113,18 +127,10 @@ class CloudifyVrouter(cloudify.Cloudify):
network, security group, fip, VM creation
"""
# network creation
- super(CloudifyVrouter, self).execute()
+ super().execute()
start_time = time.time()
- self.__logger.info("Put private keypair in manager")
- scpc = scp.SCPClient(self.ssh.get_transport())
- scpc.put(self.key_filename, remote_path='~/cloudify_ims.pem')
- (_, stdout, stderr) = self.ssh.exec_command(
- "sudo cp ~/cloudify_ims.pem /etc/cloudify/ && "
- "sudo chmod 444 /etc/cloudify/cloudify_ims.pem && "
- "sudo yum install -y gcc python-devel python-cmd2 && "
- "cfy status")
- self.__logger.info("output:\n%s", stdout.read())
- self.__logger.info("error:\n%s", stderr.read())
+ self.put_private_key()
+ self.upload_cfy_plugins(self.cop_yaml, self.cop_wgn)
self.image_alt = self.publish_image_alt()
self.flavor_alt = self.create_flavor_alt()
@@ -181,8 +187,8 @@ class CloudifyVrouter(cloudify.Cloudify):
descriptor.get('name'), descriptor.get('name'),
self.vnf.get('inputs'))
- wait_for_execution(
- self.cfy_client, get_execution_id(
+ cloudify.wait_for_execution(
+ self.cfy_client, cloudify.get_execution_id(
self.cfy_client, descriptor.get('name')),
self.__logger, timeout=7200)
@@ -190,7 +196,7 @@ class CloudifyVrouter(cloudify.Cloudify):
execution = self.cfy_client.executions.start(
descriptor.get('name'), 'install')
# Show execution log
- execution = wait_for_execution(
+ execution = cloudify.wait_for_execution(
self.cfy_client, execution, self.__logger)
duration = time.time() - start_time
@@ -206,8 +212,7 @@ class CloudifyVrouter(cloudify.Cloudify):
def test_vnf(self):
start_time = time.time()
- testing = vrouter_base.VrouterOnBoardingBase(
- self.case_name, self.util, self.util_info)
+ testing = vrouter_base.VrouterOnBoardingBase(self.util, self.util_info)
result, test_result_data = testing.test_vnf()
duration = time.time() - start_time
if result:
@@ -221,91 +226,9 @@ class CloudifyVrouter(cloudify.Cloudify):
return True
def clean(self):
- try:
- dep_name = self.vnf['descriptor'].get('name')
- # kill existing execution
- self.__logger.info('Deleting the current deployment')
- exec_list = self.cfy_client.executions.list()
- for execution in exec_list:
- if execution['status'] == "started":
- try:
- self.cfy_client.executions.cancel(
- execution['id'], force=True)
- except Exception: # pylint: disable=broad-except
- self.__logger.warn("Can't cancel the current exec")
-
- execution = self.cfy_client.executions.start(
- dep_name, 'uninstall', parameters=dict(ignore_failure=True))
-
- wait_for_execution(self.cfy_client, execution, self.__logger)
- self.cfy_client.deployments.delete(
- self.vnf['descriptor'].get('name'))
- self.cfy_client.blueprints.delete(
- self.vnf['descriptor'].get('name'))
- except Exception: # pylint: disable=broad-except
- self.__logger.exception("Some issue during the undeployment ..")
+ self.kill_existing_execution(self.vnf['descriptor'].get('name'))
if self.image_alt:
self.cloud.delete_image(self.image_alt)
if self.flavor_alt:
self.orig_cloud.delete_flavor(self.flavor_alt.id)
- super(CloudifyVrouter, self).clean()
-
-
-def wait_for_execution(client, execution, logger, timeout=7200, ):
- """Wait for a workflow execution on Cloudify Manager."""
- # if execution already ended - return without waiting
- if execution.status in Execution.END_STATES:
- return execution
-
- if timeout is not None:
- deadline = time.time() + timeout
-
- # Poll for execution status and execution logs, until execution ends
- # and we receive an event of type in WORKFLOW_END_TYPES
- offset = 0
- batch_size = 50
- event_list = []
- execution_ended = False
- while True:
- event_list = client.events.list(
- execution_id=execution.id, _offset=offset, _size=batch_size,
- include_logs=True, sort='@timestamp').items
-
- offset = offset + len(event_list)
- for event in event_list:
- logger.debug(event.get('message'))
-
- if timeout is not None:
- if time.time() > deadline:
- raise RuntimeError(
- 'execution of operation {0} for deployment {1} '
- 'timed out'.format(execution.workflow_id,
- execution.deployment_id))
- else:
- # update the remaining timeout
- timeout = deadline - time.time()
-
- if not execution_ended:
- execution = client.executions.get(execution.id)
- execution_ended = execution.status in Execution.END_STATES
-
- if execution_ended:
- break
-
- time.sleep(5)
-
- return execution
-
-
-def get_execution_id(client, deployment_id):
- """
- Get the execution id of a env preparation.
- network, security group, fip, VM creation
- """
- executions = client.executions.list(deployment_id=deployment_id)
- for execution in executions:
- if execution.workflow_id == 'create_deployment_environment':
- return execution
- raise RuntimeError('Failed to get create_deployment_environment '
- 'workflow execution.'
- 'Available executions: {0}'.format(executions))
+ super().clean()