From f89d59b9ec2b6796dfb3f9ca27e150f3cdc8e8fe Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 8 Oct 2010 14:40:30 +0200 Subject: [PATCH] Change QA log output Currently, the logging in QA doesn't show the duration of the various steps, and if it is needed one has to perform log manipulation. This patch changes the output so that the log informatio is line based (as opposed to block-based), such that it's easy to grep for all log lines: ./qa/ganeti-qa.py --yes-do-it qa.json 2>&1|grep ^---- ---- 2010-10-08 14:40:21.730382 start Test SSH connection -------------- ---- 2010-10-08 14:40:23.156633 time=0:00:01.426251 Test SSH connection ---- 2010-10-08 14:40:23.156735 start ICMP ping each node -------------- ---- 2010-10-08 14:40:24.230479 time=0:00:01.073744 ICMP ping each node ---- 2010-10-08 14:40:24.230583 start Test availibility of Ganeti commands ---- 2010-10-08 14:40:32.314586 time=0:00:08.084003 Test availibility of Ganeti commands ---- 2010-10-08 14:40:32.314734 start gnt-node info -------------------- ---- 2010-10-08 14:40:32.860884 time=0:00:00.546150 gnt-node info ------ or just for the duration of the steps: ./qa/ganeti-qa.py --yes-do-it ../qa-mpgntac5.fra.json 2>&1|grep ^----.*time= ---- 2010-10-08 14:42:12.630067 time=0:00:01.239256 Test SSH connection ---- 2010-10-08 14:42:14.204393 time=0:00:01.574221 ICMP ping each node ---- 2010-10-08 14:42:22.170828 time=0:00:07.966331 Test availibility of Ganeti commands ---- 2010-10-08 14:42:22.701030 time=0:00:00.530037 gnt-node info ------ This will help with identifying slow steps or even graphing the QA duration. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- qa/ganeti-qa.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 34e4787a5..5c5023fa5 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python -u # # Copyright (C) 2007, 2008, 2009, 2010 Google Inc. @@ -44,6 +44,16 @@ from ganeti import rapi import ganeti.rapi.client +def _FormatHeader(line, end=72, char="-"): + """Fill a line up to the end column. + + """ + line = "---- " + line + " " + line += "-" * (end-len(line)) + line = line.rstrip() + return line + + def RunTest(fn, *args): """Runs a test after printing a header. @@ -51,16 +61,22 @@ def RunTest(fn, *args): if fn.__doc__: desc = fn.__doc__.splitlines()[0].strip() else: - desc = '%r' % fn + desc = "%r" % fn - now = str(datetime.datetime.now()) + desc = desc.rstrip(".") + + tstart = datetime.datetime.now() print - print '---', now, ('-' * (55 - len(now))) - print desc - print '-' * 60 + print _FormatHeader("%s start %s" % (tstart, desc)) - return fn(*args) + try: + retval = fn(*args) + return retval + finally: + tstop = datetime.datetime.now() + tdelta = tstop - tstart + print _FormatHeader("%s time=%s %s" % (tstop, tdelta, desc)) def RunEnvTests(): -- GitLab