From c09c18c01a46fea6f507b254656d5b32f44dee12 Mon Sep 17 00:00:00 2001 From: Charles Farquhar Date: Wed, 2 Aug 2017 23:34:25 +0000 Subject: [PATCH] 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 (cherry picked from commit ea0d7bdb3e9a72d0c4d321a268227c84ddc9b270) --- tests/s3cfg.j2 | 7 +++ tests/test-swift3-functional.yml | 91 ++++++++++++++++++++++++++++++++ tox.ini | 12 +++++ zuul.d/jobs.yaml | 7 +++ zuul.d/project.yaml | 1 + 5 files changed, 118 insertions(+) create mode 100644 tests/s3cfg.j2 create mode 100644 tests/test-swift3-functional.yml 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 67e57e9a..4afe2515 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 114ebfc5..1a769591 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -28,6 +28,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