aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <ollivier.cedric@gmail.com>2019-05-24 22:08:50 +0200
committerCédric Ollivier <ollivier.cedric@gmail.com>2019-05-24 22:08:50 +0200
commit7d58f89103a8c44fd166c3e06b492ade63e5c5b3 (patch)
tree03ae5a4963d22b257d3f978ee47169fd4020ae50
parent383d5803c8440d31f8df4ecaf70b34a84971b73b (diff)
Decode Bytes in logging calls
It fixes a few incorrect types in log calls [1]. [1] https://build.opnfv.org/ci/view/functest/job/functest-latest-daily/163/ Change-Id: I01790f6454694f434d31366f9c1cf9d98ff5a9cf Signed-off-by: Cédric Ollivier <ollivier.cedric@gmail.com>
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py14
-rw-r--r--functest/opnfv_tests/openstack/shaker/shaker.py4
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py10
-rw-r--r--functest/opnfv_tests/vnf/epc/juju_epc.py38
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py9
5 files changed, 39 insertions, 36 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index 674c74252..08e4a36c1 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -191,18 +191,18 @@ class RallyBase(singlevm.VmReady2):
'--deployment',
str(getattr(config.CONF, 'rally_deployment_name'))]
output = subprocess.check_output(cmd)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
except subprocess.CalledProcessError:
pass
cmd = ['rally', 'deployment', 'create', '--fromenv',
'--name', str(getattr(config.CONF, 'rally_deployment_name'))]
output = subprocess.check_output(cmd, env=environ)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
cmd = ['rally', 'deployment', 'check']
output = subprocess.check_output(cmd)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
return RallyBase.get_verifier_deployment_id()
@staticmethod
@@ -399,7 +399,7 @@ class RallyBase(singlevm.VmReady2):
cmd = (["rally", "task", "detailed", "--uuid", task_id])
LOGGER.debug('running command: %s', cmd)
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
# save report as JSON
report_json_name = '{}.json'.format(test_name)
@@ -408,7 +408,7 @@ class RallyBase(singlevm.VmReady2):
"--out", report_json_dir])
LOGGER.debug('running command: %s', cmd)
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
json_results = open(report_json_dir).read()
self._append_summary(json_results, test_name)
@@ -608,7 +608,7 @@ class RallyBase(singlevm.VmReady2):
"--to", file_name]
LOGGER.debug('running command: %s', cmd)
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
@staticmethod
def verify_report(file_name, uuid, export_type="html"):
@@ -624,7 +624,7 @@ class RallyBase(singlevm.VmReady2):
"--uuid", uuid, "--to", file_name]
LOGGER.debug('running command: %s', cmd)
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
def clean(self):
"""Cleanup of OpenStack resources. Should be called on completion."""
diff --git a/functest/opnfv_tests/openstack/shaker/shaker.py b/functest/opnfv_tests/openstack/shaker/shaker.py
index 995a10b18..51ac88ae0 100644
--- a/functest/opnfv_tests/openstack/shaker/shaker.py
+++ b/functest/opnfv_tests/openstack/shaker/shaker.py
@@ -113,8 +113,8 @@ class Shaker(singlevm.SingleVm2):
self.shaker_timeout, self.image.name, self.flavor.name,
self.fip.floating_ip_address, self.ext_net.id,
env.get('NAMESERVER')))
- self.__logger.info("output:\n%s", stdout.read())
- self.__logger.info("error:\n%s", stderr.read())
+ self.__logger.info("output:\n%s", stdout.read().decode())
+ self.__logger.info("error:\n%s", stderr.read().decode())
if not os.path.exists(self.res_dir):
os.makedirs(self.res_dir)
try:
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 30e9ce60b..69f7c2958 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -142,7 +142,7 @@ class TempestCommon(singlevm.VmReady2):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for line in proc.stdout:
- LOGGER.info(line.rstrip())
+ LOGGER.info(line.decode().rstrip())
new_line = line.decode().replace(' ', '').split('|')
if 'Tests' in new_line:
break
@@ -175,7 +175,7 @@ class TempestCommon(singlevm.VmReady2):
'--force']
try:
output = subprocess.check_output(cmd)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
except subprocess.CalledProcessError:
pass
@@ -184,7 +184,7 @@ class TempestCommon(singlevm.VmReady2):
'--name', str(getattr(config.CONF, 'tempest_verifier_name')),
'--type', 'tempest', '--system-wide']
output = subprocess.check_output(cmd)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
return TempestCommon.get_verifier_id()
@staticmethod
@@ -320,7 +320,7 @@ class TempestCommon(singlevm.VmReady2):
cmd = ['rally', 'verify', 'configure-verifier', '--reconfigure',
'--id', str(getattr(config.CONF, 'tempest_verifier_name'))]
output = subprocess.check_output(cmd)
- LOGGER.info("%s\n%s", " ".join(cmd), output)
+ LOGGER.info("%s\n%s", " ".join(cmd), output.decode())
LOGGER.debug("Looking for tempest.conf file...")
tempest_conf_file = os.path.join(deployment_dir, "tempest.conf")
@@ -347,7 +347,7 @@ class TempestCommon(singlevm.VmReady2):
cmd = "(cd {0}; stestr list '{1}' >{2} 2>/dev/null)".format(
self.verifier_repo_dir, testr_mode, self.list)
output = subprocess.check_output(cmd, shell=True)
- LOGGER.info("%s\n%s", cmd, output)
+ LOGGER.info("%s\n%s", cmd, output.decode())
os.remove('/etc/tempest.conf')
def apply_tempest_blacklist(self):
diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py
index 93961ada9..5b2e0e3de 100644
--- a/functest/opnfv_tests/vnf/epc/juju_epc.py
+++ b/functest/opnfv_tests/vnf/epc/juju_epc.py
@@ -171,7 +171,7 @@ class JujuEpc(singlevm.VmReady2):
yfile.write(CLOUD_TEMPLATE.format(**cloud_data))
cmd = ['juju', 'add-cloud', 'abot-epc', '-f', clouds_yaml, '--replace']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
def _register_credentials(self):
self.__logger.info("Creating Credentials for Abot-epc .....")
@@ -189,7 +189,7 @@ class JujuEpc(singlevm.VmReady2):
cmd = ['juju', 'add-credential', 'abot-epc', '-f', credentials_yaml,
'--replace']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
def prepare(self):
"""Prepare testcase (Additional pre-configuration steps)."""
@@ -214,7 +214,7 @@ class JujuEpc(singlevm.VmReady2):
'RegionOne'),
'-u', self.public_auth_url]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
return image
def publish_image_alt(self, name=None):
@@ -225,7 +225,7 @@ class JujuEpc(singlevm.VmReady2):
'RegionOne'),
'-u', self.public_auth_url]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
return image_alt
def deploy_orchestrator(self): # pylint: disable=too-many-locals
@@ -255,11 +255,11 @@ class JujuEpc(singlevm.VmReady2):
'--config', 'use-default-secgroup=true',
'--debug']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
except subprocess.CalledProcessError as cpe:
self.__logger.error(
"Exception with Juju Bootstrap: %s\n%s",
- cpe.cmd, cpe.output)
+ cpe.cmd, cpe.output.decode())
return False
except Exception: # pylint: disable=broad-except
self.__logger.exception("Some issue with Juju Bootstrap ...")
@@ -272,7 +272,7 @@ class JujuEpc(singlevm.VmReady2):
cmd = ['juju', 'status', '--format', 'short', name]
for i in range(10):
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
ret = re.search(
r'(?=workload:({})\))'.format(status), output.decode())
if ret:
@@ -293,17 +293,17 @@ class JujuEpc(singlevm.VmReady2):
self.__logger.info("Deploying Abot-epc bundle file ...")
cmd = ['juju', 'deploy', '{}'.format(descriptor.get('file_name'))]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
self.__logger.info("Waiting for instances .....")
try:
cmd = ['timeout', '-t', JujuEpc.juju_timeout, 'juju-wait']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
self.__logger.info("Deployed Abot-epc on Openstack")
except subprocess.CalledProcessError as cpe:
self.__logger.error(
"Exception with Juju VNF Deployment: %s\n%s",
- cpe.cmd, cpe.output)
+ cpe.cmd, cpe.output.decode())
return False
except Exception: # pylint: disable=broad-except
self.__logger.exception("Some issue with the VNF Deployment ..")
@@ -312,7 +312,7 @@ class JujuEpc(singlevm.VmReady2):
self.__logger.info("Checking status of ABot and EPC units ...")
cmd = ['juju', 'status']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.debug("%s\n%s", " ".join(cmd), output)
+ self.__logger.debug("%s\n%s", " ".join(cmd), output.decode())
for app in ['abot-epc-basic', 'oai-epc', 'oai-hss']:
if not self.check_app(app):
return False
@@ -322,7 +322,7 @@ class JujuEpc(singlevm.VmReady2):
'juju', 'scp', '--', '-r', '-v',
'{}/featureFiles'.format(self.case_dir), 'abot-epc-basic/0:~/']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
self.__logger.info("Copying the feature files within Abot_node ")
cmd = ['timeout', '-t', JujuEpc.juju_timeout,
@@ -330,7 +330,7 @@ class JujuEpc(singlevm.VmReady2):
'sudo', 'cp', '-vfR', '~/featureFiles/*',
'/etc/rebaca-test-suite/featureFiles']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
return True
def test_vnf(self):
@@ -340,11 +340,11 @@ class JujuEpc(singlevm.VmReady2):
cmd = ['juju', 'run-action', 'abot-epc-basic/0', 'run',
'tagnames={}'.format(self.details['test_vnf']['tag_name'])]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
cmd = ['timeout', '-t', JujuEpc.juju_timeout, 'juju-wait']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
duration = time.time() - start_time
self.__logger.info("Getting results from Abot node....")
@@ -354,7 +354,7 @@ class JujuEpc(singlevm.VmReady2):
'/var/lib/abot-epc-basic/artifacts/TestResults.json',
'{}/.'.format(self.res_dir)]
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
self.__logger.info("Parsing the Test results...")
res = (process_abot_test_result('{}/TestResults.json'.format(
self.res_dir)))
@@ -393,17 +393,17 @@ class JujuEpc(singlevm.VmReady2):
try:
cmd = ['juju', 'debug-log', '--replay', '--no-tail']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.debug("%s\n%s", " ".join(cmd), output)
+ self.__logger.debug("%s\n%s", " ".join(cmd), output.decode())
self.__logger.info("Destroying Orchestrator...")
cmd = ['timeout', '-t', JujuEpc.juju_timeout,
'juju', 'destroy-controller', '-y', 'abot-controller',
'--destroy-all-models']
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- self.__logger.info("%s\n%s", " ".join(cmd), output)
+ self.__logger.info("%s\n%s", " ".join(cmd), output.decode())
except subprocess.CalledProcessError as cpe:
self.__logger.error(
"Exception with Juju Cleanup: %s\n%s",
- cpe.cmd, cpe.output)
+ cpe.cmd, cpe.output.decode())
except Exception: # pylint: disable=broad-except
self.__logger.exception("General issue during the undeployment ..")
for fip in self.cloud.list_floating_ips():
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index 1b790a0bf..c51258060 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -78,10 +78,13 @@ class OSRallyTesting(unittest.TestCase):
calls = [
mock.call(['rally', 'deployment', 'destroy', '--deployment',
str(getattr(config.CONF, 'rally_deployment_name'))]),
+ mock.call().decode(),
mock.call(['rally', 'deployment', 'create', '--fromenv', '--name',
str(getattr(config.CONF, 'rally_deployment_name'))],
env=None),
- mock.call(['rally', 'deployment', 'check'])]
+ mock.call().decode(),
+ mock.call(['rally', 'deployment', 'check']),
+ mock.call().decode()]
mock_exec.assert_has_calls(calls)
@mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists')
@@ -414,7 +417,7 @@ class OSRallyTesting(unittest.TestCase):
"--to", file_name]
args[0].assert_called_with(cmd, stderr=subprocess.STDOUT)
- @mock.patch('subprocess.check_output', return_value=None)
+ @mock.patch('subprocess.check_output', return_value=b'')
def test_export_task(self, *args):
file_name = "{}/{}.html".format(
self.rally_base.results_dir, self.rally_base.case_name)
@@ -435,7 +438,7 @@ class OSRallyTesting(unittest.TestCase):
"--to", file_name]
args[0].assert_called_with(cmd, stderr=subprocess.STDOUT)
- @mock.patch('subprocess.check_output', return_value=None)
+ @mock.patch('subprocess.check_output', return_value=b'')
def test_verify_report(self, *args):
file_name = "{}/{}.html".format(
self.rally_base.results_dir, self.rally_base.case_name)