tests: Ansible SSH timeout test

Also change Docker image to new 'mitogen' organization.
pull/244/head
David Wilson 7 years ago
parent 3058efc80f
commit 6109de51a0

@ -8,6 +8,9 @@ library = lib/modules
retry_files_enabled = False
forks = 50
# Required by integration/ssh/timeouts.yml
timeout = 3
# On Travis, paramiko check fails due to host key checking enabled.
host_key_checking = False

@ -2,6 +2,9 @@
[test-targets]
localhost
[slow-connect-targets]
slow-localhost ansible_host=localhost ansible_user=mitogen__slow_user ansible_password=slow_user_password
[connection-delegation-test]
cd-bastion
cd-rack11 mitogen_via=ssh-user@cd-bastion

@ -11,3 +11,4 @@
- import_playbook: playbook_semantics/all.yml
- import_playbook: remote_tmp/all.yml
- import_playbook: runner/all.yml
- import_playbook: ssh/all.yml

@ -0,0 +1 @@
- import_playbook: timeouts.yml

@ -0,0 +1,20 @@
# Ensure 'ssh' connections time out correctly.
- name: integration/ssh/timeouts_wrapper.yml
hosts: test-targets
tasks:
- connection: local
command: ansible slow-connect-targets -m custom_python_detect_environment #debug -a msg="--{{ 69 + 42 }}--"
register: out
ignore_errors: true
when: is_mitogen
- assert:
that:
- |
'"changed": false' in out.stdout
- |
'"unreachable": true' in out.stdout
- |
'"msg": "Connection timed out."' in out.stdout
when: is_mitogen

@ -29,6 +29,7 @@
- require_tty
- pw_required
- require_tty_pw_required
- slow_user
when: ansible_system != 'Darwin'
- name: Create Mitogen test users
@ -52,6 +53,7 @@
- pw_required
- require_tty_pw_required
- readonly_homedir
- slow_user
when: ansible_system == 'Darwin'
- name: Create Mitogen test users
@ -88,6 +90,14 @@
- name: Readonly homedir for one account
shell: "chown -R root: ~mitogen__readonly_homedir"
- name: Slow bash profile for one account
copy:
dest: ~mitogen__slow_user/.{{item}}
src: ../data/docker/mitogen__slow_user.profile
with_items:
- bashrc
- profile
- name: Require a TTY for two accounts
lineinfile:
path: /etc/sudoers

@ -47,6 +47,7 @@ RUN \
useradd -s /bin/bash -m mitogen__require_tty && \
useradd -s /bin/bash -m mitogen__require_tty_pw_required && \
useradd -s /bin/bash -m mitogen__readonly_homedir && \
useradd -s /bin/bash -m mitogen__slow_user && \
chown -R root: ~mitogen__readonly_homedir && \
{ for i in `seq 1 21`; do useradd -s /bin/bash -m mitogen__user$i; done; } && \
( echo 'root:rootpassword' | chpasswd; ) && \
@ -58,10 +59,14 @@ RUN \
( echo 'mitogen__require_tty:require_tty_password' | chpasswd; ) && \
( echo 'mitogen__require_tty_pw_required:require_tty_pw_required_password' | chpasswd; ) && \
( echo 'mitogen__readonly_homedir:readonly_homedir_password' | chpasswd; ) && \
( echo 'mitogen__slow_user:slow_user_password' | chpasswd; ) && \
mkdir ~mitogen__has_sudo_pubkey/.ssh && \
{ echo '#!/bin/bash\nexec strace -ff -o /tmp/pywrap$$.trace python2.7 "$@"' > /usr/local/bin/pywrap; chmod +x /usr/local/bin/pywrap; }
COPY data/docker/mitogen__has_sudo_pubkey.key.pub /home/mitogen__has_sudo_pubkey/.ssh/authorized_keys
COPY data/docker/mitogen__slow_user.profile /home/mitogen__slow_user/.profile
COPY data/docker/mitogen__slow_user.profile /home/mitogen__slow_user/.bashrc
RUN \
chown -R mitogen__has_sudo_pubkey ~mitogen__has_sudo_pubkey && \
chmod -R go= ~mitogen__has_sudo_pubkey
@ -93,6 +98,6 @@ for (distro, wheel, prefix) in (('debian', 'sudo', DEBIAN_DOCKERFILE),
subprocess.check_call(sh('docker build %s -t %s -f %s',
mydir,
'd2mw/mitogen-%s-test' % (distro,),
'mitogen/%s-test' % (distro,),
dockerfile_fp.name
))

@ -0,0 +1,3 @@
# mitogen__slow_user takes forever to log in.
sleep 10

@ -175,7 +175,7 @@ class DockerizedSshDaemon(object):
def get_image(self):
if not self.image:
distro = os.environ.get('MITOGEN_TEST_DISTRO', 'debian')
self.image = 'd2mw/mitogen-%s-test' % (distro,)
self.image = 'mitogen/%s-test' % (distro,)
return self.image
def __init__(self):

Loading…
Cancel
Save