From b873fcd409a906ee8a56f0deea1e880362cda8b5 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Thu, 3 Aug 2017 13:48:31 +0200 Subject: [PATCH] Fill the tests directory The tests directory is needed to pass the gates Change-Id: I647d7487177a046120e5f7f43adf48e2aa821f8a Signed-off-by: Manuel Buil --- defaults/main.yml | 2 +- templates/etc/tacker/tacker.conf.j2 | 2 +- tests/group_vars/all_containers.yml | 26 ++++++++ tests/host_vars/infra1.yml | 18 ++++++ tests/host_vars/localhost.yml | 19 ++++++ tests/host_vars/tacker1.yml | 18 ++++++ tests/inventory | 35 +++++++++- tests/os_tacker-overrides.yml | 30 +++++++++ tests/test-install-tacker.yml | 34 ++++++++++ tests/test-tacker-functional.yml | 30 +++++++++ tests/test.yml | 32 ++++++++-- tests/tests-repo-clone.sh | 99 +++++++++++++++++++++++++++++ tox.ini | 27 ++------ 13 files changed, 344 insertions(+), 28 deletions(-) create mode 100644 tests/group_vars/all_containers.yml create mode 100644 tests/host_vars/infra1.yml create mode 100644 tests/host_vars/localhost.yml create mode 100644 tests/host_vars/tacker1.yml create mode 100644 tests/os_tacker-overrides.yml create mode 100644 tests/test-install-tacker.yml create mode 100644 tests/test-tacker-functional.yml create mode 100755 tests/tests-repo-clone.sh diff --git a/defaults/main.yml b/defaults/main.yml index f78750d..00176a4 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -135,7 +135,7 @@ heat_service_adminurl: "{{ tacker_service_publicuri_proto }}://{{ external_lb_vi #NOTE: these default should be updated approprietly # tacker-horizon uses this tackerclient_git_url: https://github.com/openstack/python-tackerclient.git -tacker_git_branch: "stable/liberty" +tacker_git_branch: "master" # tacker horizon vars tacker_horizon_venv: "/openstack/venvs/horizon-{{ openstack_release }}" diff --git a/templates/etc/tacker/tacker.conf.j2 b/templates/etc/tacker/tacker.conf.j2 index c50a169..0006fdf 100644 --- a/templates/etc/tacker/tacker.conf.j2 +++ b/templates/etc/tacker/tacker.conf.j2 @@ -410,7 +410,7 @@ default_vim = VIM0 #openstack = /etc/tacker/vim/fernet_keys [tacker_nova] # parameters for novaclient to talk to nova -region_name = {{ service_region }} +region_name = {{ tacker_service_region }} project_domain_id = {{ nova_service_project_domain_id }} project_name = {{ nova_service_project_name }} user_domain_id = {{ nova_service_user_domain_id }} diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml new file mode 100644 index 0000000..f37df47 --- /dev/null +++ b/tests/group_vars/all_containers.yml @@ -0,0 +1,26 @@ +--- +# 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. + +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/infra1.yml b/tests/host_vars/infra1.yml new file mode 100644 index 0000000..86d45ff --- /dev/null +++ b/tests/host_vars/infra1.yml @@ -0,0 +1,18 @@ +--- +# 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. + +ansible_host: 10.1.0.2 +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/host_vars/tacker1.yml b/tests/host_vars/tacker1.yml new file mode 100644 index 0000000..96329d4 --- /dev/null +++ b/tests/host_vars/tacker1.yml @@ -0,0 +1,18 @@ +--- +# Copyright 2017, SUSE Linux GmbH +# +# 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/inventory b/tests/inventory index d18580b..9e0b85d 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1 +1,34 @@ -localhost \ No newline at end of file +[all] +localhost +infra1 +tacker1 + +[all_containers] +infra1 +tacker1 + +[rabbitmq_all] +infra1 + +[galera_all] +infra1 + +[memcached_all] +infra1 + +[service_all:children] +rabbitmq_all +galera_all +memcached_all + +[keystone_all] +infra1 + +[tacker_all] +tacker1 + +[utility_all] +tacker1 + +[tacker_all] +tacker1 diff --git a/tests/os_tacker-overrides.yml b/tests/os_tacker-overrides.yml new file mode 100644 index 0000000..0dbae15 --- /dev/null +++ b/tests/os_tacker-overrides.yml @@ -0,0 +1,30 @@ +--- +# Copyright 2017, SUSE LINUX GmbH +# +# 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. + +tacker_service_tenant_name: service +tacker_rabbitmq_port: "{{ rabbitmq_port }}" +tacker_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" +tacker_rabbitmq_servers: "{{ rabbitmq_servers }}" +tacker_rabbitmq_host_group: "{{ rabbitmq_host_group }}" +tacker_service_publicuri: "{{ tacker_service_proto }}://{{ hostvars[groups['tacker_all'][0]]['ansible_host'] }}:{{ tacker_service_port }}" +tacker_service_adminurl: "{{ tacker_service_proto }}://{{ hostvars[groups['tacker_all'][0]]['ansible_host'] }}:{{ tacker_service_port }}" +tacker_service_adminuri: "{{ tacker_service_proto }}://{{ hostvars[groups['tacker_all'][0]]['ansible_host'] }}:{{ tacker_service_port }}" +tacker_aodh_enabled: false +tacker_gnocchi_enabled: false +tacker_rabbitmq_password: "secrete" +tacker_service_password: "secrete" +tacker_container_mysql_password: "secrete" +tacker_developer_mode: true +tacker_galera_address: "{{ test_galera_host }}" diff --git a/tests/test-install-tacker.yml b/tests/test-install-tacker.yml new file mode 100644 index 0000000..095c7d4 --- /dev/null +++ b/tests/test-install-tacker.yml @@ -0,0 +1,34 @@ +--- +# Copyright 2017, SUSE Linux GmbH +# +# 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: Playbook for deploying tacker + hosts: tacker_all + user: root + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - include: common/ensure-rabbitmq.yml + vhost_name: "{{ tacker_rabbitmq_vhost }}" + user_name: "{{ tacker_rabbitmq_userid }}" + user_password: "{{ tacker_rabbitmq_password }}" + when: "{{ groups['rabbitmq_all'] is defined }}" + - include: common/create-grant-db.yml + db_name: "{{ tacker_galera_database }}" + db_password: "{{ tacker_container_mysql_password }}" + roles: + - role: os_tacker + vars_files: + - common/test-vars.yml diff --git a/tests/test-tacker-functional.yml b/tests/test-tacker-functional.yml new file mode 100644 index 0000000..857e6bd --- /dev/null +++ b/tests/test-tacker-functional.yml @@ -0,0 +1,30 @@ +--- +# 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. + +- name: Ensure tacker APIs are reachable + hosts: tacker_all + user: root + gather_facts: false + tasks: + - name: check tacker api + uri: + url: "http://localhost:{{ item }}" + status_code: 200 + register: result + until: result.status == 200 + retries: 5 + delay: 10 + with_items: + - 8888 diff --git a/tests/test.yml b/tests/test.yml index 9eda09e..675cb8e 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,5 +1,29 @@ --- -- hosts: localhost - remote_user: root - roles: - - os_tacker \ No newline at end of file +# Copyright 2017, SUSE Linux GmbH +# +# 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 RabbitMQ/MariaDB +- include: common/test-install-infra.yml + +# Install Keystone +- include: common/test-install-keystone.yml + +# Install Tacker +- include: test-install-tacker.yml + +# Test Tacker +- include: test-tacker-functional.yml diff --git a/tests/tests-repo-clone.sh b/tests/tests-repo-clone.sh new file mode 100755 index 0000000..9c793c5 --- /dev/null +++ b/tests/tests-repo-clone.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# 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. + +# 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. + +# WARNING: +# This file is maintained in the openstack-ansible-tests repository: +# https://git.openstack.org/cgit/openstack/openstack-ansible-tests +# If you need to change this script, then propose the change there. +# Once it merges, the change will be replicated to the other repositories. + +## Shell Opts ---------------------------------------------------------------- + +set -e + +## Vars ---------------------------------------------------------------------- + +export TESTING_HOME=${TESTING_HOME:-$HOME} +export WORKING_DIR=${WORKING_DIR:-$(pwd)} +export CLONE_UPGRADE_TESTS=${CLONE_UPGRADE_TESTS:-no} + +## Functions ----------------------------------------------------------------- + +function create_tests_clonemap { + +# Prepare the clonemap for zuul-cloner to use +cat > ${TESTING_HOME}/tests-clonemap.yaml << EOF +clonemap: + - name: openstack/openstack-ansible-tests + dest: ${WORKING_DIR}/tests/common +EOF + +} + +## Main ---------------------------------------------------------------------- + +# If zuul-cloner is present, use it so that we +# also include any dependent patches from the +# tests repo noted in the commit message. +if [[ -x /usr/zuul-env/bin/zuul-cloner ]]; then + + # Prepare the clonemap for zuul-cloner to use + create_tests_clonemap + + # Execute the clone + /usr/zuul-env/bin/zuul-cloner \ + --cache-dir /opt/git \ + --map ${TESTING_HOME}/tests-clonemap.yaml \ + git://git.openstack.org \ + openstack/openstack-ansible-tests + + # Clean up the clonemap. + rm -f ${TESTING_HOME}/tests-clonemap.yaml + +# Alternatively, use a simple git-clone. We do +# not re-clone if the directory exists already +# to prevent overwriting any local changes which +# may have been made. +elif [[ ! -d tests/common ]]; 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} ${WORKING_DIR}/tests/common + else + git clone \ + https://git.openstack.org/openstack/openstack-ansible-tests \ + ${WORKING_DIR}/tests/common + fi +fi + +# If this test set includes an upgrade test, the +# previous stable release tests repo must also be +# cloned. +# Note: +# Dependent patches to the previous stable release +# tests repo are not supported. +if [[ "${CLONE_UPGRADE_TESTS}" == "yes" ]]; then + if [[ ! -d "${WORKING_DIR}/tests/common/previous" ]]; then + git clone -b stable/ocata \ + https://git.openstack.org/openstack/openstack-ansible-tests \ + ${WORKING_DIR}/tests/common/previous + fi +fi diff --git a/tox.ini b/tox.ini index b3d4ada..349cb5c 100644 --- a/tox.ini +++ b/tox.ini @@ -119,27 +119,12 @@ install_command = commands = bash -c "{toxinidir}/tests/common/test-log-collect.sh" -# TODO(mbuil): Add functional testing -#[testenv:functional] -## Ignore_errors is set to true so that the logs are collected at the -## end of the run. This will not produce a false positive. Any -## exception will be mark the run as failed and exit 1 after all of -## the commands have been iterated through. -#ignore_errors = True -## NOTE(odyssey4me): this target does not use constraints because -## it doesn't work in OpenStack-CI yet. Once that's fixed, we can -## drop the install_command. -#install_command = -# {[testenv:func_base]install_command} -#deps = -# {[testenv:ansible]deps} -#commands = -# {[testenv:ansible]commands} -# ansible-playbook -i {toxinidir}/tests/inventory \ -# -e "install_test_packages=True" \ -# {toxinidir}/tests/test.yml -vvvv -# {[testenv:func_logs]commands} - +[testenv:functional] +deps = + {[testenv:ansible]deps} +commands = + bash -c "{toxinidir}/tests/tests-repo-clone.sh" + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" [testenv:linters] deps =