From 07b21e057c70004a44eea2a373dc420c3050caab Mon Sep 17 00:00:00 2001 From: Robert Nishihara Date: Sat, 20 May 2017 23:11:19 -0700 Subject: [PATCH] Print the driver stdout/stderr if we fail to decode it in jenkins. (#567) * Print the driver stdout/stderr if we fail to decode it in jenkins. * Fix whitespace. * Add explanation. --- test/jenkins_tests/multi_node_docker_test.py | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/jenkins_tests/multi_node_docker_test.py b/test/jenkins_tests/multi_node_docker_test.py index 6dd69b1bd7ca..5e2c91fc2084 100644 --- a/test/jenkins_tests/multi_node_docker_test.py +++ b/test/jenkins_tests/multi_node_docker_test.py @@ -20,10 +20,25 @@ def wait_for_output(proc): A tuple of the stdout and stderr of the process as strings. """ stdout_data, stderr_data = proc.communicate() - stdout_data = (stdout_data.decode("ascii") if stdout_data is not None - else None) - stderr_data = (stderr_data.decode("ascii") if stderr_data is not None - else None) + + if stdout_data is not None: + try: + # NOTE(rkn): This try/except block is here because I once saw an + # exception raised here and want to print more information if that + # happens again. + stdout_data = stdout_data.decode("ascii") + except UnicodeDecodeError: + raise Exception("Failed to decode stdout_data:", stdout_data) + + if stderr_data is not None: + try: + # NOTE(rkn): This try/except block is here because I once saw an + # exception raised here and want to print more information if that + # happens again. + stderr_data = stderr_data.decode("ascii") + except UnicodeDecodeError: + raise Exception("Failed to decode stderr_data:", stderr_data) + return stdout_data, stderr_data