diff --git a/optional_plugins/runner_remote/tests/test_remote.py b/optional_plugins/runner_remote/tests/test_remote.py index a96b5b636b7c9656cce0aeccd2dd5fff83df15fb..980a939dbb6425cb673beaccbf67348aa8bfbfc7 100644 --- a/optional_plugins/runner_remote/tests/test_remote.py +++ b/optional_plugins/runner_remote/tests/test_remote.py @@ -1,5 +1,8 @@ import argparse +import glob +import os import shutil +import tempfile import unittest try: @@ -8,7 +11,7 @@ except ImportError: import mock from avocado.core.job import Job -from avocado.core import version +from avocado.core import exit_codes, version from avocado.utils import process import avocado_runner_remote @@ -110,6 +113,35 @@ class RemoteTestRunnerTest(unittest.TestCase): if job: shutil.rmtree(job.args.base_logdir) + def test_run_replay_remotefail(self): + """ + Runs a replay job using remote plugin (not supported). + """ + tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__) + cmd_line = ('avocado run passtest.py ' + '-m examples/tests/sleeptest.py.data/sleeptest.yaml ' + '--job-results-dir %s --sysinfo=off --json -' % tmpdir) + result = process.run(cmd_line, ignore_status=True) + jobdir = ''.join(glob.glob(os.path.join(tmpdir, 'job-*'))) + idfile = ''.join(os.path.join(jobdir, 'id')) + + with open(idfile, 'r') as f: + jobid = f.read().strip('\n') + + cmd_line = ('avocado run --replay %s --remote-hostname ' + 'localhost --job-results-dir %s --sysinfo=off' % (jobid, tmpdir)) + expected_rc = exit_codes.AVOCADO_FAIL + result = process.run(cmd_line, ignore_status=True) + + self.assertEqual(result.exit_status, expected_rc, + "Command %s did not return rc " + "%d:\n%s" % (cmd_line, expected_rc, result)) + + msg = b"Currently we don't replay jobs in remote hosts." + self.assertIn(msg, result.stderr) + + shutil.rmtree(tmpdir) + if __name__ == '__main__': unittest.main() diff --git a/selftests/functional/test_replay_basic.py b/selftests/functional/test_replay_basic.py index 816bd471ff96a8b1883ac2291482c459f053d3e8..edca5c4d2cee63390bfd7ee583b7300ebde60a57 100644 --- a/selftests/functional/test_replay_basic.py +++ b/selftests/functional/test_replay_basic.py @@ -4,22 +4,12 @@ import shutil import tempfile import unittest -import pkg_resources - from avocado.core import exit_codes from avocado.utils import process from .. import AVOCADO, BASEDIR -def remote_capable(): - try: - pkg_resources.require('avocado-framework-plugin-runner-remote') - return True - except pkg_resources.DistributionNotFound: - return False - - class ReplayTests(unittest.TestCase): def setUp(self): @@ -154,20 +144,6 @@ class ReplayTests(unittest.TestCase): b'INTERRUPT 0') self.assertIn(msg, result.stdout) - @unittest.skipUnless(remote_capable(), - "Remote runner plugin is not available") - def test_run_replay_remotefail(self): - """ - Runs a replay job using remote plugin (not supported). - """ - cmd_line = ('%s run --replay %s --remote-hostname ' - 'localhost --job-results-dir %s --sysinfo=off' - % (AVOCADO, self.jobid, self.tmpdir)) - expected_rc = exit_codes.AVOCADO_FAIL - result = self.run_and_check(cmd_line, expected_rc) - msg = b"Currently we don't replay jobs in remote hosts." - self.assertIn(msg, result.stderr) - def test_run_replay_status_and_variants(self): """ Runs a replay job with custom variants using '--replay-test-status'