From a83d52d99f45265a90fa7c451d1134a0b8344811 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 3 Aug 2015 15:18:09 -0300 Subject: [PATCH] latest job result: create the `latest` symlink at the job beginning Instead of creating at the end of the job. This allows users running long (time wise) jobs to be monitored by "following" the $AVOCADO_RESULT/latest/job.log file. This implements the card described at: https://trello.com/c/QJ4wCD8x/447-reconsider-when-the-latest-log-symlink-is-created Signed-off-by: Cleber Rosa --- avocado/core/job.py | 4 ++-- .../all/functional/avocado/basic_tests.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/avocado/core/job.py b/avocado/core/job.py index ff49f2b6..ebc1a781 100644 --- a/avocado/core/job.py +++ b/avocado/core/job.py @@ -443,6 +443,8 @@ class Job(object): self.args.test_result_total = mux.get_number_of_tests(test_suite) self._make_test_result() + if not self.standalone: + self._update_latest_link() self._make_test_runner() self._start_sysinfo() @@ -452,8 +454,6 @@ class Job(object): failures = self.test_runner.run_suite(test_suite, mux, timeout=self.timeout) self.view.stop_file_logging() - if not self.standalone: - self._update_latest_link() # If it's all good so far, set job status to 'PASS' if self.status == 'RUNNING': self.status = 'PASS' diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 2f4b66d5..e359176e 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -237,6 +237,24 @@ class RunnerOperationTest(unittest.TestCase): result)) self.assertIn('"status": "ERROR"', result.stdout) + def test_early_latest_result(self): + """ + Tests that the `latest` link to the latest job results is created early + """ + os.chdir(basedir) + cmd_line = ('./scripts/avocado run --sysinfo=off --job-results-dir %s examples/tests/sleeptest.py ' + '-m examples/tests/sleeptest.py.data/sleeptest.yaml' % self.tmpdir) + avocado_process = process.SubProcess(cmd_line) + avocado_process.start() + link = os.path.join(self.tmpdir, 'latest') + for trial in xrange(0, 50): + time.sleep(0.1) + if os.path.exists(link) and os.path.islink(link): + avocado_process.terminate() + break + self.assertTrue(os.path.exists(link)) + self.assertTrue(os.path.islink(link)) + def tearDown(self): shutil.rmtree(self.tmpdir) -- GitLab