From e1f8c402737b4daaa83ace9cdfde818631b6e4cc Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 15 Nov 2025 22:38:35 +0100 Subject: [PATCH] Adjust load tests. --- .../docker_image_load/tasks/tests/basic.yml | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/tests/integration/targets/docker_image_load/tasks/tests/basic.yml b/tests/integration/targets/docker_image_load/tasks/tests/basic.yml index 73d6482c..3748c55d 100644 --- a/tests/integration/targets/docker_image_load/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_image_load/tasks/tests/basic.yml @@ -73,11 +73,17 @@ loop: "{{ all_images }}" when: remove_all_images is failed +- name: Show all images + ansible.builtin.command: docker image ls + - name: Load all images (IDs) community.docker.docker_image_load: path: "{{ remote_tmp_dir }}/archive-2.tar" register: result +- name: Show all images + ansible.builtin.command: docker image ls + - name: Print loaded image names ansible.builtin.debug: var: result.image_names @@ -110,11 +116,17 @@ name: "{{ item }}" loop: "{{ all_images }}" +- name: Show all images + ansible.builtin.command: docker image ls + - name: Load all images (mixed images and IDs) community.docker.docker_image_load: path: "{{ remote_tmp_dir }}/archive-3.tar" register: result +- name: Show all images + ansible.builtin.command: docker image ls + - name: Print loading log ansible.builtin.debug: var: result.stdout_lines @@ -127,10 +139,14 @@ that: - 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 - - "result.images | length == 3 or ('Loaded image: ' ~ docker_test_image_hello_world) == result.stdout" - - (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 | map(attribute='Id') | sort) in [[image_ids[0], image_ids[0], image_ids[1]] | sort, [image_ids[0]]] + # With Docker 29, a third possibility appears: just two entries. + - >- + result.images | length == 3 + 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 @@ -139,11 +155,17 @@ name: "{{ item }}" loop: "{{ all_images }}" +- name: Show all images + ansible.builtin.command: docker image ls + - name: Load all images (same image twice) community.docker.docker_image_load: path: "{{ remote_tmp_dir }}/archive-4.tar" register: result +- name: Show all images + ansible.builtin.command: docker image ls + - name: Print loaded image names ansible.builtin.debug: var: result.image_names @@ -151,10 +173,11 @@ - ansible.builtin.assert: that: - result is changed - - result.image_names | length == 1 - - result.image_names[0] == image_names[0] - - result.images | length == 1 + - result.image_names | length in [1, 2] + - (result.image_names | sort) in [[image_names[0]], [image_names[0], image_ids[0]] | sort] + - result.images | length in [1, 2] - result.images[0].Id == image_ids[0] + - result.images[1].Id | default(image_ids[0]) == image_ids[0] # Single image by ID @@ -163,11 +186,17 @@ name: "{{ item }}" loop: "{{ all_images }}" +- name: Show all images + ansible.builtin.command: docker image ls + - name: Load all images (single image by ID) community.docker.docker_image_load: path: "{{ remote_tmp_dir }}/archive-5.tar" register: result +- name: Show all images + ansible.builtin.command: docker image ls + - name: Print loaded image names ansible.builtin.debug: var: result.image_names @@ -197,11 +226,17 @@ name: "{{ item }}" loop: "{{ all_images }}" +- name: Show all images + ansible.builtin.command: docker image ls + - name: Load all images (names) community.docker.docker_image_load: path: "{{ remote_tmp_dir }}/archive-1.tar" register: result +- name: Show all images + ansible.builtin.command: docker image ls + - name: Print loaded image names ansible.builtin.debug: var: result.image_names