diff options
25 files changed, 442 insertions, 232 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile index 2cbee665..8c7e4b0f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -51,7 +51,9 @@ python-dev \ python-mock \ python-pip \ postgresql \ -ruby1.9.1-dev \ +ruby \ +ruby-dev \ +ruby-bundler \ ssh \ sshpass \ wget \ @@ -89,13 +91,10 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds /src/fds # other repositories RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git /src/odl_test -RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_VNFS_DIR}/vims-test +RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test /src/vims-test RUN git clone --depth 1 -b $VROUTER_TAG https://github.com/oolorg/opnfv-functest-vrouter.git ${REPOS_VNFS_DIR}/vrouter RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos -RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 -RUN curl -L https://get.rvm.io | bash -s stable - # SFC integration RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/setup_scripts/tacker_client_install.sh" @@ -103,18 +102,7 @@ RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/se RUN ln -s /src/tempest /src/refstack-client/.tempest \ && virtualenv --system-site-packages /src/tempest/.venv -RUN /bin/bash -c ". /etc/profile.d/rvm.sh \ - && cd ${REPOS_VNFS_DIR}/vims-test \ - && rvm autolibs enable" -RUN /bin/bash -c ". /etc/profile.d/rvm.sh \ - && cd ${REPOS_VNFS_DIR}/vims-test \ - && rvm install 1.9.3" -RUN /bin/bash -c ". /etc/profile.d/rvm.sh \ - && cd ${REPOS_VNFS_DIR}/vims-test \ - && rvm use 1.9.3" -RUN /bin/bash -c ". /etc/profile.d/rvm.sh \ - && cd ${REPOS_VNFS_DIR}/vims-test \ - && bundle install" +RUN cd /src/vims-test && bundle install RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' \ && sudo apt-get install -y nodejs \ diff --git a/docker/thirdparty-requirements.txt b/docker/thirdparty-requirements.txt index 84521f23..773af758 100644 --- a/docker/thirdparty-requirements.txt +++ b/docker/thirdparty-requirements.txt @@ -1,6 +1,5 @@ baro_tests sdnvpn -opera securityscanning sfc promise diff --git a/docker/vnf/Dockerfile b/docker/vnf/Dockerfile new file mode 100644 index 00000000..70c13ab2 --- /dev/null +++ b/docker/vnf/Dockerfile @@ -0,0 +1,12 @@ +FROM opnfv/functest-core + +ARG VIMS_TAG=stable + +RUN apk --no-cache add --update \ + ruby ruby-dev ruby-bundler ruby-irb ruby-rdoc \ + procps git g++ make libxslt-dev libxml2-dev zlib-dev libffi-dev && \ + git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test /src/vims-test && \ + rm -r /src/vims-test/.git && \ + cd /src/vims-test && bundle config build.nokogiri --use-system-libraries && bundle install --system +COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml +CMD ["bash","-c","prepare_env start && run_tests -t all"] diff --git a/docker/vnf/hooks/post_checkout b/docker/vnf/hooks/post_checkout new file mode 100644 index 00000000..20a6d4b9 --- /dev/null +++ b/docker/vnf/hooks/post_checkout @@ -0,0 +1,6 @@ +#!/bin/bash + +from="${DOCKER_REPO%/*}/functest-core" +sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile + +exit $? diff --git a/docker/vnf/testcases.yaml b/docker/vnf/testcases.yaml new file mode 100644 index 00000000..1a42101e --- /dev/null +++ b/docker/vnf/testcases.yaml @@ -0,0 +1,65 @@ +tiers: + - + name: vnf + order: 4 + ci_loop: '(daily)|(weekly)' + description : >- + Collection of VNF test cases. + testcases: + - + case_name: cloudify_ims + project_name: functest + criteria: 100 + blocking: false + description: >- + This test case deploys an OpenSource vIMS solution from Clearwater + using the Cloudify orchestrator. It also runs some signaling traffic. + dependencies: + installer: '' + scenario: 'os-nosdn-nofeature-ha' + run: + module: 'functest.opnfv_tests.vnf.ims.cloudify_ims' + class: 'CloudifyIms' + + - + case_name: aaa + enabled: false + project_name: functest + criteria: 100 + blocking: false + description: >- + Simple VNF. + dependencies: + installer: '' + scenario: '' + run: + module: 'functest.opnfv_tests.vnf.aaa.aaa' + class: 'AaaVnf' + + - + case_name: orchestra_openims + project_name: functest + criteria: 100 + blocking: false + description: >- + OpenIMS VNF deployment with Open Baton (Orchestra) + dependencies: + installer: '' + scenario: 'os-nosdn-nofeature-ha' + run: + module: 'functest.opnfv_tests.vnf.ims.orchestra_openims' + class: 'OpenImsVnf' + + - + case_name: orchestra_clearwaterims + project_name: functest + criteria: 100 + blocking: false + description: >- + ClearwaterIMS VNF deployment with Open Baton (Orchestra) + dependencies: + installer: '' + scenario: 'os-nosdn-nofeature-ha' + run: + module: 'functest.opnfv_tests.vnf.ims.orchestra_clearwaterims' + class: 'ClearwaterImsVnf' diff --git a/functest/api/common/thread.py b/functest/api/common/thread.py new file mode 100644 index 00000000..fb60aaac --- /dev/null +++ b/functest/api/common/thread.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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 + +""" +Used to handle multi-thread tasks +""" + +import logging +import threading + +from oslo_serialization import jsonutils + + +LOGGER = logging.getLogger(__name__) + + +class TaskThread(threading.Thread): + """ Task Thread Class """ + + def __init__(self, target, args, handler): + super(TaskThread, self).__init__(target=target, args=args) + self.target = target + self.args = args + self.handler = handler + + def run(self): + """ Override the function run: run testcase and update database """ + update_data = {'task_id': self.args.get('task_id'), + 'status': 'IN PROGRESS'} + self.handler.insert(update_data) + + LOGGER.info('Starting running test case') + + try: + data = self.target(self.args) + except Exception as err: # pylint: disable=broad-except + LOGGER.exception('Task Failed') + update_data = {'status': 'FAIL', 'error': str(err)} + self.handler.update_attr(self.args.get('task_id'), update_data) + else: + LOGGER.info('Task Finished') + LOGGER.debug('Result: %s', data) + new_data = {'status': 'FINISHED', + 'result': jsonutils.dumps(data.get('result', {}))} + + self.handler.update_attr(self.args.get('task_id'), new_data) diff --git a/functest/api/database/__init__.py b/functest/api/database/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/functest/api/database/__init__.py diff --git a/functest/api/database/db.py b/functest/api/database/db.py new file mode 100644 index 00000000..ea861ddb --- /dev/null +++ b/functest/api/database/db.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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 + +""" +Create database to store task results using sqlalchemy +""" + +from sqlalchemy import create_engine +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import scoped_session, sessionmaker + + +SQLITE = 'sqlite:////tmp/functest.db' + +ENGINE = create_engine(SQLITE, convert_unicode=True) +DB_SESSION = scoped_session(sessionmaker(autocommit=False, + autoflush=False, + bind=ENGINE)) +BASE = declarative_base() +BASE.query = DB_SESSION.query_property() diff --git a/functest/api/database/v1/__init__.py b/functest/api/database/v1/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/functest/api/database/v1/__init__.py diff --git a/functest/api/database/v1/handlers.py b/functest/api/database/v1/handlers.py new file mode 100644 index 00000000..7bd286de --- /dev/null +++ b/functest/api/database/v1/handlers.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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 + +""" +Used to handle tasks: insert the task info into database and update it +""" + +from functest.api.database.db import DB_SESSION +from functest.api.database.v1.models import Tasks + + +class TasksHandler(object): + """ Tasks Handler Class """ + + def insert(self, kwargs): # pylint: disable=no-self-use + """ To insert the task info into database """ + task = Tasks(**kwargs) + DB_SESSION.add(task) # pylint: disable=maybe-no-member + DB_SESSION.commit() # pylint: disable=maybe-no-member + return task + + def get_task_by_taskid(self, task_id): # pylint: disable=no-self-use + """ Obtain the task by task id """ + # pylint: disable=maybe-no-member + task = Tasks.query.filter_by(task_id=task_id).first() + if not task: + raise ValueError + + return task + + def update_attr(self, task_id, attr): + """ Update the required attributes of the task """ + task = self.get_task_by_taskid(task_id) + + for key, value in attr.items(): + setattr(task, key, value) + DB_SESSION.commit() # pylint: disable=maybe-no-member diff --git a/functest/api/database/v1/models.py b/functest/api/database/v1/models.py new file mode 100644 index 00000000..c5de91bc --- /dev/null +++ b/functest/api/database/v1/models.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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 + +""" +Define tables for tasks +""" + +from sqlalchemy import Column +from sqlalchemy import Integer +from sqlalchemy import String +from sqlalchemy import Text + +from functest.api.database.db import BASE + + +class Tasks(BASE): # pylint: disable=too-few-public-methods, no-init + """ Create a table for tasks""" + + __tablename__ = 'tasks' + id = Column(Integer, primary_key=True) # pylint: disable=invalid-name + task_id = Column(String(50)) + status = Column(Integer) + error = Column(String(120)) + result = Column(Text) + + def __repr__(self): + return '<Task %r>' % Tasks.task_id diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py index 35bffb04..9c455198 100644 --- a/functest/api/resources/v1/envs.py +++ b/functest/api/resources/v1/envs.py @@ -14,6 +14,7 @@ from flask import jsonify from functest.api.base import ApiResource from functest.cli.commands.cli_env import Env +from functest.api.common import api_utils import functest.utils.functest_utils as ft_utils @@ -31,4 +32,9 @@ class V1Envs(ApiResource): def prepare(self, args): # pylint: disable=no-self-use, unused-argument """ Prepare environment """ - ft_utils.execute_command("prepare_env start") + try: + ft_utils.execute_command("prepare_env start") + except Exception as err: # pylint: disable=broad-except + return api_utils.result_handler(status=1, data=str(err)) + return api_utils.result_handler( + status=0, data="Prepare env successfully") diff --git a/functest/api/resources/v1/tasks.py b/functest/api/resources/v1/tasks.py new file mode 100644 index 00000000..7086e707 --- /dev/null +++ b/functest/api/resources/v1/tasks.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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 + +""" +Resources to retrieve the task results +""" + + +import json +import logging +import uuid + +from flask import jsonify + +from functest.api.base import ApiResource +from functest.api.common import api_utils +from functest.api.database.v1.handlers import TasksHandler + + +LOGGER = logging.getLogger(__name__) + + +class V1Tasks(ApiResource): + """ V1Tasks Resource class""" + + def get(self, task_id): # pylint: disable=no-self-use + """ GET the result of the task id """ + try: + uuid.UUID(task_id) + except ValueError: + return api_utils.result_handler(status=1, data='Invalid task id') + + task_handler = TasksHandler() + try: + task = task_handler.get_task_by_taskid(task_id) + except ValueError: + return api_utils.result_handler(status=1, data='No such task id') + + status = task.status + LOGGER.debug('Task status is: %s', status) + + if status not in ['IN PROGRESS', 'FAIL', 'FINISHED']: + return api_utils.result_handler(status=1, + data='internal server error') + if status == 'IN PROGRESS': + result = {'status': status, 'result': ''} + elif status == 'FAIL': + result = {'status': status, 'error': task.error} + else: + result = {'status': status, 'result': json.loads(task.result)} + + return jsonify(result) diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py index c3b8217a..f146c24c 100644 --- a/functest/api/resources/v1/testcases.py +++ b/functest/api/resources/v1/testcases.py @@ -11,11 +11,20 @@ Resources to handle testcase related requests """ +import os +import logging +import uuid + from flask import abort, jsonify from functest.api.base import ApiResource -from functest.api.common import api_utils +from functest.api.common import api_utils, thread from functest.cli.commands.cli_testcase import Testcase +from functest.api.database.v1.handlers import TasksHandler +from functest.utils.constants import CONST +import functest.utils.functest_utils as ft_utils + +LOGGER = logging.getLogger(__name__) class V1Testcases(ApiResource): @@ -46,3 +55,61 @@ class V1Testcase(ApiResource): result.update(testcase_info) result.update({'dependency': dependency_dict}) return jsonify(result) + + def post(self): + """ Used to handle post request """ + return self._dispatch_post() + + def run_test_case(self, args): + """ Run a testcase """ + try: + case_name = args['testcase'] + except KeyError: + return api_utils.result_handler( + status=1, data='testcase name must be provided') + + task_id = str(uuid.uuid4()) + + task_args = {'testcase': case_name, 'task_id': task_id} + + task_args.update(args.get('opts', {})) + + task_thread = thread.TaskThread(self._run, task_args, TasksHandler()) + task_thread.start() + + results = {'testcase': case_name, 'task_id': task_id} + return jsonify(results) + + def _run(self, args): # pylint: disable=no-self-use + """ The built_in function to run a test case """ + + case_name = args.get('testcase') + + if not os.path.isfile(CONST.__getattribute__('env_active')): + raise Exception("Functest environment is not ready.") + else: + try: + cmd = "run_tests -t {}".format(case_name) + runner = ft_utils.execute_command(cmd) + except Exception: # pylint: disable=broad-except + result = 'FAIL' + LOGGER.exception("Running test case %s failed!", case_name) + if runner == os.EX_OK: + result = 'PASS' + else: + result = 'FAIL' + + env_info = { + 'installer': CONST.__getattribute__('INSTALLER_TYPE'), + 'scenario': CONST.__getattribute__('DEPLOY_SCENARIO'), + 'build_tag': CONST.__getattribute__('BUILD_TAG'), + 'ci_loop': CONST.__getattribute__('CI_LOOP') + } + result = { + 'task_id': args.get('task_id'), + 'case_name': case_name, + 'env_info': env_info, + 'result': result + } + + return {'result': result} diff --git a/functest/api/server.py b/functest/api/server.py index e246333e..1d47b0dc 100644 --- a/functest/api/server.py +++ b/functest/api/server.py @@ -12,6 +12,7 @@ Used to launch Functest RestApi """ +import inspect import logging import socket from urlparse import urljoin @@ -21,12 +22,28 @@ from flask import Flask from flask_restful import Api from functest.api.base import ApiResource -from functest.api.urls import URLPATTERNS from functest.api.common import api_utils +from functest.api.database.db import BASE +from functest.api.database.db import DB_SESSION +from functest.api.database.db import ENGINE +from functest.api.database.v1 import models +from functest.api.urls import URLPATTERNS LOGGER = logging.getLogger(__name__) +APP = Flask(__name__) +API = Api(APP) + + +@APP.teardown_request +def shutdown_session(exception=None): # pylint: disable=unused-argument + """ + To be called at the end of each request whether it is successful + or an exception is raised + """ + DB_SESSION.remove() + def get_resource(resource_name): """ Obtain the required resource according to resource name """ @@ -41,7 +58,7 @@ def get_endpoint(url): return urljoin('http://{}:5000'.format(address), url) -def api_add_resource(api): +def api_add_resource(): """ The resource has multiple URLs and you can pass multiple URLs to the add_resource() method on the Api object. Each one will be routed to @@ -49,19 +66,38 @@ def api_add_resource(api): """ for url_pattern in URLPATTERNS: try: - api.add_resource( + API.add_resource( get_resource(url_pattern.target), url_pattern.url, endpoint=get_endpoint(url_pattern.url)) except StopIteration: LOGGER.error('url resource not found: %s', url_pattern.url) +def init_db(): + """ + Import all modules here that might define models so that + they will be registered properly on the metadata, and then + create a database + """ + def func(subcls): + """ To check the subclasses of BASE""" + try: + if issubclass(subcls[1], BASE): + return True + except TypeError: + pass + return False + # pylint: disable=bad-builtin + subclses = filter(func, inspect.getmembers(models, inspect.isclass)) + LOGGER.debug('Import models: %s', [subcls[1] for subcls in subclses]) + BASE.metadata.create_all(bind=ENGINE) + + def main(): """Entry point""" logging.config.fileConfig(pkg_resources.resource_filename( 'functest', 'ci/logging.ini')) LOGGER.info('Starting Functest server') - app = Flask(__name__) - api = Api(app) - api_add_resource(api) - app.run(host='0.0.0.0') + api_add_resource() + init_db() + APP.run(host='0.0.0.0') diff --git a/functest/api/urls.py b/functest/api/urls.py index 40af98d6..f7bcae38 100644 --- a/functest/api/urls.py +++ b/functest/api/urls.py @@ -43,6 +43,11 @@ URLPATTERNS = [ # => GET the info of one testcase Url('/api/v1/functest/testcases/<testcase_name>', 'v1_testcase'), + # POST /api/v1/functest/testcases/action + # {"action":"run_test_case", "args": {"opts": {}, "testcase": "vping_ssh"}} + # => Run a testcase + Url('/api/v1/functest/testcases/action', 'v1_testcase'), + # GET /api/v1/functest/testcases => GET all tiers Url('/api/v1/functest/tiers', 'v1_tiers'), @@ -52,5 +57,10 @@ URLPATTERNS = [ # GET /api/v1/functest/tiers/<tier_name>/testcases # => GET all testcases within given tier - Url('/api/v1/functest/tiers/<tier_name>/testcases', 'v1_testcases_in_tier') + Url('/api/v1/functest/tiers/<tier_name>/testcases', + 'v1_testcases_in_tier'), + + # GET /api/v1/functest/tasks/<task_id> + # => GET the result of the task id + Url('/api/v1/functest/tasks/<task_id>', 'v1_tasks') ] diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml index 6107b42a..49ba7a9e 100644 --- a/functest/ci/config_functest.yaml +++ b/functest/ci/config_functest.yaml @@ -5,7 +5,7 @@ general: dir_repo_rally: /home/opnfv/repos/rally repo_tempest: /src/tempest dir_repo_releng: /home/opnfv/repos/releng - repo_vims_test: /home/opnfv/repos/vnfs/vims-test + repo_vims_test: /src/vims-test repo_onos: /home/opnfv/repos/onos repo_barometer: /home/opnfv/repos/barometer repo_doctor: /home/opnfv/repos/doctor @@ -96,11 +96,6 @@ odl_sfc: tempest: deployment_name: opnfv-tempest - identity: - tenant_name: tempest - tenant_description: Tenant for Tempest test suite - user_name: tempest - user_password: Tempest123! validation: ssh_timeout: 130 object_storage: @@ -141,9 +136,6 @@ vnf: tenant_name: orchestra_clearwaterims tenant_description: Clearwater IMS deployed with Open Baton config: orchestra.yaml - opera_ims: - tenant_name: opera_ims - tenant_description: ims deployed with open-o ONOS: general: diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index fecd8126..7c51987c 100644 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -460,7 +460,7 @@ tiers: - name: vnf order: 4 - ci_loop: 'daily' + ci_loop: '(daily)|(weekly)' description : >- Collection of VNF test cases. testcases: @@ -486,7 +486,7 @@ tiers: criteria: 100 blocking: false description: >- - Test suite from Parser project. + Simple VNF. dependencies: installer: '' scenario: '' @@ -523,21 +523,6 @@ tiers: class: 'ClearwaterImsVnf' - - case_name: opera_vims - enabled: false - project_name: opera - criteria: 100 - blocking: false - description: >- - VNF deployment with OPEN-O - dependencies: - installer: 'compass' - scenario: 'os-nosdn-openo-ha' - run: - module: 'functest.opnfv_tests.vnf.ims.opera_ims' - class: 'OperaIms' - - - case_name: vyos_vrouter enabled: false project_name: functest diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py index 975f2bdc..fd3785b9 100644 --- a/functest/opnfv_tests/openstack/tempest/conf_utils.py +++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py @@ -51,25 +51,6 @@ logger = logging.getLogger(__name__) def create_tempest_resources(use_custom_images=False, use_custom_flavors=False): - keystone_client = os_utils.get_keystone_client() - - logger.debug("Creating tenant and user for Tempest suite") - tenant_id = os_utils.create_tenant( - keystone_client, - CONST.__getattribute__('tempest_identity_tenant_name'), - CONST.__getattribute__('tempest_identity_tenant_description')) - if not tenant_id: - logger.error("Failed to create %s tenant" - % CONST.__getattribute__('tempest_identity_tenant_name')) - - user_id = os_utils.create_user( - keystone_client, - CONST.__getattribute__('tempest_identity_user_name'), - CONST.__getattribute__('tempest_identity_user_password'), - None, tenant_id) - if not user_id: - logger.error("Failed to create %s user" % - CONST.__getattribute__('tempest_identity_user_name')) logger.debug("Creating private network for Tempest suite") network_dic = os_utils.create_shared_network_full( @@ -289,12 +270,6 @@ def configure_tempest_update_params(tempest_conf_file, config.set('compute', 'flavor_ref', FLAVOR_ID) if FLAVOR_ID_ALT is not None: config.set('compute', 'flavor_ref_alt', FLAVOR_ID_ALT) - config.set('identity', 'tenant_name', - CONST.__getattribute__('tempest_identity_tenant_name')) - config.set('identity', 'username', - CONST.__getattribute__('tempest_identity_user_name')) - config.set('identity', 'password', - CONST.__getattribute__('tempest_identity_user_password')) config.set('identity', 'region', 'RegionOne') if os_utils.is_keystone_v3(): auth_version = 'v3' diff --git a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py index 5a5c12be..1c3f69c6 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py +++ b/functest/opnfv_tests/vnf/ims/clearwater_ims_base.py @@ -117,7 +117,6 @@ class ClearwaterOnBoardingBase(vnf.VnfOnBoarding): dns_file_bak = '/etc/resolv.conf.bak' shutil.copy(dns_file, dns_file_bak) script = ('echo -e "nameserver {0}{1}" > {2};' - 'source /etc/profile.d/rvm.sh;' 'cd {3};' 'rake test[{4}] SIGNUP_CODE={5}' .format(dns_ip, diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py deleted file mode 100644 index d420705a..00000000 --- a/functest/opnfv_tests/vnf/ims/opera_ims.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others. -# -# 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 json -import logging -import os -import time - -from opera import openo_connect -import requests - -import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base -from functest.utils.constants import CONST - - -class OperaIms(clearwater_ims_base.ClearwaterOnBoardingBase): - - def __init__(self, **kwargs): - if "case_name" not in kwargs: - kwargs["case_name"] = "opera_ims" - super(OperaIms, self).__init__(**kwargs) - self.logger = logging.getLogger(__name__) - self.ellis_file = os.path.join( - CONST.__getattribute__('dir_results'), 'ellis.info') - self.live_test_file = os.path.join( - CONST.__getattribute__('dir_results'), 'live_test_report.json') - try: - self.openo_msb_endpoint = os.environ['OPENO_MSB_ENDPOINT'] - except KeyError: - raise Exception('OPENO_MSB_ENDPOINT is not specified,' - ' put it as <OPEN-O ip>:<port>') - else: - self.logger.info('OPEN-O endpoint is: %s', self.openo_msb_endpoint) - - def prepare(self): - pass - - def clean(self): - pass - - def deploy_vnf(self): - try: - openo_connect.create_service(self.openo_msb_endpoint, - 'functest_opera', - 'VNF for functest testing') - except Exception as e: - self.logger.error(e) - return {'status': 'FAIL', 'result': e} - else: - self.logger.info('vIMS deployment is kicked off') - return {'status': 'PASS', 'result': ''} - - def dump_info(self, info_file, result): - with open(info_file, 'w') as f: - self.logger.debug('Save information to file: %s', info_file) - json.dump(result, f) - - def test_vnf(self): - vnfm_ip = openo_connect.get_vnfm_ip(self.openo_msb_endpoint) - self.logger.info('VNFM IP: %s', vnfm_ip) - vnf_status_url = 'http://{0}:5000/api/v1/model/status'.format(vnfm_ip) - vnf_alive = False - retry = 40 - - self.logger.info('Check the VNF status') - while retry > 0: - rq = requests.get(vnf_status_url, timeout=90) - response = rq.json() - vnf_alive = response['vnf_alive'] - msg = response['msg'] - self.logger.info(msg) - if vnf_alive: - break - self.logger.info('check again in one and half a minute...') - retry = retry - 1 - time.sleep(90) - - if not vnf_alive: - raise Exception('VNF failed to start: {0}'.format(msg)) - - ellis_config_url = ('http://{0}:5000/api/v1/model/ellis/configure' - .format(vnfm_ip)) - rq = requests.get(ellis_config_url, timeout=90) - if rq.json() and not rq.json()['ellis_ok']: - self.logger.error(rq.json()['data']) - raise Exception('Failed to configure Ellis') - - self.logger.info('Get Clearwater deployment detail') - vnf_info_url = ('http://{0}:5000/api/v1/model/output' - .format(vnfm_ip)) - rq = requests.get(vnf_info_url, timeout=90) - data = rq.json()['data'] - self.logger.info(data) - bono_ip = data['bono_ip'] - ellis_ip = data['ellis_ip'] - dns_ip = data['dns_ip'] - result = self.config_ellis(ellis_ip, 'signup', True) - self.logger.debug('Ellis Result: %s', result) - self.dump_info(self.ellis_file, result) - - if dns_ip: - vims_test_result = self.run_clearwater_live_test( - dns_ip, - 'clearwater.local', - bono_ip, - ellis_ip, - 'signup') - if vims_test_result != '': - self.dump_info(self.live_test_file, vims_test_result) - return {'status': 'PASS', 'result': vims_test_result} - else: - return {'status': 'FAIL', 'result': ''} - - def main(self, **kwargs): - self.logger.info("Start to run Opera vIMS VNF onboarding test") - self.execute() - self.logger.info("Opera vIMS VNF onboarding test finished") - if self.result is "PASS": - return self.EX_OK - else: - return self.EX_RUN_ERROR - - def run(self): - kwargs = {} - return self.main(**kwargs) diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py index 55085744..bbfcc57d 100644 --- a/functest/tests/unit/openstack/tempest/test_conf_utils.py +++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py @@ -21,12 +21,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'os_utils.get_keystone_client', return_value=mock.Mock()), \ mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_tenant', - return_value='test_tenant_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_user', - return_value='test_user_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' 'os_utils.create_shared_network_full', return_value=None), \ self.assertRaises(Exception) as context: @@ -39,12 +33,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'os_utils.get_keystone_client', return_value=mock.Mock()), \ mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_tenant', - return_value='test_tenant_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_user', - return_value='test_user_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' 'os_utils.create_shared_network_full', return_value=mock.Mock()), \ mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' @@ -67,12 +55,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase): 'os_utils.get_keystone_client', return_value=mock.Mock()), \ mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_tenant', - return_value='test_tenant_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' - 'os_utils.create_user', - return_value='test_user_id'), \ - mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' 'os_utils.create_shared_network_full', return_value=mock.Mock()), \ mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.' diff --git a/functest/utils/env.py b/functest/utils/env.py index 2fb766d3..d7b396ea 100644 --- a/functest/utils/env.py +++ b/functest/utils/env.py @@ -32,7 +32,8 @@ class Environment(object): if k not in os.environ: self.__setattr__(k, v) self._set_ci_run() - self._set_ci_loop() + if 'CI_LOOP' not in os.environ: + self._set_ci_loop() def _set_ci_run(self): if self.BUILD_TAG: diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index 335f14cd..8b59c954 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -22,8 +22,8 @@ from heatclient import client as heatclient from novaclient import client as novaclient from keystoneclient import client as keystoneclient from neutronclient.neutron import client as neutronclient -from functest.utils.constants import CONST +from functest.utils.constants import CONST import functest.utils.functest_utils as ft_utils logger = logging.getLogger(__name__) @@ -713,6 +713,8 @@ def get_private_net(neutron_client): def get_external_net(neutron_client): + if (hasattr(CONST, 'EXTERNAL_NETWORK')): + return CONST.__getattribute__('EXTERNAL_NETWORK') for network in neutron_client.list_networks()['networks']: if network['router:external']: return network['name'] @@ -720,6 +722,11 @@ def get_external_net(neutron_client): def get_external_net_id(neutron_client): + if (hasattr(CONST, 'EXTERNAL_NETWORK')): + networks = neutron_client.list_networks( + name=CONST.__getattribute__('EXTERNAL_NETWORK')) + net_id = networks['networks'][0]['id'] + return net_id for network in neutron_client.list_networks()['networks']: if network['router:external']: return network['id'] diff --git a/upper-constraints.txt b/upper-constraints.txt index 234ccee1..74d363c5 100644 --- a/upper-constraints.txt +++ b/upper-constraints.txt @@ -2,7 +2,6 @@ git+https://gerrit.opnfv.org/gerrit/releng#egg=opnfv&subdirectory=modules git+https://gerrit.opnfv.org/gerrit/snaps#egg=snaps git+https://gerrit.opnfv.org/gerrit/barometer#egg=baro_tests git+https://gerrit.opnfv.org/gerrit/sdnvpn#egg=sdnvpn -git+https://gerrit.opnfv.org/gerrit/opera#egg=opera git+https://gerrit.opnfv.org/gerrit/securityscanning#egg=securityscanning git+https://gerrit.opnfv.org/gerrit/sfc#egg=sfc -e git+https://gerrit.opnfv.org/gerrit/promise#egg=promise |