Improve and fix tests (#36)

* Parameterize test images.

* Use different images, similar to ansible/ansible#72698.
This commit is contained in:
Felix Fontein
2020-11-23 21:48:46 +01:00
committed by GitHub
parent 1fa2c3b77d
commit 219c6b3a85
55 changed files with 804 additions and 778 deletions
@@ -10,6 +10,21 @@
- debug:
msg: "Using name prefix {{ name_prefix }}"
- name: Create files directory
file:
path: '{{ output_dir }}/files'
state: directory
- name: Template files
template:
src: '{{ item }}'
dest: '{{ output_dir }}/files/{{ item }}'
loop:
- Dockerfile
- EtcHostsDockerfile
- MyDockerfile
- StagedDockerfile
- block:
- include_tasks: run-test.yml
with_fileglob:
@@ -5,14 +5,14 @@
- name: Make sure image is not there
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
state: absent
force_absent: yes
register: absent_1
- name: Make sure image is not there (idempotency)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
state: absent
register: absent_2
@@ -22,14 +22,14 @@
- name: Make sure image is there
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
state: present
source: pull
register: present_1
- name: Make sure image is there (idempotent)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
state: present
source: pull
register: present_2
@@ -41,28 +41,28 @@
- name: Make sure tag is not there
docker_image:
name: "hello-world:alias"
name: "{{ docker_test_image_hello_world }}:alias"
state: absent
- name: Tag image with alias
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ docker_test_image_hello_world }}:alias"
register: tag_1
- name: Tag image with alias (idempotent)
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ docker_test_image_hello_world }}:alias"
register: tag_2
- name: Tag image with alias (force, still idempotent)
docker_image:
source: local
name: "hello-world:latest"
repository: "hello-world:alias"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ docker_test_image_hello_world }}:alias"
force_tag: yes
register: tag_3
@@ -74,5 +74,5 @@
- name: Cleanup alias tag
docker_image:
name: "hello-world:alias"
name: "{{ docker_test_image_hello_world }}:alias"
state: absent
@@ -22,14 +22,14 @@
state: absent
force_absent: yes
- name: Make sure we have hello-world:latest
- name: Make sure we have {{ docker_test_image_hello_world }}:latest
docker_image:
name: hello-world:latest
name: "{{ docker_test_image_hello_world }}:latest"
source: pull
- name: Push image to test registry
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ hello_world_image_base }}"
push: yes
source: local
@@ -37,7 +37,7 @@
- name: Push image to test registry (idempotent)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ hello_world_image_base }}"
push: yes
source: local
@@ -45,7 +45,7 @@
- name: Push image to test registry (force, still idempotent)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
repository: "{{ hello_world_image_base }}"
push: yes
source: local
@@ -115,7 +115,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
repository: "{{ test_image_base }}"
source: build
@@ -125,7 +125,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
repository: "{{ test_image_base }}"
source: build
@@ -22,7 +22,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
args:
TEST1: val1
TEST2: val2
@@ -35,7 +35,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
args:
TEST1: val1
TEST2: val2
@@ -70,7 +70,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
container_limits:
memory: 4000
pull: no
@@ -82,7 +82,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
container_limits:
memory: 5000000
memswap: 7000000
@@ -115,7 +115,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
@@ -130,7 +130,7 @@
- assert:
that:
- dockerfile_1 is changed
- "'FROM alpine:3.7' in dockerfile_1.stdout"
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
####################################################################
@@ -141,7 +141,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
@@ -149,7 +149,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
@@ -160,7 +160,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
@@ -184,27 +184,27 @@
- name: Archive image
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
archive_path: "{{ output_dir }}/image.tar"
source: pull
register: archive_image
- name: remove image
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
state: absent
force_absent: yes
- name: load image (changed)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
load_path: "{{ output_dir }}/image.tar"
source: load
register: load_image
- name: load image (idempotency)
docker_image:
name: "hello-world:latest"
name: "{{ docker_test_image_hello_world }}:latest"
load_path: "{{ output_dir }}/image.tar"
source: load
register: load_image_1
@@ -223,7 +223,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
register: path_1
@@ -232,7 +232,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
register: path_2
@@ -256,7 +256,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "StagedDockerfile"
target: first
pull: no
@@ -282,7 +282,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "EtcHostsDockerfile"
pull: no
etc_hosts: