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.
- 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
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):
"""
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:
extra = {}
proc = subprocess.Popen(
pid = detach_popen(
args=args,
stdin=childfp,
stdout=childfp,
@ -215,8 +239,8 @@ def create_child(args, merge_stdio=False, preexec_fn=None):
parentfp.close()
LOG.debug('create_child() child %d fd %d, parent %d, cmd: %s',
proc.pid, fd, os.getpid(), Argv(args))
return proc.pid, fd, None
pid, fd, os.getpid(), Argv(args))
return pid, fd, None
def _acquire_controlling_tty():
@ -250,7 +274,7 @@ def tty_create_child(args):
disable_echo(master_fd)
disable_echo(slave_fd)
proc = subprocess.Popen(
pid = detach_popen(
args=args,
stdin=slave_fd,
stdout=slave_fd,
@ -261,8 +285,8 @@ def tty_create_child(args):
os.close(slave_fd)
LOG.debug('tty_create_child() child %d fd %d, parent %d, cmd: %s',
proc.pid, master_fd, os.getpid(), Argv(args))
return proc.pid, master_fd, None
pid, master_fd, os.getpid(), Argv(args))
return pid, master_fd, None
def hybrid_tty_create_child(args):
@ -284,7 +308,7 @@ def hybrid_tty_create_child(args):
mitogen.core.set_block(childfp)
disable_echo(master_fd)
disable_echo(slave_fd)
proc = subprocess.Popen(
pid = detach_popen(
args=args,
stdin=childfp,
stdout=childfp,
@ -300,8 +324,8 @@ def hybrid_tty_create_child(args):
parentfp.close()
LOG.debug('hybrid_tty_create_child() pid=%d stdio=%d, tty=%d, cmd: %s',
proc.pid, stdio_fd, master_fd, Argv(args))
return proc.pid, stdio_fd, master_fd
pid, stdio_fd, master_fd, Argv(args))
return pid, stdio_fd, master_fd
def write_all(fd, s, deadline=None):

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

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

Loading…
Cancel
Save