Compare commits

...
Author SHA1 Message Date
Defame1297 be8c3f2ed9 test(docker): merge the verify role runs and assert a unit change keeps dockerd running
Build / build (pull_request) Successful in 34s
Lint / lint (pull_request) Successful in 3m36s
Molecule / molecule (pull_request) Successful in 7m0s
The verify ran the role four times to switch the unit, daemon and restart
inputs, and each run refreshed apt against the stand-in repository. Nothing
showed that removing a unit leaves dockerd running.

The daemon-settings check now runs before any role run; those runs set no
daemon input until the last play, so daemon.json still holds converge's
content. One play then runs the role twice: first with the boot unit off, a
daemon change and no restart, asserting the units, the new value and an
unchanged dockerd start time; then with both units on and a restart,
asserting the boot unit is back, the value and a new start time.

Closes #460

Assisted-by: Claude Code
2026-11-28 20:39:19 +00:00
+42 -52
View File
@@ -297,48 +297,7 @@
changed_when: false changed_when: false
failed_when: docker_verify_start_run.rc != 2 failed_when: docker_verify_start_run.rc != 2
# Switching an input back to false removes that unit and script and leaves the other alone. # Converge's daemon.json, read before the role runs below change it.
- name: Verify that a unit is removed when its input is false
hosts: all
vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser]
docker_start_missed: false
docker_stop_at_shutdown: true
docker_stop_at_shutdown_timeout: 20
tasks:
- name: Stat the stand-in repository key
ansible.builtin.stat:
path: /srv/docker-stub-repo/docker.asc
checksum_algorithm: sha256
register: docker_stub_key
- name: Apply the role with the boot unit off
ansible.builtin.include_role:
name: mortis.kamino.docker
- name: Stat the boot unit's files and the shutdown unit's script
ansible.builtin.stat:
path: "{{ item }}"
loop:
- /usr/local/sbin/docker-start-missed
- /etc/systemd/system/docker-start-missed.service
- /usr/local/sbin/docker-stop-at-shutdown
register: docker_verify_off
- name: The boot unit is gone and the shutdown unit is still there
ansible.builtin.assert:
that: docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
quiet: true
- name: Apply the role again with both inputs on
ansible.builtin.include_role:
name: mortis.kamino.docker
vars:
docker_start_missed: true
- name: Verify the daemon settings - name: Verify the daemon settings
hosts: all hosts: all
gather_facts: false gather_facts: false
@@ -369,22 +328,26 @@
- docker_verify_daemon_stat.stat.pw_name == 'root' - docker_verify_daemon_stat.stat.pw_name == 'root'
quiet: true quiet: true
# The stand-in docker.service runs for real, so a restart shows in its start time: a changed file with docker_daemon_restart false leaves # The stand-in docker.service runs for real, so a restart shows in its start time. The first run turns the boot unit off and changes
# it alone, and with true restarts it. # daemon.json with docker_daemon_restart false: the unit goes, the other stays and dockerd keeps running. The second turns everything
- name: Verify that dockerd restarts only when asked # back on with docker_daemon_restart true: the boot unit returns and dockerd restarts.
- name: Verify the unit inputs and that dockerd restarts only when asked
hosts: all hosts: all
vars: vars:
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}" docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
docker_repo_base_url: file:///srv/docker-stub-repo docker_repo_base_url: file:///srv/docker-stub-repo
docker_users: [moleculeuser] docker_users: [moleculeuser]
docker_start_missed: true
docker_stop_at_shutdown: true docker_stop_at_shutdown: true
docker_stop_at_shutdown_timeout: 20 docker_stop_at_shutdown_timeout: 20
docker_log_driver: local docker_log_driver: local
docker_log_max_size: 10m docker_log_max_size: 10m
docker_log_max_file: "3" docker_log_max_file: "3"
docker_live_restore: true docker_live_restore: true
docker_verify_unit_paths:
- /usr/local/sbin/docker-start-missed
- /etc/systemd/system/docker-start-missed.service
- /usr/local/sbin/docker-stop-at-shutdown
tasks: tasks:
- name: Stat the stand-in repository key - name: Stat the stand-in repository key
ansible.builtin.stat: ansible.builtin.stat:
@@ -397,10 +360,11 @@
register: docker_verify_before register: docker_verify_before
changed_when: false changed_when: false
- name: Apply a changed setting with docker_daemon_restart false - name: Apply the boot unit off and a changed setting with docker_daemon_restart false
ansible.builtin.include_role: ansible.builtin.include_role:
name: mortis.kamino.docker name: mortis.kamino.docker
vars: vars:
docker_start_missed: false
docker_daemon_options: {max-concurrent-downloads: 5} docker_daemon_options: {max-concurrent-downloads: 5}
docker_daemon_restart: false docker_daemon_restart: false
@@ -409,10 +373,30 @@
register: docker_verify_kept register: docker_verify_kept
changed_when: false changed_when: false
- name: Apply another change with docker_daemon_restart true - name: Stat the boot unit's files and the shutdown unit's script
ansible.builtin.stat:
path: "{{ item }}"
loop: "{{ docker_verify_unit_paths }}"
register: docker_verify_off
- name: Read daemon.json
ansible.builtin.slurp:
src: /etc/docker/daemon.json
register: docker_verify_daemon_kept
- name: The boot unit is gone, the shutdown unit is still there, and the changed file left dockerd running
ansible.builtin.assert:
that:
- docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
- (docker_verify_daemon_kept.content | b64decode | from_json)['max-concurrent-downloads'] == 5
- docker_verify_kept.stdout == docker_verify_before.stdout
quiet: true
- name: Apply both units on and another change with docker_daemon_restart true
ansible.builtin.include_role: ansible.builtin.include_role:
name: mortis.kamino.docker name: mortis.kamino.docker
vars: vars:
docker_start_missed: true
docker_daemon_options: {max-concurrent-downloads: 6} docker_daemon_options: {max-concurrent-downloads: 6}
docker_daemon_restart: true docker_daemon_restart: true
@@ -421,17 +405,23 @@
register: docker_verify_restarted register: docker_verify_restarted
changed_when: false changed_when: false
- name: Read daemon.json - name: Stat the unit files again
ansible.builtin.stat:
path: "{{ item }}"
loop: "{{ docker_verify_unit_paths }}"
register: docker_verify_on
- name: Read daemon.json again
ansible.builtin.slurp: ansible.builtin.slurp:
src: /etc/docker/daemon.json src: /etc/docker/daemon.json
register: docker_verify_daemon_after register: docker_verify_daemon_after
- name: The first change left dockerd alone and the second restarted it - name: Both units are back and the second change restarted dockerd
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- docker_verify_kept.stdout == docker_verify_before.stdout - docker_verify_on.results | map(attribute='stat.exists') | unique | list == [true]
- docker_verify_restarted.stdout != docker_verify_kept.stdout
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6 - (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
- docker_verify_restarted.stdout != docker_verify_kept.stdout
quiet: true quiet: true
# A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so # A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so