Revert "Rename SSHHost.run to SSHHost.run_very_slowly"
This reverts commit 672fb5f8806694d9476f016c0f1094da29120f31.
Reason for revert: Broke android tests: crbug.com/737316
Original change's description:
> Rename SSHHost.run to SSHHost.run_very_slowly
>
> This CL renames several places that calls SSHHost.run directly to SSHHost.run_very_slowly.
> In addition, it warns the caller with a more verbose server stack message now.
>
> BUG=chromium:735653
> TEST=test_that dut graphics_Sanity
> ./utils/unittest_suite.py --debug
> CQ-DEPEND=I2a434782b9b7ed7a3d31289d9925f3c8502a6d9f
>
> Change-Id: Icd22fe9bcc4b5a47320478932194a8b535f4a936
> Reviewed-on: https://chromium-review.googlesource.com/545116
> Commit-Ready: Po-Hsien Wang <pwang@chromium.org>
> Tested-by: Po-Hsien Wang <pwang@chromium.org>
> Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
Bug: chromium:735653
Change-Id: If57cd6103d73bc1f0335866d8c130953754df0d9
Reviewed-on: https://chromium-review.googlesource.com/550970
Reviewed-by: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Trybot-Ready: Allen Li <ayatane@chromium.org>
diff --git a/server/autotest.py b/server/autotest.py
index 7b4f065..b6cc6e6 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -126,9 +126,8 @@
for path in Autotest.get_client_autodir_paths(host):
try:
autotest_binary = os.path.join(path, 'bin', 'autotest')
- host.run_very_slowly('test -x %s'
- % utils.sh_escape(autotest_binary))
- host.run_very_slowly('test -w %s' % utils.sh_escape(path))
+ host.run('test -x %s' % utils.sh_escape(autotest_binary))
+ host.run('test -w %s' % utils.sh_escape(path))
logging.debug('Found existing autodir at %s', path)
return path
except error.GenericHostRunError:
@@ -161,8 +160,8 @@
client_autodir_paths = cls.get_client_autodir_paths(host)
for path in client_autodir_paths:
try:
- host.run_very_slowly('mkdir -p %s' % utils.sh_escape(path))
- host.run_very_slowly('test -w %s' % utils.sh_escape(path))
+ host.run('mkdir -p %s' % utils.sh_escape(path))
+ host.run('test -w %s' % utils.sh_escape(path))
return path
except error.AutoservRunError:
logging.debug('Failed to create %s', path)
@@ -210,8 +209,8 @@
# too apart from the client)
pkg_dir = os.path.join(autodir, 'packages')
# clean up the autodir except for the packages directory
- host.run_very_slowly('cd %s && ls | grep -v "^packages$"'
- ' | xargs rm -rf && rm -rf .[!.]*' % autodir)
+ host.run('cd %s && ls | grep -v "^packages$"'
+ ' | xargs rm -rf && rm -rf .[!.]*' % autodir)
pkgmgr.install_pkg('autotest', 'client', pkg_dir, autodir,
preserve_install_dir=True)
self.installed = True
@@ -232,7 +231,7 @@
abs_path = utils.sh_escape(abs_path)
commands.append("mkdir -p '%s'" % abs_path)
commands.append("touch '%s'/__init__.py" % abs_path)
- host.run_very_slowly(';'.join(commands))
+ host.run(';'.join(commands))
def _install(self, host=None, autodir=None, use_autoserv=True,
@@ -264,12 +263,12 @@
autodir = self.get_install_dir(host)
logging.info('Using installation dir %s', autodir)
host.set_autodir(autodir)
- host.run_very_slowly('mkdir -p %s' % utils.sh_escape(autodir))
+ host.run('mkdir -p %s' % utils.sh_escape(autodir))
# make sure there are no files in $AUTODIR/results
results_path = os.path.join(autodir, 'results')
- host.run_very_slowly('rm -rf %s/*' % utils.sh_escape(results_path),
- ignore_status=True)
+ host.run('rm -rf %s/*' % utils.sh_escape(results_path),
+ ignore_status=True)
# Fetch the autotest client from the nearest repository
if use_packaging:
@@ -287,7 +286,7 @@
# packages.
command = ('rm -f "%s"' %
(os.path.join(autodir, packages.CHECKSUM_FILE)))
- host.run_very_slowly(command)
+ host.run(command)
# try to install from file or directory
if self.source_material:
@@ -309,10 +308,9 @@
raise error.AutoservError('svn not found on target machine: %s' %
host.hostname)
try:
- host.run_very_slowly('svn checkout %s %s' % (AUTOTEST_SVN, autodir))
+ host.run('svn checkout %s %s' % (AUTOTEST_SVN, autodir))
except error.AutoservRunError, e:
- host.run_very_slowly('svn checkout %s %s'
- % (AUTOTEST_HTTP, autodir))
+ host.run('svn checkout %s %s' % (AUTOTEST_HTTP, autodir))
logging.info("Installation of autotest completed using SVN.")
self.installed = True
@@ -333,8 +331,7 @@
return
# perform the actual uninstall
- host.run_very_slowly("rm -rf %s" % utils.sh_escape(autodir),
- ignore_status=True)
+ host.run("rm -rf %s" % utils.sh_escape(autodir), ignore_status=True)
host.set_autodir(None)
self.installed = False
@@ -426,7 +423,7 @@
atrun.manual_control_file,
atrun.manual_control_file + '.state']
cmd = ';'.join('rm -f ' + control for control in delete_file_list)
- host.run_very_slowly(cmd, ignore_status=True)
+ host.run(cmd, ignore_status=True)
tmppath = utils.get(control_file, local_copy=True)
@@ -490,7 +487,7 @@
"""
client_result_dir = '%s/results/default' % host.autodir
command = 'tail -2 %s/status | head -1' % client_result_dir
- status = host.run_very_slowly(command).stdout.strip()
+ status = host.run(command).stdout.strip()
logging.info(status)
if status[:8] != 'END GOOD':
raise error.TestFail('%s client test did not pass.' % test_name)
@@ -554,7 +551,7 @@
def verify_machine(self):
binary = os.path.join(self.autodir, 'bin/autotest')
try:
- self.host.run_very_slowly('ls %s > /dev/null 2>&1' % binary)
+ self.host.run('ls %s > /dev/null 2>&1' % binary)
except:
raise error.AutoservInstallError(
"Autotest does not appear to be installed")
@@ -562,9 +559,8 @@
if not self.parallel_flag:
tmpdir = os.path.join(self.autodir, 'tmp')
download = os.path.join(self.autodir, 'tests/download')
- self.host.run_very_slowly('umount %s' % tmpdir, ignore_status=True)
- self.host.run_very_slowly('umount %s' % download,
- ignore_status=True)
+ self.host.run('umount %s' % tmpdir, ignore_status=True)
+ self.host.run('umount %s' % download, ignore_status=True)
def get_base_cmd_args(self, section):
@@ -750,10 +746,10 @@
self.host.job.push_execution_context(self.results_dir)
try:
- result = self.host.run_very_slowly(full_cmd, ignore_status=True,
- timeout=timeout,
- stdout_tee=devnull,
- stderr_tee=devnull)
+ result = self.host.run(full_cmd, ignore_status=True,
+ timeout=timeout,
+ stdout_tee=devnull,
+ stderr_tee=devnull)
finally:
self.host.job.pop_execution_context()
@@ -788,18 +784,16 @@
stdout_read = stderr_read = 0
self.host.job.push_execution_context(self.results_dir)
try:
- self.host.run_very_slowly(daemon_cmd, ignore_status=True, timeout=timeout)
+ self.host.run(daemon_cmd, ignore_status=True, timeout=timeout)
disconnect_warnings = []
while True:
monitor_cmd = self.get_monitor_cmd(monitor_dir, stdout_read,
stderr_read)
try:
- result = self.host.run_very_slowly(
- monitor_cmd,
- ignore_status=True,
- timeout=timeout,
- stdout_tee=client_log,
- stderr_tee=stderr_redirector)
+ result = self.host.run(monitor_cmd, ignore_status=True,
+ timeout=timeout,
+ stdout_tee=client_log,
+ stderr_tee=stderr_redirector)
except error.AutoservRunError, e:
result = e.result_obj
result.exit_status = None
@@ -1150,7 +1144,7 @@
fifo_path, = test_complete_match.groups()
try:
self.log_collector.collect_client_job_results()
- self.host.run_very_slowly("echo A > %s" % fifo_path)
+ self.host.run("echo A > %s" % fifo_path)
except Exception:
msg = "Post-test log collection failed, continuing anyway"
logging.exception(msg)
@@ -1165,7 +1159,7 @@
msg = "Package tarball creation failed, continuing anyway"
logging.exception(msg)
try:
- self.host.run_very_slowly("echo B > %s" % fifo_path)
+ self.host.run("echo B > %s" % fifo_path)
except Exception:
msg = "Package tarball installation failed, continuing anyway"
logging.exception(msg)
diff --git a/server/autotest_unittest.py b/server/autotest_unittest.py
index a5de455..b62a027 100755
--- a/server/autotest_unittest.py
+++ b/server/autotest_unittest.py
@@ -33,10 +33,6 @@
self.host.job.args = []
self.host.job.record = lambda *args: None
- # TODO(pwang): Delete this once crbug.com/735653, crbug.com/734887 is
- # fixed and ssh time is reasonable.
- self.host.run = self.host.run_very_slowly
-
# stubs
self.god.stub_function(utils, "get_server_dir")
self.god.stub_function(utils, "run")
diff --git a/server/control_segments/get_network_stats b/server/control_segments/get_network_stats
index 0029ac6..eeac989 100644
--- a/server/control_segments/get_network_stats
+++ b/server/control_segments/get_network_stats
@@ -21,7 +21,7 @@
# In a single ssh call, get list of network interfaces
# and their byte counts.
- result = dut.run_very_slowly('route; echo SEPARATOR; cat /proc/net/dev')
+ result = dut.run('route; echo SEPARATOR; cat /proc/net/dev')
# Split output
lines = result.stdout.splitlines()
diff --git a/server/hosts/abstract_ssh.py b/server/hosts/abstract_ssh.py
index c7ca60a..c3a1a19 100644
--- a/server/hosts/abstract_ssh.py
+++ b/server/hosts/abstract_ssh.py
@@ -121,8 +121,7 @@
Check if rsync is available on the remote host.
"""
try:
- self.run_very_slowly("rsync --version",
- stdout_tee=None, stderr_tee=None)
+ self.run("rsync --version", stdout_tee=None, stderr_tee=None)
except error.AutoservRunError:
return False
return True
@@ -523,14 +522,13 @@
"""
ctimeout = min(timeout, connect_timeout or timeout)
try:
- self.run_very_slowly(base_cmd, timeout=timeout,
- connect_timeout=ctimeout,
- ssh_failure_retry_ok=True)
+ self.run(base_cmd, timeout=timeout, connect_timeout=ctimeout,
+ ssh_failure_retry_ok=True)
except error.AutoservSSHTimeout:
msg = "Host (ssh) verify timed out (timeout = %d)" % timeout
raise error.AutoservSSHTimeout(msg)
except error.AutoservSshPermissionDeniedError:
- # let AutoservSshPermissionDeniedError be visible to the callers
+ #let AutoservSshPermissionDeniedError be visible to the callers
raise
except error.AutoservRunError, e:
# convert the generic AutoservRunError into something more
diff --git a/server/hosts/cros_host.py b/server/hosts/cros_host.py
index 23fe5ed..edbb5ea 100644
--- a/server/hosts/cros_host.py
+++ b/server/hosts/cros_host.py
@@ -187,13 +187,13 @@
"""
try:
- result = host.run_very_slowly(
+ result = host.run(
'grep -q CHROMEOS /etc/lsb-release && '
'! test -f /mnt/stateful_partition/.android_tester && '
'! grep -q moblab /etc/lsb-release',
ignore_status=True, timeout=timeout)
if result.exit_status == 0:
- lsb_release_content = host.run_very_slowly(
+ lsb_release_content = host.run(
'grep CHROMEOS_RELEASE_BOARD /etc/lsb-release',
timeout=timeout).stdout
return not lsbrelease_utils.is_jetstream(
diff --git a/server/hosts/remote.py b/server/hosts/remote.py
index 2c5dcb7..0d4994f 100644
--- a/server/hosts/remote.py
+++ b/server/hosts/remote.py
@@ -49,7 +49,7 @@
if hasattr(self, 'tmp_dirs'):
for dir in self.tmp_dirs:
try:
- self.run_very_slowly('rm -rf "%s"' % (utils.sh_escape(dir)))
+ self.run('rm -rf "%s"' % (utils.sh_escape(dir)))
except error.AutoservRunError:
pass
@@ -67,7 +67,7 @@
try:
cmd = ('test ! -e /var/log/messages || cp -f /var/log/messages '
'%s') % self.VAR_LOG_MESSAGES_COPY_PATH
- self.run_very_slowly(cmd)
+ self.run(cmd)
except Exception, e:
# Non-fatal error
logging.info('Failed to copy /var/log/messages at startup: %s', e)
@@ -243,10 +243,9 @@
on the destruction of the Host object that was used to obtain
it.
"""
- self.run_very_slowly("mkdir -p %s" % parent)
+ self.run("mkdir -p %s" % parent)
template = os.path.join(parent, 'autoserv-XXXXXX')
- dir_name = self.run_very_slowly("mktemp -d %s"
- % template).stdout.rstrip()
+ dir_name = self.run("mktemp -d %s" % template).stdout.rstrip()
self.tmp_dirs.append(dir_name)
return dir_name
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 77da9d6..991987e 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -76,24 +76,17 @@
alive_interval=alive_interval)
return "%s %s" % (base_cmd, self.hostname)
- def _get_server_stack_state(self, lowest_frames=0, highest_frames=None,
- verbose=False):
+ def _get_server_stack_state(self, lowest_frames=0, highest_frames=None):
""" Get the server stack frame status.
@param lowest_frames: the lowest frames to start printing.
@param highest_frames: the highest frames to print.
- (None means no restriction)
+ (None means no restriction)
"""
stack_frames = inspect.stack()
stack = ''
for frame in stack_frames[lowest_frames:highest_frames]:
- info = inspect.getframeinfo(frame[0])
- if verbose:
- stack = '%s:%s <%s> | %s' % (info.filename,
- info.lineno,
- info.function,
- stack)
- else:
- stack = '%s | %s' % (info.function, stack)
+ function_name = inspect.getframeinfo(frame[0]).function
+ stack = '%s|%s' % (function_name, stack)
del stack_frames
return stack[:-1] # Delete the last '|' character
@@ -299,9 +292,7 @@
@raises AutoservSSHTimeout: ssh connection has timed out
"""
if verbose:
- stack = self._get_server_stack_state(lowest_frames=1,
- highest_frames=7,
- verbose=True)
+ stack = self._get_server_stack_state(lowest_frames=1, highest_frames=7)
logging.debug("Running (ssh) '%s' from '%s'", command, stack)
command = self._verbose_logger_command(command)
@@ -321,8 +312,6 @@
raise error.AutoservRunError(timeout_message, cmderr.args[1])
- # TODO(pwang): Delete this once all reference to the original run function
- # is changed to run_very_slowly. (crbug.com/735653)
def run(self, *args, **kwargs):
return self.run_very_slowly(*args, **kwargs)
diff --git a/server/site_autotest.py b/server/site_autotest.py
index d9b2ba2..d78bb67 100755
--- a/server/site_autotest.py
+++ b/server/site_autotest.py
@@ -211,7 +211,7 @@
# When fetching a package, the client expects to be
# notified when the fetching is complete. Autotest
# does this pushing a B to a fifo queue to the client.
- self.host.run_very_slowly("echo B > %s" % fifo_path)
+ self.host.run("echo B > %s" % fifo_path)
except error.AutoservRunError:
msg = "Checksum installation failed, continuing anyway"
logging.exception(msg)