Skip to content

Commit 211079f

Browse files
Nihlusmoreatimarkafarrell
committed
Add regression tests for the new connection logic.
Co-authored-by: Alex Willmer <[email protected]> Co-authored-by: Mark Farrell <[email protected]>
1 parent 8ebeaff commit 211079f

File tree

4 files changed

+76
-2
lines changed

4 files changed

+76
-2
lines changed

tests/ansible/regression/all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- import_playbook: issue_591__setuptools_cwd_crash.yml
1414
- import_playbook: issue_615__streaming_transfer.yml
1515
- import_playbook: issue_655__wait_for_connection_error.yml
16+
- import_playbook: issue_766__get_with_context.yml
1617
- import_playbook: issue_776__load_plugins_called_twice.yml
1718
- import_playbook: issue_952__ask_become_pass.yml
1819
- import_playbook: issue_1066__add_host__host_key_checking.yml

tests/ansible/regression/issue_655__wait_for_connection_error.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
tasks:
1212
- meta: end_play
1313
when:
14-
# Podman versions available in Homebrew have dropped macOS 12 support.
14+
# Podman versions available in Homebrew require macOS 13+ (Ventura).
15+
# https://formulae.brew.sh/formula/podman
16+
# See also
17+
# - issue_766__get_with_context.yml
1518
- ansible_facts.system == 'Darwin'
1619
- ansible_facts.distribution_version is version('13.0', '<', strict=True)
1720

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# https://github.com/mitogen-hq/mitogen/issues/776
2+
---
3+
- name: regression/issue_766__get_with_context.yml
4+
hosts: localhost
5+
# Gather facts to use *and* to trigger any "could not recover task_vars" error
6+
# https://github.com/mitogen-hq/mitogen/pull/1215#issuecomment-2596421111
7+
gather_facts: true
8+
vars:
9+
netconf_container_image: ghcr.io/mitogen-hq/sysrepo-netopeer2:latest
10+
netconf_container_name: sysprep
11+
netconf_container_port: 8030
12+
13+
tasks:
14+
- meta: end_play
15+
when:
16+
# Podman can be installed on macOS, but authenticating to gchr.io isn't
17+
# worth the trouble right now.
18+
# See also
19+
# - issue_655__wait_for_connection_error.yml
20+
- ansible_facts.system == 'Darwin'
21+
22+
- meta: end_play
23+
when:
24+
# A failure during the ansible.netcommon.netconf_get task, when run
25+
# with Ansible 4 (ansible-core 2.11) & associated collections.
26+
# ansible.module_utils.connection.ConnectionError: Method not found
27+
# https://github.com/mitogen-hq/mitogen/actions/runs/12854359099/job/35838635886
28+
- ansible_version.full is version('2.11', '>=', strict=True)
29+
- ansible_version.full is version('2.12', '<', strict=True)
30+
31+
- block:
32+
- name: Start container
33+
command:
34+
cmd: >-
35+
podman run
36+
--name "{{ netconf_container_name }}"
37+
--detach
38+
--rm
39+
--publish "{{ netconf_container_port }}:830"
40+
"{{ netconf_container_image }}"
41+
changed_when: true
42+
43+
- name: Wait for container
44+
# TODO robust condition. wait_for + search_regex? wait_for_connection?
45+
wait_for:
46+
timeout: 5
47+
48+
- name: Get running configuration and state data
49+
vars:
50+
ansible_connection: netconf
51+
ansible_user: netconf
52+
ansible_password: netconf
53+
ansible_port: "{{ netconf_container_port }}"
54+
ansible_host_key_checking: false
55+
ansible_python_interpreter: "{{ ansible_playbook_python }}"
56+
ansible.netcommon.netconf_get:
57+
58+
always:
59+
- name: Cleanup container
60+
command:
61+
cmd: podman stop "{{ netconf_container_name }}"
62+
changed_when: true
63+
tags:
64+
- issue_766

tests/ansible/requirements.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
paramiko==2.3.2 # Last 2.6-compat version.
1+
paramiko==2.12.0; python_version <= '2.7'
2+
paramiko==3.5.0; python_version >= '3.6'
3+
24
# Incompatible with pip >= 72, due to removal of `setup.py test`:
35
# ModuleNotFoundError: No module named 'setuptools.command.test'
46
# https://github.com/pypa/setuptools/issues/4519
57
hdrhistogram==0.6.1
8+
9+
ncclient==0.6.13; python_version <= '2.7'
10+
ncclient==0.6.16; python_version > '2.7'
11+
612
PyYAML==3.11; python_version < '2.7'
713
PyYAML==5.3.1; python_version >= '2.7' # Latest release (Jan 2021)

0 commit comments

Comments
 (0)