Skip to content
Snippets Groups Projects
Commit afd5ca04 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add function to execute QA commands with redirected output


Some QA commands generate non-trivial output: for a full QA, the gnt-*
list commands generate more than 300MB of data. To make the QA logs
more parseable by humans, we need support for redirecting output of
commands to a different place.

This patch adds a 'AssertRedirectedCommand' that does this,
redirecting the output to a (fixed) log file in the Ganeti log
directory.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 56b9f2db
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,9 @@ _MULTIPLEXERS = {} ...@@ -55,6 +55,9 @@ _MULTIPLEXERS = {}
#: Unique ID per QA run #: Unique ID per QA run
_RUN_UUID = utils.NewUUID() _RUN_UUID = utils.NewUUID()
#: Path to the QA query output log file
_QA_OUTPUT = pathutils.GetLogFilename("qa-output")
(INST_DOWN, (INST_DOWN,
INST_UP) = range(500, 502) INST_UP) = range(500, 502)
...@@ -192,6 +195,27 @@ def AssertCommand(cmd, fail=False, node=None, log_cmd=True): ...@@ -192,6 +195,27 @@ def AssertCommand(cmd, fail=False, node=None, log_cmd=True):
return rcode return rcode
def AssertRedirectedCommand(cmd, fail=False, node=None, log_cmd=True):
"""Executes a command with redirected output.
The log will go to the qa-output log file in the ganeti log
directory on the node where the command is executed. The fail and
node parameters are passed unchanged to AssertCommand.
@param cmd: the command to be executed, as a list; a string is not
supported
"""
if not isinstance(cmd, list):
raise qa_error.Error("Non-list passed to AssertRedirectedCommand")
ofile = utils.ShellQuote(_QA_OUTPUT)
cmdstr = utils.ShellQuoteArgs(cmd)
AssertCommand("echo ---- $(date) %s ---- >> %s" % (cmdstr, ofile),
fail=False, node=node, log_cmd=False)
return AssertCommand(cmdstr + " >> %s" % ofile,
fail=fail, node=node, log_cmd=log_cmd)
def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None): def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
"""Builds SSH command to be executed. """Builds SSH command to be executed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment