aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/core/cloudify.py65
-rw-r--r--functest/opnfv_tests/openstack/vgpu/vgpu.py5
-rw-r--r--functest/opnfv_tests/vnf/epc/juju_epc.py57
-rw-r--r--functest/opnfv_tests/vnf/ims/clearwater.py4
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py129
-rw-r--r--functest/opnfv_tests/vnf/ims/heat_ims.py43
-rw-r--r--functest/opnfv_tests/vnf/router/cloudify_vrouter.py70
7 files changed, 130 insertions, 243 deletions
diff --git a/functest/core/cloudify.py b/functest/core/cloudify.py
index a760b9fa2..0428a13b3 100644
--- a/functest/core/cloudify.py
+++ b/functest/core/cloudify.py
@@ -15,6 +15,7 @@ import logging
import time
from cloudify_rest_client import CloudifyClient
+from cloudify_rest_client.executions import Execution
from functest.core import singlevm
@@ -81,3 +82,67 @@ class Cloudify(singlevm.SingleVm2):
return 1
self.__logger.info("Cloudify Manager is up and running")
return 0
+
+
+def wait_for_execution(client, execution, logger, timeout=3600, ):
+ """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))
diff --git a/functest/opnfv_tests/openstack/vgpu/vgpu.py b/functest/opnfv_tests/openstack/vgpu/vgpu.py
index 12f183e4e..c8180a45c 100644
--- a/functest/opnfv_tests/openstack/vgpu/vgpu.py
+++ b/functest/opnfv_tests/openstack/vgpu/vgpu.py
@@ -49,6 +49,5 @@ class VGPU(singlevm.SingleVm2):
'VGA compatible controller: Nvidia' in lspci_output):
self.__logger.info("The VM have a vGPU")
return 0
- else:
- self.__logger.error("The VM haven't any vGPU")
- return 1
+ self.__logger.error("The VM haven't any vGPU")
+ return 1
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py
index 644911bd7..eda910a90 100644
--- a/functest/opnfv_tests/vnf/epc/juju_epc.py
+++ b/functest/opnfv_tests/vnf/epc/juju_epc.py
@@ -20,11 +20,11 @@ import sys
from copy import deepcopy
import pkg_resources
import six
-import yaml
from functest.core import singlevm
from functest.utils import config
from functest.utils import env
+from functest.utils import functest_utils
__author__ = "Amarendra Meher <amarendra@rebaca.com>"
__author__ = "Soumaya K Nayek <soumaya.nayek@rebaca.com>"
@@ -96,32 +96,42 @@ class JujuEpc(singlevm.VmReady2):
except Exception:
raise Exception("VNF config file not found")
self.config_file = os.path.join(self.case_dir, self.config)
- self.orchestrator = dict(requirements=get_config(
- "orchestrator.requirements", self.config_file))
+ self.orchestrator = dict(
+ requirements=functest_utils.get_parameter_from_yaml(
+ "orchestrator.requirements", self.config_file))
self.created_object = []
self.details['orchestrator'] = dict(
- name=get_config("orchestrator.name", self.config_file),
- version=get_config("orchestrator.version", self.config_file),
+ name=functest_utils.get_parameter_from_yaml(
+ "orchestrator.name", self.config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "orchestrator.version", self.config_file),
status='ERROR',
result=''
)
self.vnf = dict(
- descriptor=get_config("vnf.descriptor", self.config_file),
- requirements=get_config("vnf.requirements", self.config_file)
+ descriptor=functest_utils.get_parameter_from_yaml(
+ "vnf.descriptor", self.config_file),
+ requirements=functest_utils.get_parameter_from_yaml(
+ "vnf.requirements", self.config_file)
)
self.details['vnf'] = dict(
descriptor_version=self.vnf['descriptor']['version'],
- name=get_config("vnf.name", self.config_file),
- version=get_config("vnf.version", self.config_file),
+ name=functest_utils.get_parameter_from_yaml(
+ "vnf.name", self.config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "vnf.version", self.config_file),
)
self.__logger.debug("VNF configuration: %s", self.vnf)
self.details['test_vnf'] = dict(
- name=get_config("vnf_test_suite.name", self.config_file),
- version=get_config("vnf_test_suite.version", self.config_file),
- tag_name=get_config("vnf_test_suite.tag_name", self.config_file)
+ name=functest_utils.get_parameter_from_yaml(
+ "vnf_test_suite.name", self.config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "vnf_test_suite.version", self.config_file),
+ tag_name=functest_utils.get_parameter_from_yaml(
+ "vnf_test_suite.tag_name", self.config_file)
)
self.res_dir = os.path.join(
@@ -393,29 +403,6 @@ class JujuEpc(singlevm.VmReady2):
super(JujuEpc, self).clean()
-# ----------------------------------------------------------
-#
-# YAML UTILS
-#
-# -----------------------------------------------------------
-def get_config(parameter, file_path):
- """
- Returns the value of a given parameter in file.yaml
- parameter must be given in string format with dots
- Example: general.openstack.image_name
- """
- with open(file_path) as config_file:
- file_yaml = yaml.safe_load(config_file)
- config_file.close()
- value = file_yaml
- for element in parameter.split("."):
- value = value.get(element)
- if value is None:
- raise ValueError("The parameter %s is not defined in"
- " reporting.yaml" % parameter)
- return value
-
-
def sig_test_format(sig_test):
"""
Process the signaling result to have a short result
diff --git a/functest/opnfv_tests/vnf/ims/clearwater.py b/functest/opnfv_tests/vnf/ims/clearwater.py
index 57857b563..cc4d4be04 100644
--- a/functest/opnfv_tests/vnf/ims/clearwater.py
+++ b/functest/opnfv_tests/vnf/ims/clearwater.py
@@ -46,9 +46,7 @@ class ClearwaterTesting(object):
self.ellis_ip = ellis_ip
- def availability_check_by_creating_numbers(self,
- signup_code='secret',
- two_numbers=False):
+ def availability_check(self, signup_code='secret', two_numbers=False):
"""Create one or two numbers"""
assert self.ellis_ip
output_dict = {}
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index 08699e4bb..bbb19694a 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -14,9 +14,7 @@ from __future__ import division
import logging
import os
import time
-import yaml
-from cloudify_rest_client.executions import Execution
import pkg_resources
import scp
import six
@@ -25,6 +23,7 @@ from functest.core import cloudify
from functest.opnfv_tests.vnf.ims import clearwater
from functest.utils import config
from functest.utils import env
+from functest.utils import functest_utils
__author__ = "Valentin Boucher <valentin.boucher@orange.com>"
@@ -63,26 +62,34 @@ class CloudifyIms(cloudify.Cloudify):
config_file = os.path.join(self.case_dir, self.config)
self.details['orchestrator'] = dict(
- name=get_config("orchestrator.name", config_file),
- version=get_config("orchestrator.version", config_file),
+ name=functest_utils.get_parameter_from_yaml(
+ "orchestrator.name", config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "orchestrator.version", config_file),
status='ERROR',
result=''
)
self.vnf = dict(
- descriptor=get_config("vnf.descriptor", config_file),
- inputs=get_config("vnf.inputs", config_file)
+ descriptor=functest_utils.get_parameter_from_yaml(
+ "vnf.descriptor", config_file),
+ inputs=functest_utils.get_parameter_from_yaml(
+ "vnf.inputs", config_file)
)
self.details['vnf'] = dict(
descriptor_version=self.vnf['descriptor']['version'],
- name=get_config("vnf.name", config_file),
- version=get_config("vnf.version", config_file),
+ name=functest_utils.get_parameter_from_yaml(
+ "vnf.name", config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "vnf.version", config_file),
)
self.__logger.debug("VNF configuration: %s", self.vnf)
self.details['test_vnf'] = dict(
- name=get_config("vnf_test_suite.name", config_file),
- version=get_config("vnf_test_suite.version", config_file)
+ name=functest_utils.get_parameter_from_yaml(
+ "vnf_test_suite.name", config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "vnf_test_suite.version", config_file)
)
self.image_alt = None
@@ -159,7 +166,7 @@ class CloudifyIms(cloudify.Cloudify):
network_name=self.network.name,
key_pair_name=self.keypair.name
))
- if (self.deploy_vnf() and self.test_vnf()):
+ if self.deploy_vnf() and self.test_vnf():
self.result = 100
return 0
self.result = 1/3 * 100
@@ -200,16 +207,16 @@ class CloudifyIms(cloudify.Cloudify):
descriptor.get('name'), descriptor.get('name'),
self.vnf.get('inputs'))
- wait_for_execution(
+ cloudify.wait_for_execution(
self.cfy_client,
- get_execution_id(self.cfy_client, descriptor.get('name')),
+ cloudify.get_execution_id(self.cfy_client, descriptor.get('name')),
self.__logger, timeout=300)
self.__logger.info("Start the VNF Instance deployment")
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, timeout=3600)
self.__logger.info(execution)
@@ -222,7 +229,7 @@ class CloudifyIms(cloudify.Cloudify):
self.vnf['descriptor'].get('name'))['outputs']['ellis_ip']
self.clearwater = clearwater.ClearwaterTesting(self.case_name,
ellis_ip)
- self.clearwater.availability_check_by_creating_numbers()
+ self.clearwater.availability_check()
self.details['vnf'].update(status='PASS',
duration=time.time() - start_time)
@@ -282,7 +289,8 @@ class CloudifyIms(cloudify.Cloudify):
parameters=dict(ignore_failure=True),
force=True)
- wait_for_execution(self.cfy_client, execution, self.__logger)
+ cloudify.wait_for_execution(
+ self.cfy_client, execution, self.__logger)
self.cfy_client.deployments.delete(
self.vnf['descriptor'].get('name'))
self.cfy_client.blueprints.delete(
@@ -294,92 +302,3 @@ class CloudifyIms(cloudify.Cloudify):
if self.flavor_alt:
self.orig_cloud.delete_flavor(self.flavor_alt.id)
super(CloudifyIms, self).clean()
-
-
-# ----------------------------------------------------------
-#
-# YAML UTILS
-#
-# -----------------------------------------------------------
-def get_config(parameter, file_path):
- """
- Get config parameter.
-
- Returns the value of a given parameter in file.yaml
- parameter must be given in string format with dots
- Example: general.openstack.image_name
- """
- with open(file_path) as config_file:
- file_yaml = yaml.safe_load(config_file)
- config_file.close()
- value = file_yaml
- for element in parameter.split("."):
- value = value.get(element)
- if value is None:
- raise ValueError("The parameter %s is not defined in"
- " reporting.yaml" % parameter)
- return value
-
-
-def wait_for_execution(client, execution, logger, timeout=3600, ):
- """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))
diff --git a/functest/opnfv_tests/vnf/ims/heat_ims.py b/functest/opnfv_tests/vnf/ims/heat_ims.py
index 3d32b889d..462fe7fee 100644
--- a/functest/opnfv_tests/vnf/ims/heat_ims.py
+++ b/functest/opnfv_tests/vnf/ims/heat_ims.py
@@ -15,7 +15,6 @@ import logging
import os
import re
import time
-import yaml
import pkg_resources
from xtesting.core import testcase
@@ -24,6 +23,7 @@ from functest.core import singlevm
from functest.opnfv_tests.vnf.ims import clearwater
from functest.utils import config
from functest.utils import env
+from functest.utils import functest_utils
__author__ = "Valentin Boucher <valentin.boucher@kontron.com>"
@@ -63,13 +63,17 @@ class HeatIms(singlevm.VmReady2):
config_file = os.path.join(self.case_dir, self.config)
self.vnf = dict(
- descriptor=get_config("vnf.descriptor", config_file),
- parameters=get_config("vnf.inputs", config_file)
+ descriptor=functest_utils.get_parameter_from_yaml(
+ "vnf.descriptor", config_file),
+ parameters=functest_utils.get_parameter_from_yaml(
+ "vnf.inputs", config_file)
)
self.details['vnf'] = dict(
descriptor_version=self.vnf['descriptor']['version'],
- name=get_config("vnf.name", config_file),
- version=get_config("vnf.version", config_file),
+ name=functest_utils.get_parameter_from_yaml(
+ "vnf.name", config_file),
+ version=functest_utils.get_parameter_from_yaml(
+ "vnf.version", config_file),
)
self.__logger.debug("VNF configuration: %s", self.vnf)
self.keypair = None
@@ -99,7 +103,7 @@ class HeatIms(singlevm.VmReady2):
'{}-kp_{}'.format(self.case_name, self.guid))
self.__logger.debug("keypair: %s", self.keypair)
- if (self.deploy_vnf() and self.test_vnf()):
+ if self.deploy_vnf() and self.test_vnf():
self.result = 100
return 0
self.result = 1/3 * 100
@@ -169,7 +173,7 @@ class HeatIms(singlevm.VmReady2):
# an infrastructure orchestrator so when Heat say "stack created"
# it means that all OpenStack ressources are created but not that
# Clearwater are up and ready (Cloud-Init script still running)
- self.clearwater.availability_check_by_creating_numbers()
+ self.clearwater.availability_check()
duration = time.time() - start_time
@@ -225,28 +229,3 @@ class HeatIms(singlevm.VmReady2):
super(HeatIms, self).clean()
if self.role:
self.orig_cloud.delete_role(self.role.id)
-
-
-# ----------------------------------------------------------
-#
-# YAML UTILS
-#
-# -----------------------------------------------------------
-def get_config(parameter, file_path):
- """
- Get config parameter.
-
- Returns the value of a given parameter in file.yaml
- parameter must be given in string format with dots
- Example: general.openstack.image_name
- """
- with open(file_path) as config_file:
- file_yaml = yaml.safe_load(config_file)
- config_file.close()
- value = file_yaml
- for element in parameter.split("."):
- value = value.get(element)
- if value is None:
- raise ValueError("The parameter %s is not defined in"
- " reporting.yaml" % parameter)
- return value
diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
index e8c8632bd..a0145b801 100644
--- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
+++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
@@ -15,7 +15,6 @@ import logging
import os
import time
-from cloudify_rest_client.executions import Execution
import pkg_resources
import scp
@@ -181,8 +180,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 +189,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
@@ -237,7 +236,8 @@ class CloudifyVrouter(cloudify.Cloudify):
execution = self.cfy_client.executions.start(
dep_name, 'uninstall', parameters=dict(ignore_failure=True))
- wait_for_execution(self.cfy_client, execution, self.__logger)
+ cloudify.wait_for_execution(
+ self.cfy_client, execution, self.__logger)
self.cfy_client.deployments.delete(
self.vnf['descriptor'].get('name'))
self.cfy_client.blueprints.delete(
@@ -249,63 +249,3 @@ class CloudifyVrouter(cloudify.Cloudify):
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))