Migrate cvp-sanity to Python3
* use print function from future
* convert dict keys and values to list
* do not use bunch imports
* fix requirements mismatch
Related: PROD-33849
Change-Id: Ifecc3a9dcdcfe3243f7dcf2c709a80e9a7c765a1
diff --git a/test_set/cvp-sanity/tests/test_salt_master.py b/test_set/cvp-sanity/tests/test_salt_master.py
index 35ebcb7..691da0a 100644
--- a/test_set/cvp-sanity/tests/test_salt_master.py
+++ b/test_set/cvp-sanity/tests/test_salt_master.py
@@ -9,9 +9,9 @@
tgt='salt:master',
param='cd /srv/salt/reclass/classes/cluster/; git status',
expr_form='pillar', check_status=True)
- assert 'nothing to commit' in git_status.values()[0], (
+ assert 'nothing to commit' in list(git_status.values())[0], (
"Git status shows some unmerged changes:\n{}".format(
- git_status.values()[0])
+ list(git_status.values())[0])
)
@@ -21,7 +21,7 @@
tgt='salt:master',
param='reclass-salt --top; echo $?',
expr_form='pillar', check_status=True)
- result = reclass[reclass.keys()[0]][-1]
+ result = reclass[list(reclass.keys())[0]][-1]
assert result == '0', 'Reclass is broken:\n{}'.format(reclass)
@@ -32,18 +32,18 @@
tgt='salt:master',
param='reclass-salt -o json --top',
expr_form='pillar', check_status=True)
- salt = local_salt_client.cmd(
+ salt = list(local_salt_client.cmd(
tgt='salt:master',
param='salt-run manage.status timeout=10 --out=json',
- expr_form='pillar', check_status=True).values()[0]
- reclass_warnings = reclass[reclass.keys()[0]].split('{\n "base":')[0]
+ expr_form='pillar', check_status=True).values())[0] or {}
+ reclass_warnings = reclass[list(reclass.keys())[0]].split('{\n "base":')[0]
if reclass_warnings:
logging.warning("\nReclass-salt output has warnings: {}".format(reclass_warnings))
- reclass_nodes = reclass[reclass.keys()[0]].split('{\n "base":')[1]
+ reclass_nodes = reclass[list(reclass.keys())[0]].split('{\n "base":')[1]
assert reclass_nodes != '', 'No nodes were found in' \
' reclass-salt --top output'
reclass_nodes = sorted(json.loads(reclass_nodes.strip("}")).keys())
- salt_nodes = sorted([x for xs in json.loads(salt).values() for x in xs])
+ salt_nodes = sorted([x for xs in list(json.loads(salt).values()) for x in xs])
assert salt_nodes == reclass_nodes, (
"Mismatch between registered salt nodes (left) and node defined in "
"reclass (right)."