mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
[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:
@@ -1,3 +0,0 @@
|
||||
FROM busybox
|
||||
ENV foo /bar
|
||||
WORKDIR ${foo}
|
||||
@@ -1,7 +0,0 @@
|
||||
FROM busybox AS first
|
||||
ENV dir /first
|
||||
WORKDIR ${dir}
|
||||
|
||||
FROM busybox AS second
|
||||
ENV dir /second
|
||||
WORKDIR ${dir}
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
FROM {{ docker_test_image_busybox }}
|
||||
ENV foo /bar
|
||||
WORKDIR ${foo}
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.7
|
||||
FROM {{ docker_test_image_alpine }}
|
||||
ENV INSTALL_PATH /newdata
|
||||
RUN mkdir -p $INSTALL_PATH
|
||||
|
||||
@@ -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}
|
||||
Reference in New Issue
Block a user