diff --git a/tests/s3cfg.j2 b/tests/s3cfg.j2 new file mode 100644 index 00000000..93bd79dc --- /dev/null +++ b/tests/s3cfg.j2 @@ -0,0 +1,7 @@ +[default] +access_key = "{{ ec2_access_key }}" +host_base = "{{ ansible_host }}:8080" +host_bucket = "{{ ansible_host }}:8080" +secret_key = "{{ ec2_secret_key }}" +signature_v2 = True +use_https = False diff --git a/tests/test-swift3-functional.yml b/tests/test-swift3-functional.yml new file mode 100644 index 00000000..917e24b7 --- /dev/null +++ b/tests/test-swift3-functional.yml @@ -0,0 +1,91 @@ +--- +# 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 + diff --git a/tox.ini b/tox.ini index 2d05a534..d21bc931 100644 --- a/tox.ini +++ b/tox.ini @@ -127,6 +127,18 @@ commands = bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" +[testenv:func_swift3] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_PARAMETERS=-vvv -e swift_swift3_enabled=True + TEST_PLAYBOOK={toxinidir}/tests/test.yml {toxinidir}/tests/test-swift-functional.yml {toxinidir}/tests/test-swift3-functional.yml +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + [testenv:multi_reg] deps = {[testenv:ansible]deps} diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index ba6a9e58..bac73b23 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -33,3 +33,10 @@ vars: tox_env: func_pypy +- job: + name: openstack-ansible-swift3-ubuntu-xenial-nv + parent: openstack-ansible-functional-ubuntu-xenial + voting: false + vars: + tox_env: func_swift3 + diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index c8261c99..7bb67549 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -26,6 +26,7 @@ - openstack-ansible-multireg-ubuntu-xenial - openstack-ansible-multireg-centos-7-nv - openstack-ansible-pypy-ubuntu-xenial-nv + - openstack-ansible-swift3-ubuntu-xenial-nv experimental: jobs: - openstack-ansible-integrated-deploy-aio