zuul-storage-proxy/playbooks/test.yaml
James E. Blair 5f349f83c4 Publish container images to quay.io
Change-Id: I176f16e0a4b17c45ca76e6521bebe3e22f8c2bbd
2023-04-21 10:24:14 -07:00

139 lines
3.7 KiB
YAML

- hosts: all
vars:
content: "Hello world!"
proxy_image: quay.io/zuul-ci/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 }}"