Moves remote dependant test to proper plugin

There was a functional test on avocado that depended on remote plugin.
This change moves this test to proper plugin instead of run the test
only if the plugin is available during test execution.

Reference: https://trello.com/c/NPEUj0wZSigned-off-by: NCaio Carrara <ccarrara@redhat.com>
上级 989ca0b2
import argparse import argparse
import glob
import os
import shutil import shutil
import tempfile
import unittest import unittest
try: try:
...@@ -8,7 +11,7 @@ except ImportError: ...@@ -8,7 +11,7 @@ except ImportError:
import mock import mock
from avocado.core.job import Job from avocado.core.job import Job
from avocado.core import version from avocado.core import exit_codes, version
from avocado.utils import process from avocado.utils import process
import avocado_runner_remote import avocado_runner_remote
...@@ -110,6 +113,35 @@ class RemoteTestRunnerTest(unittest.TestCase): ...@@ -110,6 +113,35 @@ class RemoteTestRunnerTest(unittest.TestCase):
if job: if job:
shutil.rmtree(job.args.base_logdir) 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__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -4,22 +4,12 @@ import shutil ...@@ -4,22 +4,12 @@ import shutil
import tempfile import tempfile
import unittest import unittest
import pkg_resources
from avocado.core import exit_codes from avocado.core import exit_codes
from avocado.utils import process from avocado.utils import process
from .. import AVOCADO, BASEDIR 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): class ReplayTests(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -154,20 +144,6 @@ class ReplayTests(unittest.TestCase): ...@@ -154,20 +144,6 @@ class ReplayTests(unittest.TestCase):
b'INTERRUPT 0') b'INTERRUPT 0')
self.assertIn(msg, result.stdout) 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): def test_run_replay_status_and_variants(self):
""" """
Runs a replay job with custom variants using '--replay-test-status' Runs a replay job with custom variants using '--replay-test-status'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册