summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/patrole/Dockerfile37
-rw-r--r--docker/patrole/hooks/post_checkout6
-rw-r--r--docker/patrole/testcases.yaml22
-rw-r--r--functest/core/vnf.py20
-rw-r--r--functest/opnfv_tests/openstack/patrole/__init__.py0
-rw-r--r--functest/opnfv_tests/openstack/patrole/patrole.py79
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py4
-rw-r--r--functest/tests/unit/core/test_vnf.py14
8 files changed, 177 insertions, 5 deletions
diff --git a/docker/patrole/Dockerfile b/docker/patrole/Dockerfile
new file mode 100644
index 000000000..c423c403d
--- /dev/null
+++ b/docker/patrole/Dockerfile
@@ -0,0 +1,37 @@
+FROM opnfv/functest-core
+
+ARG BRANCH=master
+ARG PATROLE_TAG=0.2.0
+ARG OPENSTACK_TAG=stable/pike
+ARG RALLY_TAG=stable/0.10
+ARG OS_FAULTS_TAG=0.1.16
+
+RUN apk --no-cache add --virtual .build-deps --update \
+ python-dev build-base linux-headers libffi-dev \
+ openssl-dev libjpeg-turbo-dev && \
+ wget -q -O- https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=$OPENSTACK_TAG | \
+ sed -E s/^tempest==+\(.*\)$/-e\ git+https:\\/\\/github.com\\/openstack\\/tempest@\\1#egg=tempest/ \
+ > upper-constraints.txt && \
+ pip install --no-cache-dir --src /src -cupper-constraints.txt \
+ -chttps://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH \
+ -e git+https://github.com/openstack/requirements@$OPENSTACK_TAG#egg=openstack_requirements && \
+ git clone --depth 1 https://github.com/openstack/os-faults.git -b $OS_FAULTS_TAG /src/os-faults && \
+ update-requirements -s --source /src/openstack-requirements /src/os-faults/ && \
+ git clone --depth 1 https://github.com/openstack/rally.git -b $RALLY_TAG /src/rally && \
+ update-requirements -s --source /src/openstack-requirements /src/rally/ && \
+ git clone https://github.com/openstack/patrole.git /src/patrole && \
+ (cd /src/patrole && git checkout $PATROLE_TAG) && \
+ update-requirements -s --source /src/openstack-requirements /src/patrole/ && \
+ pip install --no-cache-dir --src /src -cupper-constraints.txt \
+ -chttps://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH \
+ tempest /src/os-faults && \
+ pip install --no-cache-dir --src /src -cupper-constraints.txt \
+ -chttps://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH \
+ oslotest /src/patrole /src/rally && \
+ mkdir -p /etc/rally && \
+ printf "[database]\nconnection = 'sqlite:////var/lib/rally/database/rally.sqlite'" > /etc/rally/rally.conf && \
+ mkdir -p /var/lib/rally/database && rally db create && \
+ rm -r upper-constraints.txt /src/os-faults /src/rally && \
+ apk del .build-deps
+COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml
+CMD ["run_tests", "-t", "all"]
diff --git a/docker/patrole/hooks/post_checkout b/docker/patrole/hooks/post_checkout
new file mode 100644
index 000000000..8d0e98124
--- /dev/null
+++ b/docker/patrole/hooks/post_checkout
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-core:${DOCKER_TAG}"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/patrole/testcases.yaml b/docker/patrole/testcases.yaml
new file mode 100644
index 000000000..10edc4e5d
--- /dev/null
+++ b/docker/patrole/testcases.yaml
@@ -0,0 +1,22 @@
+---
+tiers:
+ -
+ name: smoke
+ order: 1
+ ci_loop: '(daily)|(weekly)'
+ description: >-
+ Set of basic Functional tests to validate the OPNFV scenarios.
+ testcases:
+ -
+ case_name: patrole
+ project_name: functest
+ criteria: 100
+ blocking: true
+ description: >-
+ Test suite from Patrole project.
+ dependencies:
+ installer: '^((?!netvirt).)*$'
+ scenario: ''
+ run:
+ module: 'functest.opnfv_tests.openstack.patrole.patrole'
+ class: 'Patrole'
diff --git a/functest/core/vnf.py b/functest/core/vnf.py
index cf20492b1..412e13156 100644
--- a/functest/core/vnf.py
+++ b/functest/core/vnf.py
@@ -17,6 +17,7 @@ from snaps.config.user import UserConfig
from snaps.config.project import ProjectConfig
from snaps.openstack.create_user import OpenStackUser
from snaps.openstack.create_project import OpenStackProject
+from snaps.openstack.utils import keystone_utils
from snaps.openstack.tests import openstack_tests
from functest.core import testcase
@@ -116,16 +117,31 @@ class VnfOnBoarding(testcase.TestCase):
snaps_creds,
ProjectConfig(
name=self.tenant_name,
- description=self.tenant_description
+ description=self.tenant_description,
+ domain=snaps_creds.project_domain_name
))
self.os_project.create()
self.created_object.append(self.os_project)
+
+ snaps_creds.project_domain_id = \
+ self.os_project.get_project().domain_id
+ snaps_creds.user_domain_id = \
+ self.os_project.get_project().domain_id
+
+ for role in ['admin', 'Admin']:
+ if keystone_utils.get_role_by_name(
+ keystone_utils.keystone_client(snaps_creds), role):
+ admin_role = role
+ break
+
user_creator = OpenStackUser(
snaps_creds,
UserConfig(
name=self.user_name,
password=str(uuid.uuid4()),
- roles={'admin': self.tenant_name}))
+ project_name=self.tenant_name,
+ domain_name=snaps_creds.user_domain_name,
+ roles={admin_role: self.tenant_name}))
user_creator.create()
self.created_object.append(user_creator)
self.snaps_creds = user_creator.get_os_creds(self.tenant_name)
diff --git a/functest/opnfv_tests/openstack/patrole/__init__.py b/functest/opnfv_tests/openstack/patrole/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/functest/opnfv_tests/openstack/patrole/__init__.py
diff --git a/functest/opnfv_tests/openstack/patrole/patrole.py b/functest/opnfv_tests/openstack/patrole/patrole.py
new file mode 100644
index 000000000..9d72a98f3
--- /dev/null
+++ b/functest/opnfv_tests/openstack/patrole/patrole.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2018 Orange 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
+
+# pylint: disable=missing-docstring
+
+import logging
+import os
+import time
+
+from functest.core import testcase
+from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.tempest import conf_utils
+from functest.opnfv_tests.openstack.tempest import tempest
+
+
+class Patrole(tempest.TempestCommon):
+
+ __logger = logging.getLogger(__name__)
+
+ def __init__(self, **kwargs):
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = 'patrole'
+ super(Patrole, self).__init__(**kwargs)
+ self.mode = "^patrole_tempest_plugin."
+
+ def run(self, **kwargs):
+ self.start_time = time.time()
+ try:
+ if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR):
+ os.makedirs(conf_utils.TEMPEST_RESULTS_DIR)
+ resources = self.resources.create()
+ compute_cnt = snaps_utils.get_active_compute_cnt(
+ self.resources.os_creds)
+ self.configure_tempest_patrole(
+ self.deployment_dir,
+ network_name=resources.get("network_name"),
+ image_id=resources.get("image_id"),
+ flavor_id=resources.get("flavor_id"),
+ compute_cnt=compute_cnt)
+ self.generate_test_list(self.verifier_repo_dir)
+ self.apply_tempest_blacklist()
+ self.run_verifier_tests()
+ self.parse_verifier_result()
+ self.generate_report()
+ res = testcase.TestCase.EX_OK
+ except Exception as err: # pylint: disable=broad-except
+ self.__logger.error('Error with run: %s', err)
+ res = testcase.TestCase.EX_RUN_ERROR
+ finally:
+ self.resources.cleanup()
+ self.stop_time = time.time()
+ return res
+
+ def configure_tempest_patrole(
+ self, deployment_dir, network_name=None, image_id=None,
+ flavor_id=None, compute_cnt=None):
+ # pylint: disable=too-many-arguments
+ """
+ Add/update needed parameters into tempest.conf file
+ """
+ self.__logger.debug(
+ "Updating selected tempest.conf parameters for Patrole")
+ conf_file = conf_utils.configure_verifier(deployment_dir)
+ conf_utils.configure_tempest_update_params(
+ conf_file, network_name, image_id, flavor_id, compute_cnt)
+ config = conf_utils.ConfigParser.RawConfigParser()
+ config.read(conf_file)
+ config.set('identity-feature-enabled', 'api_v2', False)
+ config.add_section('rbac')
+ config.set('rbac', 'enable_rbac', True)
+ config.set('rbac', 'rbac_test_role', 'admin')
+ with open(conf_file, 'wb') as config_file:
+ config.write(config_file)
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index 39bbb7678..81e9b5ee9 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -234,7 +234,9 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase):
keystone_password=self.snaps_creds.password,
keystone_tenant_name=self.snaps_creds.project_name,
keystone_url=public_auth_url,
- region=self.snaps_creds.region_name)
+ region=self.snaps_creds.region_name,
+ user_domain_name=self.snaps_creds.user_domain_name,
+ project_domain_name=self.snaps_creds.project_domain_name)
self.__logger.info("Set creds for cloudify manager %s", cfy_creds)
cfy_client = CloudifyClient(
diff --git a/functest/tests/unit/core/test_vnf.py b/functest/tests/unit/core/test_vnf.py
index 0ac672f6c..dbdcc0f05 100644
--- a/functest/tests/unit/core/test_vnf.py
+++ b/functest/tests/unit/core/test_vnf.py
@@ -129,6 +129,9 @@ class VnfBaseTesting(unittest.TestCase):
args[2].assert_not_called()
@mock.patch('functest.core.vnf.OpenStackUser', side_effect=Exception)
+ @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name',
+ return_value="admin")
+ @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
@mock.patch('functest.core.vnf.OpenStackProject')
@mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
def test_prepare_exc3(self, *args):
@@ -136,16 +139,23 @@ class VnfBaseTesting(unittest.TestCase):
self.test.prepare()
args[0].assert_called_with(os_env_file=constants.ENV_FILE)
args[1].assert_called_with(mock.ANY, mock.ANY)
- args[2].assert_called_with(mock.ANY, mock.ANY)
+ args[2].assert_called_with(mock.ANY)
+ args[3].assert_called_with(mock.ANY, mock.ANY)
+ args[4].assert_called_with(mock.ANY, mock.ANY)
@mock.patch('functest.core.vnf.OpenStackUser')
+ @mock.patch('snaps.openstack.utils.keystone_utils.get_role_by_name',
+ return_value="admin")
+ @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
@mock.patch('functest.core.vnf.OpenStackProject')
@mock.patch('snaps.openstack.tests.openstack_tests.get_credentials')
def test_prepare_default(self, *args):
self.assertEqual(self.test.prepare(), testcase.TestCase.EX_OK)
args[0].assert_called_with(os_env_file=constants.ENV_FILE)
args[1].assert_called_with(mock.ANY, mock.ANY)
- args[2].assert_called_with(mock.ANY, mock.ANY)
+ args[2].assert_called_with(mock.ANY)
+ args[3].assert_called_with(mock.ANY, mock.ANY)
+ args[4].assert_called_with(mock.ANY, mock.ANY)
def test_deploy_vnf_unimplemented(self):
with self.assertRaises(vnf.VnfDeploymentException):