Adjust load tests.

This commit is contained in:
Felix Fontein 2025-11-15 22:38:35 +01:00
parent 44a1dd33c2
commit e1f8c40273

View File

@ -73,11 +73,17 @@
loop: "{{ all_images }}" loop: "{{ all_images }}"
when: remove_all_images is failed when: remove_all_images is failed
- name: Show all images
ansible.builtin.command: docker image ls
- name: Load all images (IDs) - name: Load all images (IDs)
community.docker.docker_image_load: community.docker.docker_image_load:
path: "{{ remote_tmp_dir }}/archive-2.tar" path: "{{ remote_tmp_dir }}/archive-2.tar"
register: result register: result
- name: Show all images
ansible.builtin.command: docker image ls
- name: Print loaded image names - name: Print loaded image names
ansible.builtin.debug: ansible.builtin.debug:
var: result.image_names var: result.image_names
@ -110,11 +116,17 @@
name: "{{ item }}" name: "{{ item }}"
loop: "{{ all_images }}" loop: "{{ all_images }}"
- name: Show all images
ansible.builtin.command: docker image ls
- name: Load all images (mixed images and IDs) - name: Load all images (mixed images and IDs)
community.docker.docker_image_load: community.docker.docker_image_load:
path: "{{ remote_tmp_dir }}/archive-3.tar" path: "{{ remote_tmp_dir }}/archive-3.tar"
register: result register: result
- name: Show all images
ansible.builtin.command: docker image ls
- name: Print loading log - name: Print loading log
ansible.builtin.debug: ansible.builtin.debug:
var: result.stdout_lines var: result.stdout_lines
@ -127,10 +139,14 @@
that: that:
- result is changed - result is changed
# For some reason, *sometimes* only the named image is found; in fact, in that case, the log only mentions that image and nothing else # For some reason, *sometimes* only the named image is found; in fact, in that case, the log only mentions that image and nothing else
- "result.images | length == 3 or ('Loaded image: ' ~ docker_test_image_hello_world) == result.stdout" # With Docker 29, a third possibility appears: just two entries.
- (result.image_names | sort) in [[image_names[0], image_ids[0], image_ids[1]] | sort, [image_names[0]]] - >-
- result.images | length in [1, 3] result.images | length == 3
- (result.images | map(attribute='Id') | sort) in [[image_ids[0], image_ids[0], image_ids[1]] | sort, [image_ids[0]]] or ('Loaded image: ' ~ docker_test_image_hello_world) == result.stdout
or result.images | length == 2
- (result.image_names | sort) in [[image_names[0], image_ids[0], image_ids[1]] | sort, [image_names[0], image_ids[1]] | sort, [image_names[0]]]
- result.images | length in [1, 2, 3]
- (result.images | map(attribute='Id') | sort) in [[image_ids[0], image_ids[0], image_ids[1]] | sort, [image_ids[0], image_ids[1]] | sort, [image_ids[0]]]
# Same image twice # Same image twice
@ -139,11 +155,17 @@
name: "{{ item }}" name: "{{ item }}"
loop: "{{ all_images }}" loop: "{{ all_images }}"
- name: Show all images
ansible.builtin.command: docker image ls
- name: Load all images (same image twice) - name: Load all images (same image twice)
community.docker.docker_image_load: community.docker.docker_image_load:
path: "{{ remote_tmp_dir }}/archive-4.tar" path: "{{ remote_tmp_dir }}/archive-4.tar"
register: result register: result
- name: Show all images
ansible.builtin.command: docker image ls
- name: Print loaded image names - name: Print loaded image names
ansible.builtin.debug: ansible.builtin.debug:
var: result.image_names var: result.image_names
@ -151,10 +173,11 @@
- ansible.builtin.assert: - ansible.builtin.assert:
that: that:
- result is changed - result is changed
- result.image_names | length == 1 - result.image_names | length in [1, 2]
- result.image_names[0] == image_names[0] - (result.image_names | sort) in [[image_names[0]], [image_names[0], image_ids[0]] | sort]
- result.images | length == 1 - result.images | length in [1, 2]
- result.images[0].Id == image_ids[0] - result.images[0].Id == image_ids[0]
- result.images[1].Id | default(image_ids[0]) == image_ids[0]
# Single image by ID # Single image by ID
@ -163,11 +186,17 @@
name: "{{ item }}" name: "{{ item }}"
loop: "{{ all_images }}" loop: "{{ all_images }}"
- name: Show all images
ansible.builtin.command: docker image ls
- name: Load all images (single image by ID) - name: Load all images (single image by ID)
community.docker.docker_image_load: community.docker.docker_image_load:
path: "{{ remote_tmp_dir }}/archive-5.tar" path: "{{ remote_tmp_dir }}/archive-5.tar"
register: result register: result
- name: Show all images
ansible.builtin.command: docker image ls
- name: Print loaded image names - name: Print loaded image names
ansible.builtin.debug: ansible.builtin.debug:
var: result.image_names var: result.image_names
@ -197,11 +226,17 @@
name: "{{ item }}" name: "{{ item }}"
loop: "{{ all_images }}" loop: "{{ all_images }}"
- name: Show all images
ansible.builtin.command: docker image ls
- name: Load all images (names) - name: Load all images (names)
community.docker.docker_image_load: community.docker.docker_image_load:
path: "{{ remote_tmp_dir }}/archive-1.tar" path: "{{ remote_tmp_dir }}/archive-1.tar"
register: result register: result
- name: Show all images
ansible.builtin.command: docker image ls
- name: Print loaded image names - name: Print loaded image names
ansible.builtin.debug: ansible.builtin.debug:
var: result.image_names var: result.image_names