From d588748a36a36701d69f40b68bf3d62f20d76baf Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Wed, 14 Jan 2015 17:17:08 +0000 Subject: [PATCH] Default the worker number to 0 not NaN If 'NaN' then the worker balance summary will fail with a TypeError. 0 makes sense in the common cases: * either you have worker tags and they are numbered * or you have no worker tags and thus you have just one worker, and we can call that worker '0' because it is the first one The 'NaN' shows up when you try to use subunit-trace in commands such as python -m subunit.run discover |subunit-trace which is something people are wont to do. Change-Id: Ibe18f16c0c360fc5a995fcf84e5bf2b6c16abd9c --- tempest_lib/cmd/subunit_trace.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tempest_lib/cmd/subunit_trace.py b/tempest_lib/cmd/subunit_trace.py index ea59cc6..5ffaa7c 100755 --- a/tempest_lib/cmd/subunit_trace.py +++ b/tempest_lib/cmd/subunit_trace.py @@ -81,10 +81,15 @@ def get_duration(timestamps): def find_worker(test): + """Get the worker number. + + If there are no workers because we aren't in a concurrent environment, + assume the worker number is 0. + """ for tag in test['tags']: if tag.startswith('worker-'): return int(tag[7:]) - return 'NaN' + return 0 # Print out stdout/stderr if it exists, always