Dynamically skip neutron_trunk and barbican 33/59833/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 15 Jul 2018 12:15:45 +0000 (14:15 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sun, 15 Jul 2018 12:41:20 +0000 (14:41 +0200)
It avoids fasly testcases in failure for end users.
It also removes the neutron_trunk class which is now useless (Queens).

Change-Id: I3f5a1ac84a50e061da6eadcc5c9bafb2e99050db
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
docker/smoke/testcases.yaml
functest/ci/testcases.yaml
functest/opnfv_tests/openstack/tempest/tempest.py
functest/opnfv_tests/openstack/trunk/__init__.py [deleted file]
functest/opnfv_tests/openstack/trunk/trunk.py [deleted file]

index 207bfc9..b59af41 100644 (file)
@@ -125,13 +125,14 @@ tiers:
                     OpenStack Tempest suite. The list of test cases is
                     generated by Tempest having as input the relevant
                     testcase list file.
-                dependencies:
-                    - INSTALLER_TYPE: '(fuel)|(apex)|(compass)'
                 run:
-                    module: 'functest.opnfv_tests.openstack.trunk.trunk'
-                    class: 'TempestNeutronTrunk'
+                    module: 'functest.opnfv_tests.openstack.tempest.tempest'
+                    class: 'TempestCommon'
                     args:
                         mode: 'neutron_tempest_plugin.(api|scenario).test_trunk'
+                        neutron_extensions:
+                            - trunk
+                            - trunk_details
 
             -
                 case_name: barbican
@@ -141,10 +142,10 @@ tiers:
                 description: >-
                     It leverages on the tempest plugin containing tests used to
                     verify the functionality of a barbican installation.
-                dependencies:
-                    - INSTALLER_TYPE: '^((?!fuel|apex|compass|daisy|osa).)*$'
                 run:
                     module: 'functest.opnfv_tests.openstack.tempest.tempest'
                     class: 'TempestCommon'
                     args:
                         mode: 'barbican_tempest_plugin.tests.(api|scenario)'
+                        services:
+                            - barbican
index 7919009..a9e023e 100644 (file)
@@ -316,13 +316,14 @@ tiers:
                     OpenStack Tempest suite. The list of test cases is
                     generated by Tempest having as input the relevant
                     testcase list file.
-                dependencies:
-                    - INSTALLER_TYPE: '(fuel)|(apex)|(compass)'
                 run:
-                    module: 'functest.opnfv_tests.openstack.trunk.trunk'
-                    class: 'TempestNeutronTrunk'
+                    module: 'functest.opnfv_tests.openstack.tempest.tempest'
+                    class: 'TempestCommon'
                     args:
                         mode: 'neutron_tempest_plugin.(api|scenario).test_trunk'
+                        neutron_extensions:
+                            - trunk
+                            - trunk_details
 
             -
                 case_name: barbican
@@ -332,13 +333,13 @@ tiers:
                 description: >-
                     It leverages on the tempest plugin containing tests used to
                     verify the functionality of a barbican installation.
-                dependencies:
-                    - INSTALLER_TYPE: '^((?!fuel|apex|compass|daisy|osa).)*$'
                 run:
                     module: 'functest.opnfv_tests.openstack.tempest.tempest'
                     class: 'TempestCommon'
                     args:
                         mode: 'barbican_tempest_plugin.tests.(api|scenario)'
+                        services:
+                            - barbican
 
     -
         name: features
index bf79eb2..52cc31c 100644 (file)
@@ -55,6 +55,40 @@ class TempestCommon(singlevm.VmReady1):
         self.conf_file = None
         self.image_alt = None
         self.flavor_alt = None
+        self.services = []
+        try:
+            self.services = kwargs['run']['args']['services']
+        except Exception:  # pylint: disable=broad-except
+            pass
+        self.neutron_extensions = []
+        try:
+            self.neutron_extensions = kwargs['run']['args'][
+                'neutron_extensions']
+        except Exception:  # pylint: disable=broad-except
+            pass
+
+    def check_services(self):
+        """Check the mandatory services."""
+        for service in self.services:
+            try:
+                self.cloud.search_services(service)[0]
+            except Exception:  # pylint: disable=broad-except
+                self.is_skipped = True
+                break
+
+    def check_extensions(self):
+        """Check the mandatory network extensions."""
+        extensions = self.cloud.get_network_extensions()
+        for network_extension in self.neutron_extensions:
+            if network_extension not in extensions:
+                LOGGER.warning(
+                    "Cannot find Neutron extension: %s", network_extension)
+                self.is_skipped = True
+                break
+
+    def check_requirements(self):
+        self.check_services()
+        self.check_extensions()
 
     @staticmethod
     def read_file(filename):
diff --git a/functest/opnfv_tests/openstack/trunk/__init__.py b/functest/opnfv_tests/openstack/trunk/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/functest/opnfv_tests/openstack/trunk/trunk.py b/functest/opnfv_tests/openstack/trunk/trunk.py
deleted file mode 100644 (file)
index 8d17767..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/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
-
-from six.moves import configparser
-
-from functest.opnfv_tests.openstack.tempest import tempest
-
-
-class TempestNeutronTrunk(tempest.TempestCommon):
-    """Tempest neutron trunk testcase implementation."""
-
-    def configure(self, **kwargs):
-        super(TempestNeutronTrunk, self).configure(**kwargs)
-        rconfig = configparser.RawConfigParser()
-        rconfig.read(self.conf_file)
-        rconfig.set('network-feature-enabled', 'api_extensions', 'all')
-        with open(self.conf_file, 'wb') as config_file:
-            rconfig.write(config_file)
-        self.backup_tempest_config(self.conf_file, self.res_dir)