From 76eee2fa7ee3801c0dfdc73d9634fdb8353174a9 Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Tue, 6 Sep 2016 21:49:27 +0100 Subject: [PATCH] Ensure tempest runs independently in testing In tempest role tests we install tempest on a container that already has other services installed on it. To ensure the tempest role is indepedent we should test it by deploying it in it's own container. We need to fix the dependencies for the tempest role by installing git on the tempest host. Change-Id: I0230f1a93d16243fc50df79b2d0780e744706c7b --- defaults/main.yml | 4 ++++ tasks/main.yml | 12 +++++++++++ tasks/tempest_install.yml | 8 ++++++++ tasks/tempest_install_apt.yml | 33 +++++++++++++++++++++++++++++++ tasks/tempest_install_yum.yml | 24 ++++++++++++++++++++++ tests/host_vars/tempest1.yml | 24 ++++++++++++++++++++++ tests/inventory | 7 ++++++- tests/test-nova-functional.yml | 2 +- tests/test-tempest-functional.yml | 2 +- tests/test-vars.yml | 4 ++-- vars/redhat-7.yml | 17 ++++++++++++++++ vars/ubuntu-14.04.yml | 17 ++++++++++++++++ vars/ubuntu-16.04.yml | 17 ++++++++++++++++ 13 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 tasks/tempest_install_apt.yml create mode 100644 tasks/tempest_install_yum.yml create mode 100644 tests/host_vars/tempest1.yml create mode 100644 vars/redhat-7.yml create mode 100644 vars/ubuntu-14.04.yml create mode 100644 vars/ubuntu-16.04.yml diff --git a/defaults/main.yml b/defaults/main.yml index 2cb2a64d..0e461423 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -19,6 +19,10 @@ is_metal: True ## Verbosity Options debug: False +# Set the package install state for distribution packages +# # Options are 'present' and 'latest' +tempest_package_state: "latest" + tempest_git_repo: https://git.openstack.org/openstack/tempest tempest_git_install_branch: master tempest_requirements_git_repo: https://git.openstack.org/openstack/requirements diff --git a/tasks/main.yml b/tasks/main.yml index c5f89e26..345a82ee 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Gather variables for each operating system + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" + - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" + - "{{ ansible_distribution | lower }}.yml" + - "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml" + - "{{ ansible_os_family | lower }}.yml" + tags: + - always + - include: tempest_install.yml - include: tempest_resources.yml diff --git a/tasks/tempest_install.yml b/tasks/tempest_install.yml index a178bafa..2071757c 100644 --- a/tasks/tempest_install.yml +++ b/tasks/tempest_install.yml @@ -13,6 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +- include: tempest_install_apt.yml + when: + - ansible_pkg_mgr == 'apt' + +- include: tempest_install_yum.yml + when: + - ansible_pkg_mgr == 'yum' + - name: Create developer mode constraint file copy: dest: "/opt/developer-pip-constraints.txt" diff --git a/tasks/tempest_install_apt.yml b/tasks/tempest_install_apt.yml new file mode 100644 index 00000000..aa07e960 --- /dev/null +++ b/tasks/tempest_install_apt.yml @@ -0,0 +1,33 @@ +--- +# 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: Update apt sources + apt: + update_cache: yes + cache_valid_time: 600 + register: apt_update + until: apt_update|success + retries: 5 + delay: 2 + +- name: Install apt packages + apt: + pkg: "{{ item }}" + state: "{{ tempest_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ tempest_distro_packages }}" diff --git a/tasks/tempest_install_yum.yml b/tasks/tempest_install_yum.yml new file mode 100644 index 00000000..655fa868 --- /dev/null +++ b/tasks/tempest_install_yum.yml @@ -0,0 +1,24 @@ +--- +# 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: Install yum packages + yum: + pkg: "{{ item }}" + state: "{{ tempest_package_state }}" + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ tempest_distro_packages }}" diff --git a/tests/host_vars/tempest1.yml b/tests/host_vars/tempest1.yml new file mode 100644 index 00000000..87ae8c5d --- /dev/null +++ b/tests/host_vars/tempest1.yml @@ -0,0 +1,24 @@ +--- +# 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_ssh_host: "{{ ansible_host }}" +container_name: "{{ inventory_hostname }}" +container_networks: + management_address: + address: "{{ ansible_host }}" + bridge: "br-mgmt" + interface: "eth1" + netmask: "255.255.255.0" + type: "veth" diff --git a/tests/inventory b/tests/inventory index 046804a8..1d43584e 100644 --- a/tests/inventory +++ b/tests/inventory @@ -2,10 +2,12 @@ localhost ansible_connection=local ansible_become=True neutron_local_ip=10.100.101.1 infra1 ansible_host=10.100.102.101 ansible_become=True ansible_user=root tunnel_address=10.100.101.101 openstack1 ansible_host=10.100.102.102 ansible_become=True ansible_user=root tunnel_address=10.100.101.102 neutron_local_ip=10.100.101.102 +tempest1 ansible_host=10.100.102.103 ansible_become=True ansible_user=root [all_containers] infra1 openstack1 +tempest1 [rabbitmq_all] infra1 @@ -99,4 +101,7 @@ nova_console nova_scheduler [tempest] -openstack1 +tempest1 + +[utility_all] +tempest1 diff --git a/tests/test-nova-functional.yml b/tests/test-nova-functional.yml index 9a6711d5..beb6bb8a 100644 --- a/tests/test-nova-functional.yml +++ b/tests/test-nova-functional.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Playbook for functional testing of nova - hosts: nova_api_os_compute + hosts: utility_all[0] user: root gather_facts: false tasks: diff --git a/tests/test-tempest-functional.yml b/tests/test-tempest-functional.yml index 702bc8a6..5ba32399 100644 --- a/tests/test-tempest-functional.yml +++ b/tests/test-tempest-functional.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Playbook for functional testing of tempest - hosts: keystone_all + hosts: utility_all[0] user: root gather_facts: false tasks: diff --git a/tests/test-vars.yml b/tests/test-vars.yml index 15d2df07..e697516f 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -117,7 +117,7 @@ nova_service_user_domain_id: default nova_service_user_name: nova nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" nova_venv_tag: "testing" -openrc_os_auth_url: "http://127.0.0.1:5000/v3" +openrc_os_auth_url: "http://10.100.102.102:5000/v3" openrc_os_domain_name: "Default" openrc_os_password: "{{ keystone_auth_admin_password }}" # This ensures that libvirt-python is built from source. A pre-built wheel @@ -135,7 +135,7 @@ tempest_venv_tag: "{{ tempest_git_install_branch }}" # it again here so we can refer to it in test-tempest-functional.yml tempest_venv_bin: "/opt/tempest_{{ tempest_venv_tag }}/bin" tempest_log_dir: "/var/log/" -tempest_main_group: keystone_all +tempest_main_group: utility_all tempest_service_available_aodh: False tempest_service_available_ceilometer: False tempest_service_available_cinder: False diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml new file mode 100644 index 00000000..33b3b7c8 --- /dev/null +++ b/vars/redhat-7.yml @@ -0,0 +1,17 @@ +--- +# 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. + +tempest_distro_packages: + - git diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml new file mode 100644 index 00000000..03b4c657 --- /dev/null +++ b/vars/ubuntu-14.04.yml @@ -0,0 +1,17 @@ +--- +# 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. + +tempest_distro_packages: + - git-core diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml new file mode 100644 index 00000000..03b4c657 --- /dev/null +++ b/vars/ubuntu-16.04.yml @@ -0,0 +1,17 @@ +--- +# 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. + +tempest_distro_packages: + - git-core