Set swift_operator_role if required 19/59819/1
authorCédric Ollivier <cedric.ollivier@orange.com>
Sat, 14 Jul 2018 11:37:35 +0000 (13:37 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sat, 14 Jul 2018 11:40:42 +0000 (13:40 +0200)
Apex creates member as default role which conflicts with the default
swift_operator_role [1]. It detects the default role in lowercase as
well and write it in rally.conf if required.

[1] https://build.opnfv.org/ci/view/functest/job/functest-apex-virtual-suite-master/116/console

Change-Id: Ic4dc98c793207fc32ff35852472742c92db6699c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/core/tenantnetwork.py
functest/opnfv_tests/openstack/tempest/tempest.py

index 60b747b..286aef6 100644 (file)
@@ -150,7 +150,7 @@ class TenantNetwork1(testcase.TestCase):
     @staticmethod
     def get_external_network(cloud):
         """
-        Returns the configured external network name or
+        Return the configured external network name or
         the first retrieved external network name
         """
         assert cloud
@@ -164,6 +164,17 @@ class TenantNetwork1(testcase.TestCase):
             return networks[0]
         return None
 
+    @staticmethod
+    def get_default_role(cloud, member="Member"):
+        """Get the default role
+
+        It also tests the role in lowercase to avoid possible conflicts.
+        """
+        role = cloud.get_role(member)
+        if not role:
+            role = cloud.get_role(member.lower())
+        return role
+
     def _create_network_ressources(self):
         assert self.cloud
         assert self.ext_net
index ac69357..bf79eb2 100644 (file)
@@ -261,6 +261,19 @@ class TempestCommon(singlevm.VmReady1):
         with open(rally_conf, 'wb') as config_file:
             rconfig.write(config_file)
 
+    def update_default_role(self, rally_conf='/etc/rally/rally.conf'):
+        """Detect and update the default role if required"""
+        role = self.get_default_role(self.cloud)
+        if not role:
+            return
+        rconfig = configparser.RawConfigParser()
+        rconfig.read(rally_conf)
+        if not rconfig.has_section('tempest'):
+            rconfig.add_section('tempest')
+        rconfig.set('tempest', 'swift_operator_role', '^{}$'.format(role.name))
+        with open(rally_conf, 'wb') as config_file:
+            rconfig.write(config_file)
+
     def configure(self, **kwargs):  # pylint: disable=unused-argument
         """
         Create all openstack resources for tempest-based testcases and write
@@ -291,6 +304,7 @@ class TempestCommon(singlevm.VmReady1):
             assert super(TempestCommon, self).run(
                 **kwargs) == testcase.TestCase.EX_OK
             self.update_rally_regex()
+            self.update_default_role()
             self.configure(**kwargs)
             self.generate_test_list(**kwargs)
             self.apply_tempest_blacklist()