openstack-ansible-os_swift/tests/test-swift3-functional.yml
Charles Farquhar ea0d7bdb3e Add basic functional testing for swift3
This commit adds the following swift3 functional testing:

 1. Install and configure `s3cmd` utility
 2. Verify bucket creation
 3. Verify object upload
 4. Verify object listing
 5. Verify object and bucket deletion

Change-Id: I6290e8b02004f6c518983700a6439d28fbd127a4
Co-Authored-By: Jean-Philippe Evrard <jean-philippe@evrard.me>
2018-02-16 09:48:06 +00:00

92 lines
2.7 KiB
YAML

---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Run functional tests for swift3 middleware
hosts: swift_proxy[0]
user: root
gather_facts: true
vars_files:
- common/test-vars.yml
tasks:
- name: Install prerequisite python packages
pip:
name: "{{ item }}"
state: present
virtualenv: "{{ swift_venv_bin | dirname }}"
extra_args: >-
{{ swift_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
with_items:
- s3cmd
- python-openstackclient
- name: Generate EC2 credentials
shell: |
. ~/openrc
. {{ swift_venv_bin }}/activate
openstack ec2 credentials create > /tmp/ec2_credentials.txt
args:
creates: /tmp/ec2_credentials.txt
- name: Extract EC2 access key
shell: awk '/access/ { print $4 }' /tmp/ec2_credentials.txt
changed_when: False
register: ec2_access_key
- name: Extract EC2 secret
shell: awk '/secret/ { print $4 }' /tmp/ec2_credentials.txt
changed_when: False
register: ec2_secret_key
- name: Set facts for .s3cfg template
set_fact:
ec2_access_key: "{{ ec2_access_key.stdout }}"
ec2_secret_key: "{{ ec2_secret_key.stdout }}"
- name: Generate .s3cfg
template:
src: s3cfg.j2
dest: /root/.s3cfg
- name: Verify we can create a bucket
shell: |
. {{ swift_venv_bin }}/activate
s3cmd mb s3://swift3-test
tags:
- skip_ansible_lint
- name: Verify we can put an object
shell: |
. {{ swift_venv_bin }}/activate
s3cmd put /root/openrc s3://swift3-test
tags:
- skip_ansible_lint
- name: Verify we can list the object
shell: |
. {{ swift_venv_bin }}/activate
s3cmd la | grep openrc
tags:
- skip_ansible_lint
- name: Verify we can remove buckets and objects
shell: |
. {{ swift_venv_bin }}/activate
s3cmd -r rb s3://swift3-test
tags:
- skip_ansible_lint