[stable-1] Fix docker tests (#1398)

* Adjust version_added, re-place tests. (#34)

* Template docker test containers.

* Forgot to adjust test.
This commit is contained in:
Felix Fontein 2020-11-26 13:21:12 +01:00 committed by GitHub
commit e03431d9f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 823 additions and 801 deletions

View file

@ -1,3 +0,0 @@
FROM busybox
ENV foo /bar
WORKDIR ${foo}

View file

@ -1,7 +0,0 @@
FROM busybox AS first
ENV dir /first
WORKDIR ${dir}
FROM busybox AS second
ENV dir /second
WORKDIR ${dir}

View file

@ -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:

View file

@ -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

View file

@ -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
@ -136,11 +136,6 @@
- repository_1 is changed
- repository_2 is not changed
# Uncomment in community.docker
# - assert:
# that:
# - 'FROM busybox' in repository_1.stdout
- name: Get facts of image
docker_image_info:
name: "{{ test_image_base }}:latest"

View file

@ -14,7 +14,7 @@
- name: build with old-style options
docker_image:
name: "{{ iname }}"
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: Dockerfile
http_timeout: 60
nocache: yes

View file

@ -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,6 +130,7 @@
- assert:
that:
- dockerfile_1 is changed
- "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout"
- dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
####################################################################
@ -140,7 +141,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
@ -148,7 +149,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
@ -159,7 +160,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "MyDockerfile"
pull: no
source: build
@ -183,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
@ -222,7 +223,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
register: path_1
@ -231,7 +232,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
pull: no
source: build
register: path_2
@ -255,7 +256,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "StagedDockerfile"
target: first
pull: no
@ -281,7 +282,7 @@
docker_image:
name: "{{ iname }}"
build:
path: "{{ role_path }}/files"
path: "{{ output_dir }}/files"
dockerfile: "EtcHostsDockerfile"
pull: no
etc_hosts:

View file

@ -0,0 +1,3 @@
FROM {{ docker_test_image_busybox }}
ENV foo /bar
WORKDIR ${foo}

View file

@ -1,3 +1,3 @@
FROM busybox
FROM {{ docker_test_image_busybox }}
# This should fail building if docker cannot resolve some-custom-host
RUN ping -c1 some-custom-host

View file

@ -1,4 +1,4 @@
FROM alpine:3.7
FROM {{ docker_test_image_alpine }}
ENV INSTALL_PATH /newdata
RUN mkdir -p $INSTALL_PATH

View file

@ -0,0 +1,7 @@
FROM {{ docker_test_image_busybox }} AS first
ENV dir /first
WORKDIR ${dir}
FROM {{ docker_test_image_busybox }} AS second
ENV dir /second
WORKDIR ${dir}