From 1c0e87519885238a884c7001c9b7a755fc914eaa Mon Sep 17 00:00:00 2001 From: mbligh Date: Tue, 26 Jan 2010 21:57:19 +0000 Subject: Extract the server-side profiler result collection code into a separate method and add a call to it from the failure log collection when a profiler fails. This will allow any incomplete (but possibly still useful) data collected before the profiler failed to still be available. Signed-off-by: John Admanski git-svn-id: svn://test.kernel.org/autotest/trunk@4170 592f7852-d20e-0410-864c-8624ca9c26a4 --- server/profilers.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/profilers.py b/server/profilers.py index 5c0bff06..1d54bcff 100644 --- a/server/profilers.py +++ b/server/profilers.py @@ -139,6 +139,8 @@ class profilers(profiler_manager.profiler_manager): dir=self._get_local_profilers_dir(test, host.hostname)) os.close(fd) host.get_file(get_profiler_log_path(autodir), path) + # try to collect any partial profiler logs + self._get_profiler_logs(autodir, test, host) except (error.AutotestError, error.AutoservError): logging.exception('Profiler failure log collection failed') # swallow the exception so that we don't override an existing @@ -150,6 +152,21 @@ class profilers(profiler_manager.profiler_manager): self._get_failure_logs(autodir, test, host) + def _get_profiler_logs(self, autodir, test, host): + results_dir = get_profiler_results_dir(autodir) + local_dir = self._get_local_profilers_dir(test, host.hostname) + + self.job.remove_client_log(host.hostname, results_dir, local_dir) + + tempdir = tempfile.mkdtemp(dir=self.job.tmpdir) + try: + host.get_file(results_dir + '/', tempdir) + except error.AutoservRunError: + pass # no files to pull back, nothing we can do + utils.merge_trees(tempdir, local_dir) + shutil.rmtree(tempdir, ignore_errors=True) + + def _run_clients(self, test, hosts): """ We initialize the profilers just before start because only then we @@ -235,18 +252,7 @@ class profilers(profiler_manager.profiler_manager): # pull back all the results for host, at, autodir in hosts: - results_dir = get_profiler_results_dir(autodir) - local_dir = self._get_local_profilers_dir(test, host.hostname) - - self.job.remove_client_log(host.hostname, results_dir, local_dir) - - tempdir = tempfile.mkdtemp(dir=self.job.tmpdir) - try: - host.get_file(results_dir + '/', tempdir) - except error.AutoservRunError: - pass # no files to pull back, nothing we can do - utils.merge_trees(tempdir, local_dir) - shutil.rmtree(tempdir, ignore_errors=True) + self._get_profiler_logs(autodir, test, host) def handle_reboot(self, host): -- cgit v1.2.3