Integrate Patrole as a new testcase 09/52809/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Wed, 21 Feb 2018 06:56:26 +0000 (07:56 +0100)
committerCédric Ollivier <cedric.ollivier@orange.com>
Wed, 28 Feb 2018 10:32:06 +0000 (11:32 +0100)
It's published in a new container because the current results don't
allow gating.

0.2 is selected to meet OpenStack Pike's requirements.

Co-Authored-By: Rémi Le Trocquer <remi.letrocquer@orange.com>
Change-Id: Iafcf8f66ee3531fc43136886095774885bfc3150
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
docker/patrole/Dockerfile [new file with mode: 0644]
docker/patrole/hooks/post_checkout [new file with mode: 0644]
docker/patrole/testcases.yaml [new file with mode: 0644]
functest/opnfv_tests/openstack/patrole/__init__.py [new file with mode: 0644]
functest/opnfv_tests/openstack/patrole/patrole.py [new file with mode: 0644]

diff --git a/docker/patrole/Dockerfile b/docker/patrole/Dockerfile
new file mode 100644 (file)
index 0000000..c423c40
--- /dev/null
@@ -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 (file)
index 0000000..8d0e981
--- /dev/null
@@ -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 (file)
index 0000000..10edc4e
--- /dev/null
@@ -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/opnfv_tests/openstack/patrole/__init__.py b/functest/opnfv_tests/openstack/patrole/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/functest/opnfv_tests/openstack/patrole/patrole.py b/functest/opnfv_tests/openstack/patrole/patrole.py
new file mode 100644 (file)
index 0000000..9d72a98
--- /dev/null
@@ -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)