Commit 1de1cd0c authored by Hrvoje Ribicic's avatar Hrvoje Ribicic
Browse files

Add an option for disabling the SSH multiplexer in QA



The SSH multiplexer is used by default in every connection made, and
when multiple threads are used, this causes strange issues when running
the QA locally. This patch allows the multiplexer to be bypassed,
making a new connection every time.
Signed-off-by: default avatarHrvoje Ribicic <riba@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 343c9ed2
......@@ -228,7 +228,8 @@ def AssertRedirectedCommand(cmd, fail=False, node=None, log_cmd=True):
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,
use_multiplexer=True):
"""Builds SSH command to be executed.
@type node: string
......@@ -242,6 +243,8 @@ def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
@param opts: list of additional options
@type tty: boolean or None
@param tty: if we should use tty; if None, will be auto-detected
@type use_multiplexer: boolean
@param use_multiplexer: if the multiplexer for the node should be used
"""
args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-lroot"]
......@@ -261,7 +264,7 @@ def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None):
args.append("-oForwardAgent=yes")
if opts:
args.extend(opts)
if node in _MULTIPLEXERS:
if node in _MULTIPLEXERS and use_multiplexer:
spath = _MULTIPLEXERS[node][0]
args.append("-oControlPath=%s" % spath)
args.append("-oControlMaster=no")
......@@ -338,7 +341,8 @@ def CloseMultiplexers():
utils.RemoveFile(sname)
def GetCommandOutput(node, cmd, tty=None, fail=False):
def GetCommandOutput(node, cmd, tty=None, use_multiplexer=True,
fail=False):
"""Returns the output of a command executed on the given node.
@type node: string
......@@ -347,11 +351,15 @@ def GetCommandOutput(node, cmd, tty=None, fail=False):
@param cmd: command to be executed in the node (cannot be empty or None)
@type tty: bool or None
@param tty: if we should use tty; if None, it will be auto-detected
@type use_multiplexer: bool
@param use_multiplexer: if the SSH multiplexer provided by the QA should be
used or not
@type fail: bool
@param fail: whether the command is expected to fail
"""
assert cmd
p = StartLocalCommand(GetSSHCommand(node, cmd, tty=tty),
p = StartLocalCommand(GetSSHCommand(node, cmd, tty=tty,
use_multiplexer=use_multiplexer),
stdout=subprocess.PIPE)
rcode = p.wait()
_AssertRetCode(rcode, fail, cmd, node)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment