Skip to content

Commit

Permalink
Fix error in ansible parsing if no fatal tasks or fatal tasks number …
Browse files Browse the repository at this point in the history
…is less than rescued+1 (#69)
  • Loading branch information
Dmitry Gusakov authored Oct 9, 2021
1 parent 8eb8f3c commit 12b110e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
version="4.9.3",
version="4.9.4",
# the following makes a plugin available to pytest
entry_points={"pytest11": ["adcm_pytest_plugin = adcm_pytest_plugin.plugin"]},
# custom PyPI classifier for pytest plugins
Expand Down
14 changes: 13 additions & 1 deletion src/adcm_pytest_plugin/steps/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,22 @@ def _extract_error_from_ansible_stdout(log: str):
... host-3 : ok=20 changed=0 failed=2 skipped=5 rescued=0 ignored=0
... ''')
'TASK [failed task] ***\\ndatetime *****\\nfatal: [fqdn]: FAILED! => changed=false\\nmsg: 1\\n'
>>> this('''
... TASK [api : something] ***
... datetime ***
... ok: [fqdn]
... msg: All assertions passed"
... NO MORE HOSTS LEFT *********
... PLAY RECAP *********************************************************************
... host-1 : ok=7 changed=0 failed=0 skipped=3 rescued=1 ignored=0
... host-2 : ok=7 changed=0 failed=0 skipped=3 rescued=0 ignored=0
... host-3 : ok=20 changed=0 failed=2 skipped=5 rescued=0 ignored=0
... ''')
''
"""
rescued = _get_rescued_count_from_log(log)
failed_tasks = _get_all_fatal_from_ansible_stdout(log)
return failed_tasks[rescued]
return failed_tasks[rescued] if len(failed_tasks) > rescued else "\n".join(failed_tasks)


def _get_all_fatal_from_ansible_stdout(log: str):
Expand Down

0 comments on commit 12b110e

Please sign in to comment.