Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
moreati committed Jan 19, 2025
1 parent 9fa4e3e commit 8298abc
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ jobs:
with:
python-version: ${{ matrix.python_version }}
if: ${{ matrix.python_version }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Show Python versions
run: |
set -o errexit -o nounset -o pipefail
Expand Down
39 changes: 11 additions & 28 deletions tests/ansible/regression/issue_655__wait_for_connection_error.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
hosts: localhost
gather_facts: yes
become: no
tasks:

pre_tasks:
- meta: end_play
when:
# Podman versions available in Homebrew have dropped macOS 12 support.
# Podman versions available in Homebrew require macOS 13+ (Ventura).
# https://formulae.brew.sh/formula/podman
- ansible_facts.system == 'Darwin'
- ansible_facts.distribution_version is version('13.0', '<', strict=True)

Expand All @@ -21,28 +23,14 @@
# On CentOS 8 /usr/libexec/platform-python is Python 3.6
- ansible_version.full is version('2.17', '>=', strict=True)

roles:
- role: homebrew_podman
when:
- ansible_facts.pkg_mgr in ['homebrew']

tasks:
- name: set up test container and run tests inside it
block:
- name: install deps
homebrew:
name:
- podman
state: present

- name: start machine
command:
cmd: "{{ item.cmd }}"
loop:
- cmd: podman machine init
- cmd: podman machine start
- cmd: podman info
timeout: 300
register: podman_machine
changed_when: true

- debug:
var: podman_machine

# python bindings (docker_container) aren't working on this host, so gonna shell out
- name: create container
command:
Expand Down Expand Up @@ -98,12 +86,7 @@

- name: remove test container
command:
cmd: "{{ item.cmd }}"
loop:
- cmd: podman stop testMitogen
- cmd: podman machine stop
cmd: podman stop testMitogen
changed_when: true
when:
- ansible_facts.pkg_mgr in ['homebrew']
tags:
- issue_655
54 changes: 37 additions & 17 deletions tests/ansible/regression/issue_766__get_with_context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,59 @@
---
- name: regression/issue_766__get_with_context.yml
hosts: localhost
# Gather facts to use *and* to trigger any "could not recover task_vars" error
# https://github.com/mitogen-hq/mitogen/pull/1215#issuecomment-2596421111
gather_facts: true
vars:
netconf_container_image: ghcr.io/mitogen-hq/sysrepo-netopeer2:latest
netconf_container_name: sysprep
netconf_container_port: 8030

pre_tasks:
- meta: end_play
when:
# Podman versions available in Homebrew require macOS 13+ (Ventura).
# https://formulae.brew.sh/formula/podman
- ansible_facts.system == 'Darwin'
- ansible_facts.distribution_version is version('13.0', '<', strict=True)

roles:
- role: homebrew_podman
when:
- ansible_facts.pkg_mgr in ['homebrew']

tasks:
- block:
- name: Start container
delegate_to: localhost
vars:
ansible_port: 8040
containers.podman.podman_container:
name: sysprep
image: ghcr.io/mitogen-hq/sysrepo-netopeer2:latest
auto_remove: true
detach: true
recreate: true
published_ports:
- "{{ ansible_port }}:830"
command:
cmd: >-
podman run
--name "{{ netconf_container_name }}"
--detach
--rm
--publish "{{ netconf_container_port }}:830"
"{{ netconf_container_image }}"
changed_when: true

- name: Wait for container
delegate_to: localhost
# TODO robust condition. wait_for + search_regex? wait_for_connection?
wait_for:
timeout: 5

- name: Get running configuration and state data
vars:
ansible_port: 8040
ansible_connection: netconf
ansible_user: netconf
ansible_password: netconf
ansible_port: "{{ netconf_container_port }}"
ansible_host_key_checking: false
ansible_python_interpreter: "{{ ansible_playbook_python }}"
ansible.netcommon.netconf_get:

always:
- name: Cleanup container
delegate_to: localhost
containers.podman.podman_container:
name: sysprep
state: absent
command:
cmd: podman stop "{{ netconf_container_name }}"
changed_when: true
tags:
- issue_766
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Stop podman machine
command:
cmd: podman machine stop
changed_when: true
21 changes: 21 additions & 0 deletions tests/ansible/regression/roles/homebrew_podman/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- name: install deps
homebrew:
name:
- podman
state: present

- name: start machine
command:
cmd: "{{ item.cmd }}"
loop:
- cmd: podman machine init
- cmd: podman machine start
- cmd: podman info
timeout: 300
register: podman_machine
changed_when: true
handlers:
- Stop podman machine

- debug:
var: podman_machine
4 changes: 3 additions & 1 deletion tests/ansible/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
paramiko==2.3.2 # Last 2.6-compat version.
paramiko==2.12.0; python_version <= '2.7'
paramiko==3.5.0; python_version >= '3.6'

# Incompatible with pip >= 72, due to removal of `setup.py test`:
# ModuleNotFoundError: No module named 'setuptools.command.test'
# https://github.com/pypa/setuptools/issues/4519
Expand Down

0 comments on commit 8298abc

Please sign in to comment.