Merge remote-tracking branch 'origin/dmw'

Test fixes.
pull/350/head
David Wilson 6 years ago
commit d1236bd8ff

@ -72,4 +72,4 @@ matrix:
# Sanity check against vanilla Ansible. One job suffices. # Sanity check against vanilla Ansible. One job suffices.
- python: "2.7" - python: "2.7"
env: MODE=ansible VER=2.6.2 DISTRO=debian STRATEGY=linear env: MODE=ansible VER=2.6.2 DISTROS=debian STRATEGY=linear

@ -175,6 +175,30 @@ def create_socketpair():
return parentfp, childfp return parentfp, childfp
def detach_popen(*args, **kwargs):
"""
Use :class:`subprocess.Popen` to construct a child process, then hack the
Popen so that it forgets the child it created, allowing it to survive a
call to Popen.__del__.
If the child process is not detached, there is a race between it exitting
and __del__ being called. If it exits before __del__ runs, then __del__'s
call to :func:`os.waitpid` will capture the one and only exit event
delivered to this process, causing later 'legitimate' calls to fail with
ECHILD.
:returns:
Process ID of the new child.
"""
# This allows Popen() to be used for e.g. graceful post-fork error
# handling, without tying the surrounding code into managing a Popen
# object, which isn't possible for at least :mod:`mitogen.fork`. This
# should be replaced by a swappable helper class in a future version.
proc = subprocess.Popen(*args, **kwargs)
proc._child_created = False
return proc.pid
def create_child(args, merge_stdio=False, preexec_fn=None): def create_child(args, merge_stdio=False, preexec_fn=None):
""" """
Create a child process whose stdin/stdout is connected to a socket. Create a child process whose stdin/stdout is connected to a socket.
@ -201,7 +225,7 @@ def create_child(args, merge_stdio=False, preexec_fn=None):
else: else:
extra = {} extra = {}
proc = subprocess.Popen( pid = detach_popen(
args=args, args=args,
stdin=childfp, stdin=childfp,
stdout=childfp, stdout=childfp,
@ -215,8 +239,8 @@ def create_child(args, merge_stdio=False, preexec_fn=None):
parentfp.close() parentfp.close()
LOG.debug('create_child() child %d fd %d, parent %d, cmd: %s', LOG.debug('create_child() child %d fd %d, parent %d, cmd: %s',
proc.pid, fd, os.getpid(), Argv(args)) pid, fd, os.getpid(), Argv(args))
return proc.pid, fd, None return pid, fd, None
def _acquire_controlling_tty(): def _acquire_controlling_tty():
@ -250,7 +274,7 @@ def tty_create_child(args):
disable_echo(master_fd) disable_echo(master_fd)
disable_echo(slave_fd) disable_echo(slave_fd)
proc = subprocess.Popen( pid = detach_popen(
args=args, args=args,
stdin=slave_fd, stdin=slave_fd,
stdout=slave_fd, stdout=slave_fd,
@ -261,8 +285,8 @@ def tty_create_child(args):
os.close(slave_fd) os.close(slave_fd)
LOG.debug('tty_create_child() child %d fd %d, parent %d, cmd: %s', LOG.debug('tty_create_child() child %d fd %d, parent %d, cmd: %s',
proc.pid, master_fd, os.getpid(), Argv(args)) pid, master_fd, os.getpid(), Argv(args))
return proc.pid, master_fd, None return pid, master_fd, None
def hybrid_tty_create_child(args): def hybrid_tty_create_child(args):
@ -284,7 +308,7 @@ def hybrid_tty_create_child(args):
mitogen.core.set_block(childfp) mitogen.core.set_block(childfp)
disable_echo(master_fd) disable_echo(master_fd)
disable_echo(slave_fd) disable_echo(slave_fd)
proc = subprocess.Popen( pid = detach_popen(
args=args, args=args,
stdin=childfp, stdin=childfp,
stdout=childfp, stdout=childfp,
@ -300,8 +324,8 @@ def hybrid_tty_create_child(args):
parentfp.close() parentfp.close()
LOG.debug('hybrid_tty_create_child() pid=%d stdio=%d, tty=%d, cmd: %s', LOG.debug('hybrid_tty_create_child() pid=%d stdio=%d, tty=%d, cmd: %s',
proc.pid, stdio_fd, master_fd, Argv(args)) pid, stdio_fd, master_fd, Argv(args))
return proc.pid, stdio_fd, master_fd return pid, stdio_fd, master_fd
def write_all(fd, s, deadline=None): def write_all(fd, s, deadline=None):

@ -8,6 +8,9 @@
gather_facts: no gather_facts: no
any_errors_fatal: true any_errors_fatal: true
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
register: out register: out
@ -20,6 +23,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'cd-normal-alias', 'hostname': 'cd-normal-alias',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,

@ -19,6 +19,9 @@
- name: integration/delegation/stack_construction.yml - name: integration/delegation/stack_construction.yml
hosts: cd-normal hosts: cd-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
# used later for local_action test. # used later for local_action test.
- local_action: custom_python_detect_environment - local_action: custom_python_detect_environment
register: local_env register: local_env
@ -27,6 +30,9 @@
- hosts: cd-normal - hosts: cd-normal
any_errors_fatal: true any_errors_fatal: true
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:
@ -47,6 +53,9 @@
- hosts: cd-normal - hosts: cd-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
delegate_to: cd-alias delegate_to: cd-alias
register: out register: out
@ -58,6 +67,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'alias-host', 'hostname': 'alias-host',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -81,6 +91,9 @@
- hosts: cd-alias - hosts: cd-alias
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:
@ -91,6 +104,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'alias-host', 'hostname': 'alias-host',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -114,6 +128,9 @@
- hosts: cd-normal-normal - hosts: cd-normal-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:
@ -134,6 +151,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'cd-normal-normal', 'hostname': 'cd-normal-normal',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -157,6 +175,9 @@
- hosts: cd-normal-alias - hosts: cd-normal-alias
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:
@ -167,6 +188,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'alias-host', 'hostname': 'alias-host',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -190,6 +212,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'cd-normal-alias', 'hostname': 'cd-normal-alias',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -213,6 +236,9 @@
- hosts: cd-newuser-normal-normal - hosts: cd-newuser-normal-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:
@ -233,6 +259,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'cd-newuser-normal-normal', 'hostname': 'cd-newuser-normal-normal',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -256,6 +283,9 @@
- hosts: cd-newuser-normal-normal - hosts: cd-newuser-normal-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
delegate_to: cd-alias delegate_to: cd-alias
register: out register: out
@ -267,6 +297,7 @@
'check_host_keys': 'ignore', 'check_host_keys': 'ignore',
'connect_timeout': 10, 'connect_timeout': 10,
'hostname': 'alias-host', 'hostname': 'alias-host',
'identities_only': False,
'identity_file': None, 'identity_file': None,
'password': None, 'password': None,
'port': None, 'port': None,
@ -290,6 +321,9 @@
- hosts: cd-newuser-normal-normal - hosts: cd-newuser-normal-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- local_action: mitogen_get_stack - local_action: mitogen_get_stack
register: out register: out
- assert: - assert:
@ -308,6 +342,9 @@
- hosts: cd-newuser-doas-normal - hosts: cd-newuser-doas-normal
tasks: tasks:
- meta: end_play
when: not is_mitogen
- mitogen_get_stack: - mitogen_get_stack:
register: out register: out
- assert: - assert:

Loading…
Cancel
Save