from teuthology.config import config as teuth_config
from teuthology.exceptions import CommandFailedError, AnsibleFailedError
+from teuthology.job_status import set_status
from teuthology.repo_utils import fetch_repo
from . import Task
remote.reconnect()
def _handle_failure(self, command, status):
+ self._set_status('dead')
failures = None
with open(self.failure_log.name, 'r') as fail_log:
try:
raise AnsibleFailedError(failures)
raise CommandFailedError(command, status)
+ def _set_status(self, status):
+ """
+ Not implemented in the base class
+ """
+ pass
+
def _archive_failures(self):
if self.ctx.archive:
archive_path = "{0}/ansible_failures.yaml".format(self.ctx.archive)
pass
super(CephLab, self).begin()
+ def _set_status(self, status):
+ set_status(self.ctx.summary, status)
+
task = Ansible
cephlab = CephLab
self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
self.ctx.config = dict()
+ self.ctx.summary = dict()
self.task_config = dict(playbook=[])
self.start_patchers()
m_run.return_value = ('', 1)
with raises(CommandFailedError):
task.execute_playbook()
+ assert task.ctx.summary.get('status') is None
def test_build_args_no_tags(self):
self.task_config.update(dict(
'remote1\n',
'remote2\n',
]
+
+ def test_fail_status_dead(self):
+ self.task_config.update(dict(
+ playbook=[],
+ ))
+ task = self.klass(self.ctx, self.task_config)
+ task.ctx.summary = dict()
+ task.setup()
+ with patch.object(ansible.pexpect, 'run') as m_run:
+ with patch('teuthology.task.ansible.open') as m_open:
+ fake_failure_log = Mock()
+ fake_failure_log.__enter__ = Mock()
+ fake_failure_log.__exit__ = Mock()
+ m_open.return_value = fake_failure_log
+ m_run.return_value = ('', 1)
+ with raises(CommandFailedError):
+ task.execute_playbook()
+ assert task.ctx.summary.get('status') == 'dead'
self.ctx.cluster.add(Remote('user@remote1'), ['mon.0'])
self.ctx.cluster.add(Remote('user@remote2'), ['mds.0'])
self.ctx.cluster.add(Remote('user@remote3'), ['osd.0'])
+ self.ctx.summary = dict()
self.ctx.config = dict()
self.task_config = dict()
self.start_patchers()