Add podman buildset test

This tests the registry in a namespaced buildset configuration with
podman.

Change-Id: I17c2ac3ba3c733ace05ce0103dc6cf431fbf197e
This commit is contained in:
James E. Blair 2019-10-10 13:59:08 -07:00
parent 2d02e5e3bd
commit f99d2ffad3
7 changed files with 178 additions and 14 deletions

View File

@ -23,3 +23,21 @@
- name: Remove docker user configuration
when: not user_config_stat.stat.exists
command: "rm ~/.docker/config.json"
- name: Restore registries.conf
when: registries_conf_stat.stat.exists
command: "cp {{ workspace }}/registries.conf /etc/containers/registries.conf"
become: true
- name: Remove registries.conf
when: not registries_conf_stat.stat.exists
command: "rm /etc/containers/registries.conf"
become: true
- name: Restore containers user auth
when: containers_auth_stat.stat.exists
command: "cp {{ workspace }}/containers-auth.json /run/user/{{ ansible_user_uid }}/auth.json"
- name: Remove containers user auth
when: not containers_auth_stat.stat.exists
command: "rm /run/user/{{ ansible_user_uid }}/auth.json"

View File

@ -1,13 +0,0 @@
# Version 2 is the latest that is supported by docker-compose in
# Ubuntu Xenial.
version: '2'
services:
registry:
image: zuul/zuul-registry
volumes:
- "./standard-conf/:/conf/:z"
- "/tmp/registry-test/storage/:/storage:z"
- "/tmp/registry-test/tls/:/tls:z"
ports:
- "9000:9000"

View File

@ -0,0 +1,21 @@
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "docker.io"
[[registry.mirror]]
location = "localhost:9000/docker.io"
[[registry.mirror]]
location = "docker.io"
[[registry]]
prefix = "quay.io"
location = "quay.io"
[[registry.mirror]]
location = "localhost:9000/quay.io"
[[registry.mirror]]
location = "quay.io"

View File

@ -9,6 +9,8 @@
include_tasks: docker.yaml
- name: Run docker buildset test tasks
include_tasks: docker-buildset.yaml
- name: Run docker buildset test tasks
include_tasks: podman-buildset.yaml
- name: Run podman test tasks
include_tasks: podman.yaml
- name: Run cleanup tasks

View File

@ -0,0 +1,113 @@
# Test push and pull from the buildset registry
- name: Create new registries.conf
copy:
dest: /etc/containers/registries.conf
src: files/registries.conf
become: true
- name: Start the namespaced registry
shell:
cmd: docker-compose -f namespaced-compose.yaml up -d
chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test"
- name: Wait for registry to come up
uri:
url: https://localhost:9000/v2/
validate_certs: false
status_code: 401
register: result
until: result.status is defined and result.status == 401
delay: 1
retries: 120
- name: Create new docker user config
set_fact:
new_user_config: {}
- name: Write docker user configuration
copy:
content: "{{ new_user_config | to_nice_json }}"
dest: ~/.docker/config.json
- name: Write containers auth configuration
copy:
content: "{{ new_user_config | to_nice_json }}"
dest: "/run/user/{{ ansible_user_uid }}/auth.json"
- name: Copy the test image into the buildset registry
command: >
skopeo copy --dest-creds testuser:testpass
docker-archive:{{ workspace }}/test.img
docker://localhost:9000/docker.io/test/image:latest
- name: Copy the test image into the buildset registry
command: >
skopeo copy --dest-creds testuser:testpass
docker-archive:{{ workspace }}/test.img
docker://localhost:9000/quay.io/test/quay-image:latest
- name: Print list of images
command: podman image ls --all --digests --no-trunc
register: image_list
failed_when:
- "'test/image' in image_list.stdout"
- "'test/quay-image' in image_list.stdout"
- "'alpine' in image_list.stdout"
- name: Pull the shadowed docker image from the buildset registry
command: podman pull test/image
- name: Print list of images
command: podman image ls --all --digests --no-trunc
register: image_list
failed_when: "'docker.io/test/image' not in image_list.stdout"
- name: Remove the test image from the local cache
command: podman rmi docker.io/test/image
- name: Pull the shadowed quay image from the buildset registry
command: podman pull quay.io/test/quay-image
- name: Print list of images
command: podman image ls --all --digests --no-trunc
register: image_list
failed_when: "'quay.io/test/quay-image' not in image_list.stdout"
- name: Remove the test image from the local cache
command: podman rmi quay.io/test/quay-image
- name: Try to pull an image that does not exist
command: podman pull test/dne
register: result
failed_when: result.rc != 125
- name: Pull an image from docker.io
command: podman pull alpine
- name: Print list of images
command: podman image ls --all --digests --no-trunc
register: image_list
failed_when: "'docker.io/library/alpine' not in image_list.stdout"
- name: Remove the test image from the local cache
command: podman rmi docker.io/library/alpine
- name: Pull an image from quay.io
command: podman pull quay.io/0xff/alpine-sshd
- name: Print list of images
command: podman image ls --all --digests --no-trunc
register: image_list
failed_when: "'quay.io/0xff/alpine-sshd' not in image_list.stdout"
- name: Remove the test image from the local cache
command: podman rmi quay.io/0xff/alpine-sshd
- name: Stop the namespaced registry
shell:
cmd: docker-compose -f namespaced-compose.yaml down
chdir: "{{ ansible_user_dir }}/src/opendev.org/zuul/zuul-registry/playbooks/functional-test"
- name: Clean up docker volumes
command: docker volume prune -f

View File

@ -47,6 +47,12 @@
- name: Run docker buildset test tasks
include_tasks: docker-buildset.yaml
- hosts: all
name: Run podman buildset registry test
tasks:
- name: Run podman buildset test tasks
include_tasks: podman-buildset.yaml
- hosts: all
name: Clean up after tests
tasks:

View File

@ -32,7 +32,6 @@
- name: Save docker daemon configuration
when: daemon_config_stat.stat.exists
command: "cp /etc/docker/daemon.json {{ workspace }}/docker-daemon.json"
become: true
- name: Check if docker user configuration exists
stat:
@ -43,6 +42,24 @@
when: user_config_stat.stat.exists
command: "cp ~/.docker/config.json {{ workspace }}/docker-user.json"
- name: Check if registries.conf exists
stat:
path: /etc/containers/registries.conf
register: registries_conf_stat
- name: Save registries.conf
when: registries_conf_stat.stat.exists
command: "cp /etc/containers/registries.conf {{ workspace }}/registries.conf"
- name: Check if containers user auth exists
stat:
path: "/run/user/{{ ansible_user_uid }}/auth.json"
register: containers_auth_stat
- name: Save containers user auth
when: containers_auth_stat.stat.exists
command: "cp /run/user/{{ ansible_user_uid }}/auth.json {{ workspace }}/containers-auth.json"
- name: Create a local containers image
shell: buildah commit --rm $(buildah from scratch) testimage