You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/tests/ansible/integration/connection/disconnect_resets_connectio...

50 lines
1.5 KiB
YAML

# issue 370: Connection should reset to 'disconnected' state when disconnect
# detected
#
# Previously the 'Mitogen was disconnected' error would fail the first task,
# but the Connection instance would still think it still had a valid
# connection.
#
# See also disconnect_during_module.yml
---
- name: integration/connection/disconnect_resets_connection.yml
hosts: test-targets
gather_facts: no
tasks:
- include_tasks: ../_mitogen_only.yml
- mitogen_action_script:
script: |
import sys
from ansible.errors import AnsibleConnectionFailure
assert not self._connection.connected, \
"Connection was not initially disconnected."
self._low_level_execute_command('echo')
assert self._connection.connected, \
"Connection was not connected after good command."
try:
self._low_level_execute_command('kill -9 $PPID')
assert 0, 'AnsibleConnectionFailure was not raised'
except AnsibleConnectionFailure:
e = sys.exc_info()[1]
assert str(e).startswith('Mitogen was disconnected')
assert not self._connection.connected, \
"Connection did not reset."
try:
self._low_level_execute_command('kill -9 $PPID')
assert 0, 'AnsibleConnectionFailure was not raised'
except AnsibleConnectionFailure:
e = sys.exc_info()[1]
assert str(e).startswith('Mitogen was disconnected')
tags:
- disconnect
- disconnect_resets_connection
- mitogen_only