Add an integration test to the image build
This uses a swift all-in-one container image to test the result of the zuul-storage-proxy image build. It tests it at two different mount points to verify both configurations work. Change-Id: I408207ac81ea04d1009ceb98aaed0739f86b460a
This commit is contained in:
parent
d9573ec07a
commit
8acf7c36ca
@ -20,6 +20,9 @@
|
||||
parent: opendev-build-docker-image
|
||||
allowed-projects: zuul/zuul-storage-proxy
|
||||
provides: zuul-storage-proxy-container-image
|
||||
run: &image_playbooks
|
||||
- playbooks/build.yaml
|
||||
- playbooks/test.yaml
|
||||
vars: &image_vars
|
||||
docker_images:
|
||||
- context: .
|
||||
@ -35,6 +38,7 @@
|
||||
parent: opendev-upload-docker-image
|
||||
description: Build and test a Docker image and upload to Docker Hub.
|
||||
allowed-projects: zuul/zuul-storage-proxy
|
||||
run: *image_playbooks
|
||||
secrets:
|
||||
name: docker_credentials
|
||||
secret: zuul-storage-proxy-dockerhub
|
||||
|
11
playbooks/build.yaml
Normal file
11
playbooks/build.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
- hosts: all
|
||||
roles:
|
||||
- build-docker-image
|
||||
|
||||
# If buildset_registry is defined, that means a parent job is running it;
|
||||
# only if it is not defined does it mean that we are running it. If we
|
||||
# are running it, pause the job so that child jobs will automatically
|
||||
# use it.
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- pause-buildset-registry
|
7
playbooks/files/clouds.yaml
Normal file
7
playbooks/files/clouds.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
clouds:
|
||||
testcloud:
|
||||
auth_type: v1password
|
||||
auth:
|
||||
username: 'test:tester'
|
||||
password: 'testing'
|
||||
auth_url: http://swift:8080/auth/v1.0
|
138
playbooks/test.yaml
Normal file
138
playbooks/test.yaml
Normal file
@ -0,0 +1,138 @@
|
||||
- hosts: all
|
||||
vars:
|
||||
content: "Hello world!"
|
||||
proxy_image: docker.io/zuul/zuul-storage-proxy:latest
|
||||
tasks:
|
||||
- name: Create clouds.yaml
|
||||
tempfile:
|
||||
state: file
|
||||
register: clouds_tempfile
|
||||
|
||||
- name: Write clouds.yaml
|
||||
copy:
|
||||
src: clouds.yaml
|
||||
mode: "0644"
|
||||
dest: "{{ clouds_tempfile.path }}"
|
||||
|
||||
- name: Create docker network
|
||||
command: docker network create --driver bridge swift-net
|
||||
|
||||
- name: Start a swift AIO
|
||||
command: >-
|
||||
docker run -d --rm
|
||||
--name=swift
|
||||
--network=swift-net
|
||||
--publish="8080:8080"
|
||||
docker.io/bouncestorage/swift-aio:latest
|
||||
|
||||
- name: Start the storage proxy
|
||||
command: >-
|
||||
docker run -d --rm
|
||||
--name=zuul-storage-proxy
|
||||
--network=swift-net
|
||||
--publish="8000:8000"
|
||||
--volume="{{ clouds_tempfile.path }}:/etc/openstack/clouds.yaml"
|
||||
--env CLOUD_NAMES=testcloud
|
||||
{{ proxy_image }}
|
||||
|
||||
- name: Wait for swift to start
|
||||
uri:
|
||||
url: http://127.0.0.1:8080/auth/v1.0
|
||||
headers:
|
||||
X-Storage-User: 'test:tester'
|
||||
X-Storage-Pass: 'testing'
|
||||
register: swift_result
|
||||
until: swift_result.status == 200
|
||||
delay: 2
|
||||
retries: 120
|
||||
|
||||
- name: Create swift container
|
||||
uri:
|
||||
url: http://127.0.0.1:8080/v1/AUTH_test/testcontainer
|
||||
headers:
|
||||
X-Auth-Token: '{{ swift_result.x_auth_token }}'
|
||||
method: PUT
|
||||
status_code: [201, 202]
|
||||
|
||||
- name: Verify swift container
|
||||
uri:
|
||||
url: http://127.0.0.1:8080/v1/AUTH_test/testcontainer
|
||||
headers:
|
||||
X-Auth-Token: '{{ swift_result.x_auth_token }}'
|
||||
status_code: [200, 204]
|
||||
register: result
|
||||
until: result.status in [200, 204]
|
||||
delay: 2
|
||||
retries: 15
|
||||
|
||||
- name: Create swift object
|
||||
uri:
|
||||
url: http://127.0.0.1:8080/v1/AUTH_test/testcontainer/testobject
|
||||
headers:
|
||||
X-Auth-Token: '{{ swift_result.x_auth_token }}'
|
||||
method: PUT
|
||||
status_code: [201, 202]
|
||||
body: "{{ content }}"
|
||||
|
||||
- name: Verify swift object
|
||||
uri:
|
||||
url: http://127.0.0.1:8080/v1/AUTH_test/testcontainer/testobject
|
||||
headers:
|
||||
X-Auth-Token: '{{ swift_result.x_auth_token }}'
|
||||
register: result
|
||||
until: result.status == 200
|
||||
delay: 2
|
||||
retries: 15
|
||||
|
||||
# The actual test (at mountpoint /):
|
||||
- name: Get object via proxy from /
|
||||
uri:
|
||||
url: http://127.0.0.1:8000/testcontainer/testobject
|
||||
return_content: true
|
||||
register: retrieved_object
|
||||
|
||||
- name: Verify content at /
|
||||
assert:
|
||||
that:
|
||||
- retrieved_object.content == content
|
||||
|
||||
# Restart the proxy with a different mount point
|
||||
- name: Stop storage proxy
|
||||
command: docker kill zuul-storage-proxy
|
||||
|
||||
- name: Start the storage proxy
|
||||
command: >-
|
||||
docker run -d --rm
|
||||
--name=zuul-storage-proxy
|
||||
--network=swift-net
|
||||
--publish="8000:8000"
|
||||
--volume="{{ clouds_tempfile.path }}:/etc/openstack/clouds.yaml"
|
||||
--env CLOUD_NAMES=testcloud
|
||||
--env MOUNTPOINT=/logs
|
||||
{{ proxy_image }}
|
||||
|
||||
# The actual test (at mountpoint /logs):
|
||||
- name: Get object via proxy at /logs
|
||||
uri:
|
||||
url: http://127.0.0.1:8000/logs/testcontainer/testobject
|
||||
return_content: true
|
||||
register: retrieved_object
|
||||
|
||||
- name: Verify content at /logs
|
||||
assert:
|
||||
that:
|
||||
- retrieved_object.content == content
|
||||
|
||||
- name: Stop swift
|
||||
command: docker kill swift
|
||||
|
||||
- name: Stop storage proxy
|
||||
command: docker kill zuul-storage-proxy
|
||||
|
||||
- name: Remove docker network
|
||||
command: docker network rm swift-net
|
||||
|
||||
- name: Delete clouds.yaml
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ clouds_tempfile.path }}"
|
@ -1 +1,3 @@
|
||||
openstacksdk
|
||||
# So that we can use the tempauth KSA plugin
|
||||
python-swiftclient
|
||||
|
Loading…
Reference in New Issue
Block a user