From 107e61635c2ab1feb5263380ea63e21cf2e6e65b Mon Sep 17 00:00:00 2001 From: Morgan Richomme Date: Tue, 8 Nov 2016 14:18:12 +0100 Subject: Repo structure modification - create functest subdirectory - rename unit tests - adapt path in exec and config files JIRA: FUNCTEST-525 Change-Id: Ifd5c6edfb5bda1b09f82848e2269ad5fbeb84d0a Signed-off-by: Morgan Richomme --- testcases/vnf/vIMS/clearwater.py | 66 ----- testcases/vnf/vIMS/create_venv.sh | 44 --- testcases/vnf/vIMS/orchestrator.py | 234 ---------------- testcases/vnf/vIMS/requirements.pip | 1 - testcases/vnf/vIMS/vIMS.py | 536 ------------------------------------ testcases/vnf/vRNC/parser.py | 71 ----- 6 files changed, 952 deletions(-) delete mode 100644 testcases/vnf/vIMS/clearwater.py delete mode 100755 testcases/vnf/vIMS/create_venv.sh delete mode 100644 testcases/vnf/vIMS/orchestrator.py delete mode 100644 testcases/vnf/vIMS/requirements.pip delete mode 100755 testcases/vnf/vIMS/vIMS.py delete mode 100755 testcases/vnf/vRNC/parser.py (limited to 'testcases/vnf') diff --git a/testcases/vnf/vIMS/clearwater.py b/testcases/vnf/vIMS/clearwater.py deleted file mode 100644 index 7236f4fba..000000000 --- a/testcases/vnf/vIMS/clearwater.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python -# coding: utf8 -####################################################################### -# -# Copyright (c) 2015 Orange -# valentin.boucher@orange.com -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -######################################################################## - - -class clearwater: - - def __init__(self, inputs={}, orchestrator=None, logger=None): - self.config = inputs - self.orchestrator = orchestrator - self.logger = logger - self.deploy = False - - def set_orchestrator(self, orchestrator): - self.orchestrator = orchestrator - - def set_flavor_id(self, flavor_id): - self.config['flavor_id'] = flavor_id - - def set_image_id(self, image_id): - self.config['image_id'] = image_id - - def set_agent_user(self, agent_user): - self.config['agent_user'] = agent_user - - def set_external_network_name(self, external_network_name): - self.config['external_network_name'] = external_network_name - - def set_public_domain(self, public_domain): - self.config['public_domain'] = public_domain - - def deploy_vnf(self, blueprint, bp_name='clearwater', - dep_name='clearwater-opnfv'): - if self.orchestrator: - self.dep_name = dep_name - error = self.orchestrator.download_upload_and_deploy_blueprint( - blueprint, self.config, bp_name, dep_name) - if error: - return error - - self.deploy = True - - else: - if self.logger: - self.logger.error("Cloudify manager is down or not provide...") - - def undeploy_vnf(self): - if self.orchestrator: - if self.deploy: - self.deploy = False - self.orchestrator.undeploy_deployment(self.dep_name) - else: - if self.logger: - self.logger.error("Clearwater isn't already deploy...") - else: - if self.logger: - self.logger.error("Cloudify manager is down or not provide...") diff --git a/testcases/vnf/vIMS/create_venv.sh b/testcases/vnf/vIMS/create_venv.sh deleted file mode 100755 index 575fd177c..000000000 --- a/testcases/vnf/vIMS/create_venv.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -e - -# Script checks that venv exists. If it doesn't it will be created -# It requires python2.7 and virtualenv packages installed -# -# Copyright (c) 2015 Orange -# valentin.boucher@orange.com -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 - -BASEDIR=`dirname $0` -VENV_PATH=$1 -VENV_NAME="venv_cloudify" -function venv_install() { - if command -v virtualenv-2.7; then - virtualenv-2.7 $1 - elif command -v virtualenv2; then - virtualenv2 $1 - elif command -v virtualenv; then - virtualenv $1 - else - echo Cannot find virtualenv command. - return 1 - fi -} - -# exit when something goes wrong during venv install -set -e -if [ ! -d "$VENV_PATH/$VENV_NAME" ]; then - venv_install $VENV_PATH/$VENV_NAME - echo "Virtualenv" + $VENV_NAME + "created." -fi - -if [ ! -f "$VENV_PATH/$VENV_NAME/updated" -o $BASEDIR/requirements.pip -nt $VENV_PATH/$VENV_NAME/updated ]; then - source $VENV_PATH/$VENV_NAME/bin/activate - pip install -r $BASEDIR/requirements.pip - touch $VENV_PATH/$VENV_NAME/updated - echo "Requirements installed." - deactivate -fi -set +e diff --git a/testcases/vnf/vIMS/orchestrator.py b/testcases/vnf/vIMS/orchestrator.py deleted file mode 100644 index 61157a4fb..000000000 --- a/testcases/vnf/vIMS/orchestrator.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/python -# coding: utf8 -####################################################################### -# -# Copyright (c) 2015 Orange -# valentin.boucher@orange.com -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -######################################################################## - -import os -import shutil -import subprocess32 as subprocess -import yaml - -from git import Repo - -import functest.utils.functest_logger as ft_logger - - -class orchestrator: - - def __init__(self, testcase_dir, inputs={}): - self.testcase_dir = testcase_dir - self.blueprint_dir = testcase_dir + 'cloudify-manager-blueprint/' - self.input_file = 'inputs.yaml' - self.manager_blueprint = False - self.config = inputs - self.logger = ft_logger.Logger("Orchestrator").getLogger() - self.manager_up = False - - def set_credentials(self, username, password, tenant_name, auth_url): - self.config['keystone_username'] = username - self.config['keystone_password'] = password - self.config['keystone_url'] = auth_url - self.config['keystone_tenant_name'] = tenant_name - - def set_flavor_id(self, flavor_id): - self.config['flavor_id'] = flavor_id - - def set_image_id(self, image_id): - self.config['image_id'] = image_id - - def set_external_network_name(self, external_network_name): - self.config['external_network_name'] = external_network_name - - def set_ssh_user(self, ssh_user): - self.config['ssh_user'] = ssh_user - - def set_nova_url(self, nova_url): - self.config['nova_url'] = nova_url - - def set_neutron_url(self, neutron_url): - self.config['neutron_url'] = neutron_url - - def set_nameservers(self, nameservers): - if 0 < len(nameservers): - self.config['dns_subnet_1'] = nameservers[0] - - def download_manager_blueprint(self, manager_blueprint_url, - manager_blueprint_branch): - if self.manager_blueprint: - self.logger.info( - "cloudify manager server blueprint is " - "already downloaded !") - else: - self.logger.info( - "Downloading the cloudify manager server blueprint") - download_result = self._download_blueprints( - manager_blueprint_url, - manager_blueprint_branch, - self.blueprint_dir) - - if not download_result: - self.logger.error("Failed to download manager blueprint") - exit(-1) - else: - self.manager_blueprint = True - - def manager_up(self): - return self.manager_up - - def deploy_manager(self): - if self.manager_blueprint: - self.logger.info("Writing the inputs file") - with open(self.blueprint_dir + "inputs.yaml", "w") as f: - f.write(yaml.dump(self.config, default_style='"')) - f.close() - - # Ensure no ssh key file already exists - key_files = ["/.ssh/cloudify-manager-kp.pem", - "/.ssh/cloudify-agent-kp.pem"] - home = os.path.expanduser("~") - - for key_file in key_files: - if os.path.isfile(home + key_file): - os.remove(home + key_file) - - self.logger.info("Launching the cloudify-manager deployment") - script = "set -e; " - script += ("source " + self.testcase_dir + - "venv_cloudify/bin/activate; ") - script += "cd " + self.testcase_dir + "; " - script += "cfy init -r; " - script += "cd cloudify-manager-blueprint; " - script += ("cfy local create-requirements -o requirements.txt " + - "-p openstack-manager-blueprint.yaml; ") - script += "pip install -r requirements.txt; " - script += ("cfy bootstrap --install-plugins " + - "-p openstack-manager-blueprint.yaml -i inputs.yaml; ") - cmd = "/bin/bash -c '" + script + "'" - error = execute_command(cmd, self.logger) - if error: - return error - - self.logger.info("Cloudify-manager server is UP !") - - self.manager_up = True - - def undeploy_manager(self): - self.logger.info("Launching the cloudify-manager undeployment") - - self.manager_up = False - - script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; " - script += "cd " + self.testcase_dir + "; " - script += "cfy teardown -f --ignore-deployments; " - cmd = "/bin/bash -c '" + script + "'" - execute_command(cmd, self.logger) - - self.logger.info( - "Cloudify-manager server has been successfully removed!") - - def download_upload_and_deploy_blueprint(self, blueprint, config, - bp_name, dep_name): - self.logger.info("Downloading the {0} blueprint".format( - blueprint['file_name'])) - destination_folder = self.testcase_dir + \ - blueprint['destination_folder'] - download_result = self._download_blueprints(blueprint['url'], - blueprint['branch'], - destination_folder) - - if not download_result: - self.logger.error( - "Failed to download blueprint {0}". - format(blueprint['file_name'])) - exit(-1) - - self.logger.info("Writing the inputs file") - - with open(self.testcase_dir + blueprint['destination_folder'] + - "/inputs.yaml", "w") as f: - f.write(yaml.dump(config, default_style='"')) - f.close() - - self.logger.info("Launching the {0} deployment".format(bp_name)) - script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; " - script += ("cd " + self.testcase_dir + - blueprint['destination_folder'] + "; ") - script += ("cfy blueprints upload -b " + - bp_name + " -p openstack-blueprint.yaml; ") - script += ("cfy deployments create -b " + bp_name + - " -d " + dep_name + " --inputs inputs.yaml; ") - script += ("cfy executions start -w install -d " + - dep_name + " --timeout 1800; ") - - cmd = "/bin/bash -c '" + script + "'" - error = execute_command(cmd, self.logger, 2000) - if error: - return error - self.logger.info("The deployment of {0} is ended".format(dep_name)) - - def undeploy_deployment(self, dep_name): - self.logger.info("Launching the {0} undeployment".format(dep_name)) - script = "source " + self.testcase_dir + "venv_cloudify/bin/activate; " - script += "cd " + self.testcase_dir + "; " - script += ("cfy executions start -w uninstall -d " + dep_name + - " --timeout 1800 ; ") - script += "cfy deployments delete -d " + dep_name + "; " - - cmd = "/bin/bash -c '" + script + "'" - try: - execute_command(cmd, self.logger) - except: - self.logger.error("Clearwater undeployment failed") - - def _download_blueprints(self, blueprint_url, branch, dest_path): - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - try: - Repo.clone_from(blueprint_url, dest_path, branch=branch) - return True - except: - return False - - -def execute_command(cmd, logger, timeout=1800): - """ - Execute Linux command - """ - if logger: - logger.debug('Executing command : {}'.format(cmd)) - timeout_exception = False - output_file = "output.txt" - f = open(output_file, 'w+') - try: - p = subprocess.call(cmd, shell=True, stdout=f, - stderr=subprocess.STDOUT, timeout=timeout) - except subprocess.TimeoutExpired: - timeout_exception = True - if logger: - logger.error("TIMEOUT when executing command %s" % cmd) - pass - - f.close() - f = open(output_file, 'r') - result = f.read() - if result != "" and logger: - logger.debug(result) - if p == 0: - return False - else: - if logger and not timeout_exception: - logger.error("Error when executing command %s" % cmd) - f = open(output_file, 'r') - lines = f.readlines() - result = lines[len(lines) - 3] - result += lines[len(lines) - 2] - result += lines[len(lines) - 1] - return result diff --git a/testcases/vnf/vIMS/requirements.pip b/testcases/vnf/vIMS/requirements.pip deleted file mode 100644 index ab26f6e02..000000000 --- a/testcases/vnf/vIMS/requirements.pip +++ /dev/null @@ -1 +0,0 @@ -cloudify==3.3.1 \ No newline at end of file diff --git a/testcases/vnf/vIMS/vIMS.py b/testcases/vnf/vIMS/vIMS.py deleted file mode 100755 index 50aa715f4..000000000 --- a/testcases/vnf/vIMS/vIMS.py +++ /dev/null @@ -1,536 +0,0 @@ -#!/usr/bin/python -# coding: utf8 -####################################################################### -# -# Copyright (c) 2015 Orange -# valentin.boucher@orange.com -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -######################################################################## - -import datetime -import json -import os -import pprint -import subprocess -import time - -import argparse -import keystoneclient.v2_0.client as ksclient -import novaclient.client as nvclient -import requests -from neutronclient.v2_0 import client as ntclient - -import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as ft_utils -import functest.utils.openstack_utils as os_utils -from clearwater import clearwater -from orchestrator import orchestrator - -pp = pprint.PrettyPrinter(indent=4) - - -parser = argparse.ArgumentParser() -parser.add_argument("-d", "--debug", help="Debug mode", action="store_true") -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") -parser.add_argument("-n", "--noclean", - help="Don't clean the created resources for this test.", - action="store_true") -args = parser.parse_args() - -""" logging configuration """ -logger = ft_logger.Logger("vIMS").getLogger() - - -# Cloudify parameters -VIMS_DIR = ft_utils.FUNCTEST_REPO + '/' + \ - ft_utils.get_functest_config('general.directories.dir_vIMS') - -VIMS_DATA_DIR = \ - ft_utils.get_functest_config('general.directories.dir_vIMS_data') + \ - '/' -VIMS_TEST_DIR = \ - ft_utils.get_functest_config('general.directories.dir_repo_vims_test') + \ - '/' -DB_URL = \ - ft_utils.get_functest_config('results.test_db_url') - -TENANT_NAME = \ - ft_utils.get_functest_config('vIMS.general.tenant_name') -TENANT_DESCRIPTION = \ - ft_utils.get_functest_config('vIMS.general.tenant_description') -IMAGES = \ - ft_utils.get_functest_config('vIMS.general.images') - -CFY_MANAGER_BLUEPRINT = \ - ft_utils.get_functest_config('vIMS.cloudify.blueprint') -CFY_MANAGER_REQUIERMENTS = \ - ft_utils.get_functest_config('vIMS.cloudify.requierments') -CFY_INPUTS = ft_utils.get_functest_config('vIMS.cloudify.inputs') - -CW_BLUEPRINT = \ - ft_utils.get_functest_config('vIMS.clearwater.blueprint') -CW_DEPLOYMENT_NAME = \ - ft_utils.get_functest_config('vIMS.clearwater.deployment-name') -CW_INPUTS = \ - ft_utils.get_functest_config('vIMS.clearwater.inputs') -CW_REQUIERMENTS = \ - ft_utils.get_functest_config('vIMS.clearwater.requierments') - -CFY_DEPLOYMENT_DURATION = 0 -CW_DEPLOYMENT_DURATION = 0 - -TESTCASE_START_TIME = time.time() -RESULTS = {'orchestrator': {'duration': 0, 'result': ''}, - 'vIMS': {'duration': 0, 'result': ''}, - 'sig_test': {'duration': 0, 'result': ''}} - - -def download_and_add_image_on_glance(glance, image_name, image_url): - dest_path = VIMS_DATA_DIR + "tmp/" - if not os.path.exists(dest_path): - os.makedirs(dest_path) - file_name = image_url.rsplit('/')[-1] - if not ft_utils.download_url(image_url, dest_path): - logger.error("Failed to download image %s" % file_name) - return False - - image = os_utils.create_glance_image( - glance, image_name, dest_path + file_name) - if not image: - logger.error("Failed to upload image on glance") - return False - - return image - - -def step_failure(step_name, error_msg): - logger.error(error_msg) - set_result(step_name, 0, error_msg) - status = "FAIL" - # in case of failure starting and stoping time are not correct - stop_time = time.time() - if step_name == "sig_test": - status = "PASS" - ft_utils.push_results_to_db("functest", - "vims", - TESTCASE_START_TIME, - stop_time, - status, - RESULTS) - exit(-1) - - -def set_result(step_name, duration=0, result=""): - RESULTS[step_name] = {'duration': duration, 'result': result} - - -def test_clearwater(): - script = "source " + VIMS_DATA_DIR + "venv_cloudify/bin/activate; " - script += "cd " + VIMS_DATA_DIR + "; " - script += "cfy status | grep -Eo \"([0-9]{1,3}\.){3}[0-9]{1,3}\"" - cmd = "/bin/bash -c '" + script + "'" - - try: - logger.debug("Trying to get clearwater manager IP ... ") - mgr_ip = os.popen(cmd).read() - mgr_ip = mgr_ip.splitlines()[0] - except: - step_failure("sig_test", "Unable to retrieve the IP of the " - "cloudify manager server !") - - api_url = "http://" + mgr_ip + "/api/v2" - dep_outputs = requests.get(api_url + "/deployments/" + - CW_DEPLOYMENT_NAME + "/outputs") - dns_ip = dep_outputs.json()['outputs']['dns_ip'] - ellis_ip = dep_outputs.json()['outputs']['ellis_ip'] - - ellis_url = "http://" + ellis_ip + "/" - url = ellis_url + "accounts" - - params = {"password": "functest", - "full_name": "opnfv functest user", - "email": "functest@opnfv.fr", - "signup_code": "secret"} - - rq = requests.post(url, data=params) - i = 20 - while rq.status_code != 201 and i > 0: - rq = requests.post(url, data=params) - i = i - 1 - time.sleep(10) - - if rq.status_code == 201: - url = ellis_url + "session" - rq = requests.post(url, data=params) - cookies = rq.cookies - - url = ellis_url + "accounts/" + params['email'] + "/numbers" - if cookies != "": - rq = requests.post(url, cookies=cookies) - i = 24 - while rq.status_code != 200 and i > 0: - rq = requests.post(url, cookies=cookies) - i = i - 1 - time.sleep(25) - - if rq.status_code != 200: - step_failure("sig_test", "Unable to create a number: %s" - % rq.json()['reason']) - - start_time_ts = time.time() - end_time_ts = start_time_ts - logger.info("vIMS functional test Start Time:'%s'" % ( - datetime.datetime.fromtimestamp(start_time_ts).strftime( - '%Y-%m-%d %H:%M:%S'))) - nameservers = ft_utils.get_resolvconf_ns() - resolvconf = "" - for ns in nameservers: - resolvconf += "\nnameserver " + ns - - if dns_ip != "": - script = ('echo -e "nameserver ' + dns_ip + resolvconf + - '" > /etc/resolv.conf; ') - script += 'source /etc/profile.d/rvm.sh; ' - script += 'cd ' + VIMS_TEST_DIR + '; ' - script += ('rake test[' + CW_INPUTS["public_domain"] + - '] SIGNUP_CODE="secret"') - - cmd = "/bin/bash -c '" + script + "'" - output_file = "output.txt" - f = open(output_file, 'w+') - subprocess.call(cmd, shell=True, stdout=f, - stderr=subprocess.STDOUT) - f.close() - end_time_ts = time.time() - duration = round(end_time_ts - start_time_ts, 1) - logger.info("vIMS functional test duration:'%s'" % duration) - f = open(output_file, 'r') - result = f.read() - if result != "" and logger: - logger.debug(result) - - vims_test_result = "" - try: - logger.debug("Trying to load test results") - with open(VIMS_TEST_DIR + "temp.json") as f: - vims_test_result = json.load(f) - f.close() - except: - logger.error("Unable to retrieve test results") - - set_result("sig_test", duration, vims_test_result) - - # success criteria for vIMS (for Brahmaputra) - # - orchestrator deployed - # - VNF deployed - # TODO use test criteria defined in config file - status = "FAIL" - try: - if (RESULTS['orchestrator']['duration'] > 0 and - RESULTS['vIMS']['duration'] > 0): - status = "PASS" - except: - logger.error("Unable to set test status") - - ft_utils.push_results_to_db("functest", - "vims", - TESTCASE_START_TIME, - end_time_ts, - status, - RESULTS) - - try: - os.remove(VIMS_TEST_DIR + "temp.json") - except: - logger.error("Deleting file failed") - - -def main(): - - # ############### GENERAL INITIALISATION ################ - - if not os.path.exists(VIMS_DATA_DIR): - os.makedirs(VIMS_DATA_DIR) - - ks_creds = os_utils.get_credentials("keystone") - nv_creds = os_utils.get_credentials("nova") - nt_creds = os_utils.get_credentials("neutron") - - logger.info("Prepare OpenStack plateform (create tenant and user)") - keystone = ksclient.Client(**ks_creds) - - user_id = os_utils.get_user_id(keystone, ks_creds['username']) - if user_id == '': - step_failure("init", "Error : Failed to get id of " + - ks_creds['username']) - - tenant_id = os_utils.create_tenant( - keystone, TENANT_NAME, TENANT_DESCRIPTION) - if not tenant_id: - step_failure("init", "Error : Failed to create " + - TENANT_NAME + " tenant") - - roles_name = ["admin", "Admin"] - role_id = '' - for role_name in roles_name: - if role_id == '': - role_id = os_utils.get_role_id(keystone, role_name) - - if role_id == '': - logger.error("Error : Failed to get id for %s role" % role_name) - - if not os_utils.add_role_user(keystone, user_id, role_id, tenant_id): - logger.error("Error : Failed to add %s on tenant" % - ks_creds['username']) - - user_id = os_utils.create_user( - keystone, TENANT_NAME, TENANT_NAME, None, tenant_id) - if not user_id: - logger.error("Error : Failed to create %s user" % TENANT_NAME) - - logger.info("Update OpenStack creds informations") - ks_creds.update({ - "username": TENANT_NAME, - "password": TENANT_NAME, - "tenant_name": TENANT_NAME, - }) - - nt_creds.update({ - "tenant_name": TENANT_NAME, - }) - - nv_creds.update({ - "project_id": TENANT_NAME, - }) - - logger.info("Upload some OS images if it doesn't exist") - glance = os_utils.get_glance_client() - - for img in IMAGES.keys(): - image_name = IMAGES[img]['image_name'] - image_url = IMAGES[img]['image_url'] - - image_id = os_utils.get_image_id(glance, image_name) - - if image_id == '': - logger.info("""%s image doesn't exist on glance repository. Try - downloading this image and upload on glance !""" % image_name) - image_id = download_and_add_image_on_glance( - glance, image_name, image_url) - - if image_id == '': - step_failure( - "init", - "Error : Failed to find or upload required OS " - "image for this deployment") - - nova = nvclient.Client("2", **nv_creds) - - logger.info("Update security group quota for this tenant") - neutron = ntclient.Client(**nt_creds) - if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100): - step_failure( - "init", - "Failed to update security group quota for tenant " + TENANT_NAME) - - # ############### CLOUDIFY INITIALISATION ################ - public_auth_url = keystone.service_catalog.url_for( - service_type='identity', endpoint_type='publicURL') - - cfy = orchestrator(VIMS_DATA_DIR, CFY_INPUTS) - - cfy.set_credentials(username=ks_creds['username'], password=ks_creds[ - 'password'], tenant_name=ks_creds['tenant_name'], - auth_url=public_auth_url) - - logger.info("Collect flavor id for cloudify manager server") - nova = nvclient.Client("2", **nv_creds) - - flavor_name = "m1.large" - flavor_id = os_utils.get_flavor_id(nova, flavor_name) - for requirement in CFY_MANAGER_REQUIERMENTS: - if requirement == 'ram_min': - flavor_id = os_utils.get_flavor_id_by_ram_range( - nova, CFY_MANAGER_REQUIERMENTS['ram_min'], 10000) - - if flavor_id == '': - logger.error( - "Failed to find %s flavor. " - "Try with ram range default requirement !" % flavor_name) - flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196) - - if flavor_id == '': - step_failure("orchestrator", - "Failed to find required flavor for this deployment") - - cfy.set_flavor_id(flavor_id) - - image_name = "centos_7" - image_id = os_utils.get_image_id(glance, image_name) - for requirement in CFY_MANAGER_REQUIERMENTS: - if requirement == 'os_image': - image_id = os_utils.get_image_id( - glance, CFY_MANAGER_REQUIERMENTS['os_image']) - - if image_id == '': - step_failure( - "orchestrator", - "Error : Failed to find required OS image for cloudify manager") - - cfy.set_image_id(image_id) - - ext_net = os_utils.get_external_net(neutron) - if not ext_net: - step_failure("orchestrator", "Failed to get external network") - - cfy.set_external_network_name(ext_net) - - ns = ft_utils.get_resolvconf_ns() - if ns: - cfy.set_nameservers(ns) - - if 'compute' in nova.client.services_url: - cfy.set_nova_url(nova.client.services_url['compute']) - if neutron.httpclient.endpoint_url is not None: - cfy.set_neutron_url(neutron.httpclient.endpoint_url) - - logger.info("Prepare virtualenv for cloudify-cli") - cmd = "chmod +x " + VIMS_DIR + "create_venv.sh" - ft_utils.execute_command(cmd) - time.sleep(3) - cmd = VIMS_DIR + "create_venv.sh " + VIMS_DATA_DIR - ft_utils.execute_command(cmd) - - cfy.download_manager_blueprint( - CFY_MANAGER_BLUEPRINT['url'], CFY_MANAGER_BLUEPRINT['branch']) - - # ############### CLOUDIFY DEPLOYMENT ################ - start_time_ts = time.time() - end_time_ts = start_time_ts - logger.info("Cloudify deployment Start Time:'%s'" % ( - datetime.datetime.fromtimestamp(start_time_ts).strftime( - '%Y-%m-%d %H:%M:%S'))) - - error = cfy.deploy_manager() - if error: - step_failure("orchestrator", error) - - end_time_ts = time.time() - duration = round(end_time_ts - start_time_ts, 1) - logger.info("Cloudify deployment duration:'%s'" % duration) - set_result("orchestrator", duration, "") - - # ############### CLEARWATER INITIALISATION ################ - - cw = clearwater(CW_INPUTS, cfy, logger) - - logger.info("Collect flavor id for all clearwater vm") - nova = nvclient.Client("2", **nv_creds) - - flavor_name = "m1.small" - flavor_id = os_utils.get_flavor_id(nova, flavor_name) - for requirement in CW_REQUIERMENTS: - if requirement == 'ram_min' and flavor_id == '': - flavor_id = os_utils.get_flavor_id_by_ram_range( - nova, CW_REQUIERMENTS['ram_min'], 4500) - - if flavor_id == '': - logger.error( - "Failed to find %s flavor. Try with ram range " - "default requirement !" % flavor_name) - flavor_id = os_utils.get_flavor_id_by_ram_range(nova, 4000, 8196) - - if flavor_id == '': - step_failure( - "vIMS", "Failed to find required flavor for this deployment") - - cw.set_flavor_id(flavor_id) - - image_name = "ubuntu_14.04" - image_id = os_utils.get_image_id(glance, image_name) - for requirement in CW_REQUIERMENTS: - if requirement == 'os_image': - image_id = os_utils.get_image_id( - glance, CW_REQUIERMENTS['os_image']) - - if image_id == '': - step_failure( - "vIMS", - "Error : Failed to find required OS image for cloudify manager") - - cw.set_image_id(image_id) - - ext_net = os_utils.get_external_net(neutron) - if not ext_net: - step_failure("vIMS", "Failed to get external network") - - cw.set_external_network_name(ext_net) - - # ############### CLEARWATER DEPLOYMENT ################ - - start_time_ts = time.time() - end_time_ts = start_time_ts - logger.info("vIMS VNF deployment Start Time:'%s'" % ( - datetime.datetime.fromtimestamp(start_time_ts).strftime( - '%Y-%m-%d %H:%M:%S'))) - - error = cw.deploy_vnf(CW_BLUEPRINT) - if error: - step_failure("vIMS", error) - - end_time_ts = time.time() - duration = round(end_time_ts - start_time_ts, 1) - logger.info("vIMS VNF deployment duration:'%s'" % duration) - set_result("vIMS", duration, "") - - # ############### CLEARWATER TEST ################ - - test_clearwater() - - # ########## CLEARWATER UNDEPLOYMENT ############ - - cw.undeploy_vnf() - - # ########### CLOUDIFY UNDEPLOYMENT ############# - - cfy.undeploy_manager() - - # ############## GENERAL CLEANUP ################ - if args.noclean: - exit(0) - - ks_creds = os_utils.get_credentials("keystone") - - keystone = ksclient.Client(**ks_creds) - - logger.info("Removing %s tenant .." % CFY_INPUTS['keystone_tenant_name']) - tenant_id = os_utils.get_tenant_id( - keystone, CFY_INPUTS['keystone_tenant_name']) - if tenant_id == '': - logger.error("Error : Failed to get id of %s tenant" % - CFY_INPUTS['keystone_tenant_name']) - else: - if not os_utils.delete_tenant(keystone, tenant_id): - logger.error("Error : Failed to remove %s tenant" % - CFY_INPUTS['keystone_tenant_name']) - - logger.info("Removing %s user .." % CFY_INPUTS['keystone_username']) - user_id = os_utils.get_user_id( - keystone, CFY_INPUTS['keystone_username']) - if user_id == '': - logger.error("Error : Failed to get id of %s user" % - CFY_INPUTS['keystone_username']) - else: - if not os_utils.delete_user(keystone, user_id): - logger.error("Error : Failed to remove %s user" % - CFY_INPUTS['keystone_username']) - - -if __name__ == '__main__': - main() diff --git a/testcases/vnf/vRNC/parser.py b/testcases/vnf/vRNC/parser.py deleted file mode 100755 index 0381fd648..000000000 --- a/testcases/vnf/vRNC/parser.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 ZTE Corporation -# -# 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 argparse -import time - -import functest.utils.functest_logger as ft_logger -import functest.utils.functest_utils as functest_utils - - -parser = argparse.ArgumentParser() -parser.add_argument("-r", "--report", - help="Create json result file", - action="store_true") -args = parser.parse_args() - -PARSER_REPO = \ - functest_utils.get_functest_config('general.directories.dir_repo_parser') -RESULTS_DIR = \ - functest_utils.get_functest_config('general.directories.dir_results') - -logger = ft_logger.Logger("parser").getLogger() - - -def main(): - project = 'parser' - case_name = 'parser-basics' - cmd = 'cd %s/tests && ./functest_run.sh' % PARSER_REPO - - start_time = time.time() - log_file = RESULTS_DIR + "/parser.log" - ret = functest_utils.execute_command(cmd, - info=True, - output_file=log_file) - stop_time = time.time() - - status, details = functest_utils.check_test_result(project, - ret, - start_time, - stop_time) - - functest_utils.logger_test_results(project, - case_name, - status, - details) - - if args.report: - logger.debug("Report Parser Results to DB......") - functest_utils.push_results_to_db(project, - case_name, - start_time, - stop_time, - status, - details) - exit(ret) - -if __name__ == '__main__': - main() -- cgit 1.2.3-korg