aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack/refstack/refstack.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/openstack/refstack/refstack.py')
-rw-r--r--functest/opnfv_tests/openstack/refstack/refstack.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/functest/opnfv_tests/openstack/refstack/refstack.py b/functest/opnfv_tests/openstack/refstack/refstack.py
index c709e5626..87932020b 100644
--- a/functest/opnfv_tests/openstack/refstack/refstack.py
+++ b/functest/opnfv_tests/openstack/refstack/refstack.py
@@ -24,20 +24,16 @@ class Refstack(tempest.TempestCommon):
__logger = logging.getLogger(__name__)
- defcorelist = os.path.join(
- getattr(config.CONF, 'dir_refstack_data'), 'defcore.txt')
-
- def _extract_refstack_data(self):
+ def _extract_refstack_data(self, refstack_list):
yaml_data = ""
- with open(self.defcorelist) as def_file:
+ with open(refstack_list, encoding='utf-8') as def_file:
for line in def_file:
try:
grp = re.search(r'^([^\[]*)(\[.*\])\n*$', line)
- yaml_data = "{}\n{}: {}".format(
- yaml_data, grp.group(1), grp.group(2))
+ yaml_data = f"{yaml_data}\n{grp.group(1)}: {grp.group(2)}"
except Exception: # pylint: disable=broad-except
self.__logger.warning("Cannot parse %s", line)
- return yaml.load(yaml_data)
+ return yaml.full_load(yaml_data)
def _extract_tempest_data(self):
olddir = os.getcwd()
@@ -48,25 +44,27 @@ class Refstack(tempest.TempestCommon):
except subprocess.CalledProcessError as cpe:
self.__logger.error(
"Exception when listing tempest tests: %s\n%s",
- cpe.cmd, cpe.output)
+ cpe.cmd, cpe.output.decode("utf-8"))
raise
finally:
os.chdir(olddir)
yaml_data2 = ""
for line in output.splitlines():
try:
- grp = re.search(r'^([^\[]*)(\[.*\])\n*$', line)
- yaml_data2 = "{}\n{}: {}".format(
- yaml_data2, grp.group(1), grp.group(2))
+ grp = re.search(r'^([^\[]*)(\[.*\])\n*$', line.decode("utf-8"))
+ yaml_data2 = f"{yaml_data2}\n{grp.group(1)}: {grp.group(2)}"
except Exception: # pylint: disable=broad-except
self.__logger.warning("Cannot parse %s. skipping it", line)
- return yaml.load(yaml_data2)
+ return yaml.full_load(yaml_data2)
def generate_test_list(self, **kwargs):
+ refstack_list = os.path.join(
+ getattr(config.CONF, 'dir_refstack_data'),
+ f"{kwargs.get('target', 'compute')}.txt")
self.backup_tempest_config(self.conf_file, '/etc')
- refstack_data = self._extract_refstack_data()
+ refstack_data = self._extract_refstack_data(refstack_list)
tempest_data = self._extract_tempest_data()
- with open(self.list, 'w') as ref_file:
+ with open(self.list, 'w', encoding='utf-8') as ref_file:
for key in refstack_data.keys():
try:
for data in tempest_data[key]:
@@ -75,9 +73,9 @@ class Refstack(tempest.TempestCommon):
else:
self.__logger.info("%s: ids differ. skipping it", key)
continue
- ref_file.write("{}{}\n".format(
- key, str(tempest_data[key]).replace(
- "'", "").replace(", ", ",")))
+ value = str(tempest_data[key]).replace(
+ "'", "").replace(", ", ",")
+ ref_file.write(f"{key}{value}\n")
except Exception: # pylint: disable=broad-except
self.__logger.info("%s: not found. skipping it", key)
continue