diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..968d8b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc +build/ +dist/ +doc/build/ + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite +logs/* + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +.idea +.tox +*.sublime* +*.egg-info +Icon? +ehthumbs.db +Thumbs.db +.eggs + +# User driven backup files # +############################ +*.bak +*.swp + +# Generated by pbr while building docs +###################################### +AUTHORS +ChangeLog + +# Files created by releasenotes build +releasenotes/build + +# Test temp files +tests/common +tests/*.retry + +# Vagrant artifacts +.vagrant + +# Git clones +openstack-ansible-ops +previous diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..865c2a9 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=openstack/openstack-ansible.git diff --git a/README.md b/README.rst similarity index 100% rename from README.md rename to README.rst diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..c7ac466 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,44 @@ +# Note: +# This file is maintained in the openstack-ansible-tests repository. +# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/Vagrantfile +# +# If you need to perform any change on it, you should modify the central file, +# then, an OpenStack CI job will propagate your changes to every OSA repository +# since every repo uses the same Vagrantfile + +# Verify whether required plugins are installed. +required_plugins = [ "vagrant-disksize" ] +required_plugins.each do |plugin| + if not Vagrant.has_plugin?(plugin) + raise "The vagrant plugin #{plugin} is required. Please run `vagrant plugin install #{plugin}`" + end +end + +Vagrant.configure(2) do |config| + config.vm.provider "virtualbox" do |v| + v.memory = 6144 + v.cpus = 2 + end + + config.vm.synced_folder ".", "/vagrant", type: "rsync" + + config.vm.provision "shell", + privileged: false, + inline: <<-SHELL + cd /vagrant + ./run_tests.sh + SHELL + + config.vm.define "ubuntu1604" do |xenial| + xenial.vm.box = "bento/ubuntu-16.04" + end + + config.vm.define "opensuse423" do |leap423| + leap423.vm.box = "bento/opensuse-leap-42.3" + end + + config.vm.define "centos7" do |centos7| + centos7.vm.box = "bento/centos-7" + end + +end diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..5a05c5a --- /dev/null +++ b/bindep.txt @@ -0,0 +1,52 @@ +# This file facilitates OpenStack-CI package installation +# before the execution of any tests. +# +# See the following for details: +# - https://docs.openstack.org/infra/bindep/ +# - https://git.openstack.org/cgit/openstack-infra/bindep +# +# Even if the role does not make use of this facility, it +# is better to have this file empty, otherwise OpenStack-CI +# will fall back to installing its default packages which +# will potentially be detrimental to the tests executed. +# +# Note: +# This file is maintained in the openstack-ansible-tests repository. +# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/bindep.txt +# If you need to remove or add extra dependencies, you should modify +# the central file instead and once your change is accepted then update +# this file as well. The purpose of this file is to ensure that Python and +# Ansible have all their necessary binary requirements on the test host before +# tox executes. Any binary requirements needed by services/roles should be +# installed by those roles in their applicable package install tasks, not through +# using this file. +# + +# The gcc compiler +gcc + +# Base requirements for Ubuntu +git-core [platform:dpkg] +libssl-dev [platform:dpkg] +libffi-dev [platform:dpkg] +python2.7 [platform:dpkg] +python-apt [platform:dpkg] +python-dev [platform:dpkg] +python3 [platform:dpkg] +python3-apt [platform:dpkg] +python3-dev [platform:dpkg] + +# Base requirements for RPM distros +gcc-c++ [platform:rpm] +git [platform:rpm] +libffi-devel [platform:rpm] +openssl-devel [platform:rpm] +python-devel [platform:rpm] +python2-dnf [platform:fedora] + +# For SELinux +libselinux-python [platform:redhat] +libsemanage-python [platform:redhat] + +# Required for compressing collected log files in CI +gzip diff --git a/defaults/main.yml b/defaults/main.yml index 00c9947..b74a7f2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -40,3 +40,9 @@ qdrouterd_sasl_conf_path: "/etc/sasl2/" qdrouterd_sasl_conf_file: "/etc/sasl2/qdrouterd.conf" qdrouterd_log_module: "DEFAULT" qdrouterd_log_enable: "info+" + +# Qdrouterd SSL support +qdrouterd_require_ssl: "yes" +qdrouterd_ssl_cert: /etc/qdrouterd/ssl/qdrouterd.pem +qdrouterd_ssl_key: /etc/qdrouterd/ssl/qdrouterd.key +#qdrouterd_ssl_ca_cert: /etc/qdrouterd/ssl/qdrouterd-ca.pem diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..4280085 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# Copyright 2015, 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. + +# PURPOSE: +# This script clones the openstack-ansible-tests repository to the +# tests/common folder in order to be able to re-use test components +# for role testing. This is intended to be the thinnest possible +# shim for test execution outside of OpenStack CI. + +# WARNING: +# This file is maintained in the openstack-ansible-tests repository. +# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh +# If you need to modify this file, update the one in the openstack-ansible-tests +# repository and then update this file as well. The purpose of this file is to +# prepare the host and then execute all the tox tests. +# + +## Shell Opts ---------------------------------------------------------------- +set -xeu + +## Vars ---------------------------------------------------------------------- + +WORKING_DIR="$(readlink -f $(dirname $0))" + +COMMON_TESTS_PATH="${WORKING_DIR}/tests/common" +TESTING_HOME=${TESTING_HOME:-$HOME} +ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests" + +# Use .gitreview as the key to determine the appropriate +# branch to clone for tests. +TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview") +if [[ "${TESTING_BRANCH}" == "" ]]; then + TESTING_BRANCH="master" +fi + +## Main ---------------------------------------------------------------------- + +# Source distribution information +source /etc/os-release || source /usr/lib/os-release + +# Prefer dnf over yum for CentOS. +which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum' + +# Figure out the appropriate package install command +case ${ID,,} in + *suse*) pkg_mgr_cmd="zypper -n in" ;; + centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;; + ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;; + gentoo) pkg_mgr_cmd="emerge" ;; + *) echo "unsupported distribution: ${ID,,}"; exit 1 ;; +esac + +# Install git so that we can clone the tests repo if git is not available +which git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git + +# Clone the tests repo for access to the common test script +if [[ ! -d "${COMMON_TESTS_PATH}" ]]; then + # The tests repo doesn't need a clone, we can just + # symlink it. + if [[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then + ln -s "${WORKING_DIR}" "${COMMON_TESTS_PATH}" + + # In zuul v3 any dependent repository is placed into + # /home/zuul/src/git.openstack.org, so we check to see + # if there is a tests checkout there already. If so, we + # symlink that and use it. + elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then + ln -s "${ZUUL_TESTS_CLONE_LOCATION}" "${COMMON_TESTS_PATH}" + + # Otherwise we're clearly not in zuul or using a previously setup + # repo in some way, so just clone it from upstream. + else + git clone -b "${TESTING_BRANCH}" \ + https://git.openstack.org/openstack/openstack-ansible-tests \ + "${COMMON_TESTS_PATH}" + fi +fi + +# Execute the common test script +source tests/common/run_tests_common.sh + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..3949197 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,21 @@ +[metadata] +name = ansible-qdrouterd +summary = qdrouterd for Ansible +description-file = + README.rst +classifier = + Intended Audience :: Developers + Intended Audience :: System Administrators + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + +[build_sphinx] +all_files = 1 +build-dir = doc/build +source-dir = doc/source + +[pbr] +warnerrors = True + +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d24e556 --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +# Copyright (c) 2018 Red Hat, 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. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass + +setuptools.setup( + setup_requires=['pbr>=2.0.0'], + pbr=True) diff --git a/templates/qdrouterd.conf.j2 b/templates/qdrouterd.conf.j2 index 4166cbb..886b9d8 100644 --- a/templates/qdrouterd.conf.j2 +++ b/templates/qdrouterd.conf.j2 @@ -7,6 +7,17 @@ router { saslConfigName: {{ qdrouterd_service_name }} } +{% if qdrouterd_require_ssl == 'yes' %} +sslProfile { + name: {{ ansible_hostname }} +{% if qdrouterd_ssl_ca_cert is defined %} + certDb: {{ qdrouterd_ssl_ca_cert }} +{% endif %} + certFile: {{ qdrouterd_ssl_cert }} + keyFile: {{ qdrouterd_ssl_key }} +} +{% endif %} + listener { host: {{ qdrouterd_listener_addr }} port: {{ qdrouterd_listener_port }} diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..82506c5 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,9 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +bashate>=0.5.1 # Apache-2.0 +flake8<2.6.0,>=2.5.4 # MIT +pyasn1!=0.2.3,>=0.1.8 # BSD +pyOpenSSL>=17.1.0 # Apache-2.0 +requests>=2.14.2 # Apache-2.0 +ndg-httpsclient>=0.4.2;python_version<'3.0' # BSD diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml new file mode 100644 index 0000000..5e8a332 --- /dev/null +++ b/tests/ansible-role-requirements.yml @@ -0,0 +1,24 @@ +- name: apt_package_pinning + src: https://git.openstack.org/openstack/openstack-ansible-apt_package_pinning + scm: git + version: master +- name: pip_install + src: https://git.openstack.org/openstack/openstack-ansible-pip_install + scm: git + version: master +- name: openstack_hosts + src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts + scm: git + version: master +- name: lxc_hosts + src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts + scm: git + version: master +- name: lxc_container_create + src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create + scm: git + version: master +- name: previous_qdrouterd_server + src: https://github.com/ajssmith/ansible-qdrouterd + scm: git + version: master diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml new file mode 100644 index 0000000..a421be4 --- /dev/null +++ b/tests/group_vars/all_containers.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2018, Red Hat, 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. + +container_name: "{{ inventory_hostname }}" +container_networks: + management_address: + address: "{{ ansible_host }}" + bridge: "br-mgmt" + interface: "eth1" + netmask: "255.255.255.0" + type: "veth" +physical_host: localhost +properties: + service_name: "{{ inventory_hostname }}" diff --git a/tests/host_vars/container1.yml b/tests/host_vars/container1.yml new file mode 100644 index 0000000..37954c2 --- /dev/null +++ b/tests/host_vars/container1.yml @@ -0,0 +1,18 @@ +--- +# 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. + +ansible_host: 10.1.0.2 +ansible_become: True +ansible_user: root diff --git a/tests/host_vars/container2.yml b/tests/host_vars/container2.yml new file mode 100644 index 0000000..10225ab --- /dev/null +++ b/tests/host_vars/container2.yml @@ -0,0 +1,18 @@ +--- +# 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. + +ansible_host: 10.1.0.3 +ansible_become: True +ansible_user: root diff --git a/tests/host_vars/container3.yml b/tests/host_vars/container3.yml new file mode 100644 index 0000000..e937748 --- /dev/null +++ b/tests/host_vars/container3.yml @@ -0,0 +1,18 @@ +--- +# 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. + +ansible_host: 10.1.0.4 +ansible_become: True +ansible_user: root diff --git a/tests/host_vars/localhost.yml b/tests/host_vars/localhost.yml new file mode 100644 index 0000000..65ddeaa --- /dev/null +++ b/tests/host_vars/localhost.yml @@ -0,0 +1,19 @@ +--- +# Copyright 2016, 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. + +bridges: + - "br-mgmt" + +ansible_python_interpreter: "/usr/bin/python2" diff --git a/tests/inventory b/tests/inventory index 878877b..eb5141d 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,14 @@ +[all] localhost +container1 +container2 +container3 + +[qdrouterd_all] +container1 +container2 +container3 + +[all_containers:children] +qdrouterd_all diff --git a/tests/qdrouterd-overrides.yml b/tests/qdrouterd-overrides.yml new file mode 100644 index 0000000..84a036e --- /dev/null +++ b/tests/qdrouterd-overrides.yml @@ -0,0 +1,2 @@ +qdrouterd_ssl_cert: /etc/qpid-dispatch/ssl/qdrouterd.pem +qdrouterd_ssl_key: /etc/qpid-dispatch/ssl/qdrouterd.key diff --git a/tests/test-install-previous-qdrouterd.yml b/tests/test-install-previous-qdrouterd.yml new file mode 100644 index 0000000..ea837e8 --- /dev/null +++ b/tests/test-install-previous-qdrouterd.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2018, Red Hat, 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: Gather facts + hosts: "all" + user: root + gather_facts: true + +# Install previous version +- name: Deploy previous qdrouterd version + hosts: qdrouterd_all + user: root + serial: 1 + any_errors_fatal: true + gather_facts: true + roles: + - role: "previous_qdrouterd_server" + vars_files: + - common/previous/test-vars.yml diff --git a/tests/test-qdrouterd-functional.yml b/tests/test-qdrouterd-functional.yml new file mode 100644 index 0000000..f177552 --- /dev/null +++ b/tests/test-qdrouterd-functional.yml @@ -0,0 +1,81 @@ +--- +# Copyright 2018, Red Hat, 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 + hosts: qdrouterd_all + any_errors_fatal: true + user: root + gather_facts: true + become: true + tasks: + + - name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ playbook_dir }}/../vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ playbook_dir }}/../vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ playbook_dir }}/../vars/{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ playbook_dir }}/../vars/{{ ansible_distribution | lower }}.yml" + - "{{ playbook_dir }}/../vars/{{ ansible_os_family | lower }}.yml" + + - name: Check qdrouterd is running + command: "pgrep -f qdrouterd" + delegate_to: "{{ item }}" + when: ansible_host == item + with_items: + - 10.1.0.2 + - 10.1.0.3 + - 10.1.0.4 + + - name: Open qdrouterd.conf + slurp: + src: "{{ qdrouterd_etc_conf_file }}" + register: qdrouterd_config + + - name: Read qdrouterd_ssl_cert + stat: + path: "{{ qdrouterd_ssl_cert }}" + register: qdrouterd_ssl_cert_stat + + - name: Read qdrouterd_ssl_key + stat: + path: "{{ qdrouterd_ssl_key }}" + register: qdrouterd_ssl_key_stat + + - name: Read qdrouterd files + set_fact: + qdrouterd_config_contents: "{{ qdrouterd_config.content | b64decode }}" + qdrouterd_ssl_cert_checksum: "{{ qdrouterd_ssl_cert_stat.stat.checksum }}" + qdrouterd_ssl_key_checksum: "{{ qdrouterd_ssl_key_stat.stat.checksum }}" + + - name: Check files contents + assert: + that: + - "'workerThreads' in qdrouterd_config_contents" + + - name: Get general statistics of qdrouterd + command: "qdstat -g -b 0.0.0.0:31459" + register: qdrouterd_statistics + changed_when: false + + - name: Print qdrouterd_statistics + debug: + var: qdrotuerd_statistics + + - name: Ensure SSL cert/key checksums are identical across the mesh + assert: + that: + - hostvars['container1']['qdrotuerd_ssl_cert_checksum'] == hostvars['container2']['qdrouterd_ssl_cert_checksum'] == hostvars['container3']['qdrouterd_ssl_cert_checksum'] + - hostvars['container1']['qdrouterd_ssl_key_checksum'] == hostvars['container2']['qdrouterd_ssl_key_checksum'] == hostvars['container3']['qdrouterd_ssl_key_checksum'] diff --git a/tests/test-qdrouterd-upgrades.sh b/tests/test-qdrouterd-upgrades.sh new file mode 100755 index 0000000..cfe6270 --- /dev/null +++ b/tests/test-qdrouterd-upgrades.sh @@ -0,0 +1,98 @@ +#!/usr/bin/env bash + +# Copyright 2018, Red Hat, 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. + +# WARNING: +# This file is use by all OpenStack-Ansible roles for testing purposes. +# Any changes here will affect all OpenStack-Ansible role repositories +# with immediate effect. + +# PURPOSE: +# This script executes test Ansible playbooks required for performing +# an upgrade test of the role. + +## Shell Opts ---------------------------------------------------------------- + +set -e + +## Vars ---------------------------------------------------------------------- + +export WORKING_DIR=${WORKING_DIR:-$(pwd)} +export ROLE_NAME=${ROLE_NAME:-''} + +export ANSIBLE_PARAMETERS=${ANSIBLE_PARAMETERS:-""} +export TEST_PLAYBOOK=${TEST_PLAYBOOK:-$WORKING_DIR/tests/test-upgrade-pre.yml} +export TEST_CHECK_MODE=${TEST_CHECK_MODE:-false} +export TEST_IDEMPOTENCE=${TEST_IDEMPOTENCE:-false} +export COMMON_TESTS_PATH="${WORKING_DIR}/tests/common" + +echo "ANSIBLE_OVERRIDES: ${ANSIBLE_OVERRIDES}" +echo "ANSIBLE_PARAMETERS: ${ANSIBLE_PARAMETERS}" +echo "TEST_PLAYBOOK: ${TEST_PLAYBOOK}" +echo "TEST_CHECK_MODE: ${TEST_CHECK_MODE}" +echo "TEST_IDEMPOTENCE: ${TEST_IDEMPOTENCE}" + +## Functions ----------------------------------------------------------------- + +function execute_ansible_playbook { + + export ANSIBLE_CLI_PARAMETERS="${ANSIBLE_PARAMETERS} -e @${ANSIBLE_OVERRIDES}" + export ANSIBLE_BIN=${ANSIBLE_BIN:-"ansible-playbook"} + CMD_TO_EXECUTE="${ANSIBLE_BIN} ${TEST_PLAYBOOK} $@ ${ANSIBLE_CLI_PARAMETERS}" + + echo "Executing: ${CMD_TO_EXECUTE}" + echo "With:" + echo " ANSIBLE_INVENTORY: ${ANSIBLE_INVENTORY}" + echo " ANSIBLE_LOG_PATH: ${ANSIBLE_LOG_PATH}" + + ${CMD_TO_EXECUTE} + +} + +## Main ---------------------------------------------------------------------- + +# Ensure that the Ansible environment is properly prepared +source "${COMMON_TESTS_PATH}/test-ansible-env-prep.sh" + +# Prepare environment for the initial deploy of (previous and current) Galera +# No upgrading or testing is done yet. +export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-upgrade-pre.yml" +export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-install.log" + +# Execute the setup of previous version +execute_ansible_playbook + +# Create an ansible venv matching previous branch +source ${WORKING_DIR}/tests/common/test-create-previous-venv.sh + +# Prepare environment for the deploy of previous Qdrouterd: +# No upgrading or testing is done yet. +export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-install-previous-qdrouterd.yml" +export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-previous_qdrouterd-install.log" +export PREVIOUS_VENV="ansible-previous" +export ANSIBLE_BIN="${WORKING_DIR}/.tox/${PREVIOUS_VENV}/bin/ansible-playbook" + +# Execute the setup of previous Keystone +execute_ansible_playbook +# Unset previous branch overrides +unset PREVIOUS_VENV +unset ANSIBLE_BIN + +# Prepare environment for the upgrade +export TEST_PLAYBOOK="${WORKING_DIR}/tests/test-upgrade-post.yml" +export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/ansible-execute-upgrade.log" + +# Execute the upgrade +execute_ansible_playbook diff --git a/tests/test-upgrade-post.yml b/tests/test-upgrade-post.yml new file mode 100644 index 0000000..633de04 --- /dev/null +++ b/tests/test-upgrade-post.yml @@ -0,0 +1,20 @@ +--- +# Copyright 2018, Red Hat, 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. + +# Install Qdrouterd server +- include: common/test-install-qdrouterd.yml + +# Run functional tests +- include: test-qdrouterd-functional.yml diff --git a/tests/test-upgrade-pre.yml b/tests/test-upgrade-pre.yml new file mode 100644 index 0000000..8e6d766 --- /dev/null +++ b/tests/test-upgrade-pre.yml @@ -0,0 +1,17 @@ +--- +# Copyright 2015, 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. + +# Setup the host +- include: common/test-setup-host.yml diff --git a/tests/test.yml b/tests/test.yml index b2d4af0..b15c42a 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,5 +1,23 @@ --- -- hosts: localhost - remote_user: root - roles: - - ansible-qdrouterd \ No newline at end of file +# Copyright 2018, Red Hat, 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. + +# Setup the host +- include: common/test-setup-host.yml + +# Install previous version qdrouterd server +- include: common/test-install-qdrouterd.yml + +# Run functional tests +- include: test-qdrouterd-server-functional.yml diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..41732f2 --- /dev/null +++ b/tox.ini @@ -0,0 +1,122 @@ +[tox] +minversion = 2.0 +skipsdist = True +envlist = docs,linters,functional + + +[testenv] +usedevelop = True +install_command = + pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} +deps = + -r{toxinidir}/test-requirements.txt +commands = + /usr/bin/find . -type f -name "*.pyc" -delete +passenv = + HOME + USER + http_proxy + HTTP_PROXY + https_proxy + HTTPS_PROXY + no_proxy + NO_PROXY +whitelist_externals = + bash +setenv = + PYTHONUNBUFFERED=1 + ROLE_NAME=qdrouterd + TEST_IDEMPOTENCE=false + VIRTUAL_ENV={envdir} + WORKING_DIR={toxinidir} + + +[testenv:docs] +deps = -r{toxinidir}/doc/requirements.txt +commands= + bash -c "rm -rf doc/build" + doc8 doc + sphinx-build -b html doc/source doc/build/html + + +[doc8] +# Settings for doc8: +extensions = .rst + + +[testenv:releasenotes] +deps = -r{toxinidir}/doc/requirements.txt +commands = + sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html + + +# environment used by the -infra templated docs job +[testenv:venv] +commands = + {posargs} + + +[testenv:pep8] +commands = + bash -c "{toxinidir}/tests/common/test-pep8.sh" + + +[flake8] +# Ignores the following rules due to how ansible modules work in general +# F403 'from ansible.module_utils.basic import *' used; +# unable to detect undefined names +ignore=F403 + + +[testenv:bashate] +commands = + bash -c "{toxinidir}/tests/common/test-bashate.sh" + + +[testenv:ansible] +deps = + {[testenv]deps} + -rhttps://git.openstack.org/cgit/openstack/openstack-ansible/plain/global-requirement-pins.txt + -rhttps://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt + + +[testenv:ansible-syntax] +deps = + {[testenv:ansible]deps} +commands = + bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh" + + +[testenv:ansible-lint] +deps = + {[testenv:ansible]deps} +commands = + bash -c "{toxinidir}/tests/common/test-ansible-lint.sh" + + +[testenv:functional] +deps = + {[testenv:ansible]deps} +commands = + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" + + +[testenv:upgrade] +deps = + {[testenv:ansible]deps} +setenv = + {[testenv]setenv} + ANSIBLE_OVERRIDES={toxinidir}/tests/qdrouterd-overrides.yml + CLONE_UPGRADE_TESTS=yes +commands = + bash -c "{toxinidir}/tests/test-qdrouterd-upgrades.sh" + + +[testenv:linters] +deps = + {[testenv:ansible]deps} +commands = + {[testenv:pep8]commands} + {[testenv:bashate]commands} + {[testenv:ansible-lint]commands} + {[testenv:ansible-syntax]commands} diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml new file mode 100644 index 0000000..6d5743b --- /dev/null +++ b/zuul.d/project.yaml @@ -0,0 +1,32 @@ +# 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. + +- project: + check: + jobs: + - openstack-ansible-linters + - openstack-ansible-functional-centos-7 + - openstack-ansible-functional-opensuse-423 + - openstack-ansible-functional-ubuntu-xenial + - openstack-ansible-upgrade-ubuntu-xenial + experimental: + jobs: + - openstack-ansible-integrated-deploy-aio + gate: + jobs: + - openstack-ansible-linters + - openstack-ansible-functional-centos-7 + - openstack-ansible-functional-opensuse-423 + - openstack-ansible-functional-ubuntu-xenial + - openstack-ansible-upgrade-ubuntu-xenial