From a52bba46f1360d340549901dbf62ec57e4d328b8 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sat, 25 Apr 2015 23:48:59 +0100 Subject: [PATCH 1/3] Output taskd.log to stdout on taskd failures (not test errors) --- test/basetest/taskd.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/basetest/taskd.py b/test/basetest/taskd.py index 3537bd634..f76188cbb 100644 --- a/test/basetest/taskd.py +++ b/test/basetest/taskd.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import division +from __future__ import division, print_function import os import tempfile import shutil @@ -207,6 +207,8 @@ class Taskd(object): self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=DEVNULL, env=self.env) else: + self.show_log_contents() + raise OSError("Taskd server is still running or crashed") # Wait for server to listen by checking connectivity in the port @@ -218,6 +220,8 @@ class Taskd(object): return elif status == self.TASKD_NEVER_STARTED: + self.show_log_contents() + raise OSError("Task server was never started. " "This shouldn't happen!!") @@ -225,6 +229,8 @@ class Taskd(object): # Collect output logs out, err = self.proc.communicate() + self.show_log_contents() + raise OSError( "Task server launched with '{0}' crashed or exited " "prematurely. Exit code: {1}. " @@ -242,6 +248,8 @@ class Taskd(object): sleep(1 / tries_per_minute) else: + self.show_log_contents() + raise OSError("Unknown running status for taskd '{0}'".format( status)) @@ -251,6 +259,8 @@ class Taskd(object): # Collect output logs out, err = self.proc.communicate() + self.show_log_contents() + raise OSError("Task server didn't start and listen on port {0} after " "{1} minutes. Stdout: {2!r}. Stderr: {3!r}.".format( self.port, minutes, out, err)) @@ -339,4 +349,14 @@ class Taskd(object): return parse_datafile(file) + def show_log_contents(self): + """Print to to STDOUT the contents of taskd.log + """ + if os.path.isfile(self.tasklog): + with open(self.tasklog) as fh: + print("#### Start taskd.log ####") + for line in fh: + print(line, end='') + print("#### End taskd.log ####") + # vim: ai sts=4 et sw=4 From 64be2306399cdcbbb4ffda6f00567b00469e7ca1 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sat, 25 Apr 2015 23:59:49 +0100 Subject: [PATCH 2/3] Tests: Include taskd in USE_PATH warning --- test/basetest/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/basetest/utils.py b/test/basetest/utils.py index b8833003a..5ffc72332 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -130,8 +130,8 @@ def _queue_output(arguments, pidq, outputq): "", ("Unexpected exception caught during execution of taskw: '{0}' . " "If you are running out-of-tree tests set USE_PATH=1 in shell " - "env before execution and add the location of the task binary to " - "the PATH".format(e)), + "env before execution and add the location of the task(d) binary " + "to the PATH".format(e)), 255)) # false exitcode return From 233d97fbff3c7c6c1869324af4e09e9d869a4ae6 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sun, 26 Apr 2015 00:24:59 +0100 Subject: [PATCH 3/3] Tests: Use IP address instead of hostname with taskd --- test/basetest/taskd.py | 2 +- test/basetest/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/basetest/taskd.py b/test/basetest/taskd.py index f76188cbb..e905c5a82 100644 --- a/test/basetest/taskd.py +++ b/test/basetest/taskd.py @@ -39,7 +39,7 @@ class Taskd(object): TASKD_NOT_LISTENING = 3 def __init__(self, taskd=DEFAULT_TASKD, certpath=None, - address="localhost"): + address="127.0.0.1"): """Initialize a Task server that runs in the background and stores data in a temporary folder diff --git a/test/basetest/utils.py b/test/basetest/utils.py index 5ffc72332..1e2344cde 100644 --- a/test/basetest/utils.py +++ b/test/basetest/utils.py @@ -279,7 +279,7 @@ def get_IPs(hostname): return output -def port_used(addr="localhost", port=None): +def port_used(addr="127.0.0.1", port=None): "Return True if port is in use, False otherwise" if port is None: raise TypeError("Argument 'port' may not be None") @@ -304,7 +304,7 @@ def port_used(addr="localhost", port=None): return False -def find_unused_port(addr="localhost", start=53589, track=True): +def find_unused_port(addr="127.0.0.1", start=53589, track=True): """Find an unused port starting at `start` port If track=False the returned port will not be marked as in-use and the code