Update to Python3
[functest.git] / functest / opnfv_tests / openstack / rally / rally.py
index 3e1a2e7..674c742 100644 (file)
@@ -117,6 +117,7 @@ class RallyBase(singlevm.VmReady2):
         task_args['smoke'] = self.smoke
         task_args['volume_version'] = self.VOLUME_VERSION
         task_args['volume_service_type'] = self.VOLUME_SERVICE_TYPE
+        task_args['block_migration'] = env.get("BLOCK_MIGRATION").lower()
 
         if self.ext_net:
             task_args['floating_network'] = str(self.ext_net.name)
@@ -165,7 +166,7 @@ class RallyBase(singlevm.VmReady2):
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
         deployment_uuid = proc.stdout.readline().rstrip()
-        return deployment_uuid
+        return deployment_uuid.decode()
 
     @staticmethod
     def create_rally_deployment(environ=None):
@@ -214,7 +215,7 @@ class RallyBase(singlevm.VmReady2):
                 rconfig.add_section('openstack')
             rconfig.set(
                 'openstack', 'keystone_default_role', env.get("NEW_USER_ROLE"))
-            with open(rally_conf, 'wb') as config_file:
+            with open(rally_conf, 'w') as config_file:
                 rconfig.write(config_file)
 
     @staticmethod
@@ -225,7 +226,7 @@ class RallyBase(singlevm.VmReady2):
             rconfig.read(rally_conf)
             if rconfig.has_option('openstack', 'keystone_default_role'):
                 rconfig.remove_option('openstack', 'keystone_default_role')
-            with open(rally_conf, 'wb') as config_file:
+            with open(rally_conf, 'w') as config_file:
                 rconfig.write(config_file)
 
     @staticmethod
@@ -239,7 +240,7 @@ class RallyBase(singlevm.VmReady2):
         taskid_re = re.compile('^Task +(.*): started$')
         for line in cmd_raw.splitlines(True):
             line = line.strip()
-            match = taskid_re.match(line)
+            match = taskid_re.match(line.decode())
             if match:
                 return match.group(1)
         return None
@@ -327,6 +328,8 @@ class RallyBase(singlevm.VmReady2):
             with open(RallyBase.BLACKLIST_FILE, 'r') as black_list_file:
                 black_list_yaml = yaml.safe_load(black_list_file)
 
+            if env.get('BLOCK_MIGRATION').lower() == 'true':
+                func_list.append("block_migration")
             if not self._migration_supported():
                 func_list.append("no_migration")
             if not self._network_trunk_supported():
@@ -654,8 +657,8 @@ class RallyBase(singlevm.VmReady2):
                 "{}/{}.xml".format(self.results_dir, self.case_name),
                 export_type="junit-xml")
             res = testcase.TestCase.EX_OK
-        except Exception as exc:   # pylint: disable=broad-except
-            LOGGER.error('Error with run: %s', exc)
+        except Exception:   # pylint: disable=broad-except
+            LOGGER.exception('Error with run:')
             self.result = 0
             res = testcase.TestCase.EX_RUN_ERROR
         self.stop_time = time.time()