Skip to content

Commit

Permalink
Fixed an execution problem relating to the attempts attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenden committed Sep 9, 2018
1 parent 9b8527b commit b0726c4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/deployer/plugins/plugin_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _execute_one(self, context):
if not result and count < self._attempts:
LOGGER.warn("Task failed, will retry again. This is the %d time." % count)
time.sleep(count * count)
elif not result:
else:
break

if not self._attempts <= 1 and count >= self._attempts:
Expand Down
33 changes: 33 additions & 0 deletions tests/plugins/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from hamcrest import equal_to
from hamcrest import has_entry
from hamcrest import instance_of
from hamcrest import is_not
from six import StringIO

from deployer import loader
Expand Down Expand Up @@ -218,3 +219,35 @@ def test_plugin_matrix_runs_with_two_matrices_and_contains_tags(caplog):

assert_that(context.variables.last(), not has_entry('matrix_tag', 'm2'))
assert_that(context.variables.last(), not has_entry('matrix_list', ['m2']))


def test_plugin_matrix_runs_with_two_matrices_with_multiple_attempts(caplog):
stream = StringIO('''
- name: test1
matrix:
tags:
- m1
- m2
tasks:
- name: test2
matrix:
tags:
- m3
tasks:
- name: Testing task
echo: Hello world.
attempts: 3
''')
document = loader.ordered_load(stream)

assert_that(TopLevel.valid(document), equal_to(True))

nodes = TopLevel.build(document)

context = Context()

for node in nodes:
node.execute(context)

assert_that(caplog.text, contains_string('Hello world.'))
assert_that(caplog.text, is_not(contains_string('failure')))

0 comments on commit b0726c4

Please sign in to comment.