diff --git a/.gitignore b/.gitignore index ca2ac14c..9b3b3cf8 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ doc/build/ *.log *.sql *.sqlite +logs/* # OS generated files # ###################### @@ -61,6 +62,9 @@ releasenotes/build # Test temp files tests/plugins +tests/common +tests/test.retry +tests/playbooks -# Vagrant testing artifacts +# Vagrant artifacts .vagrant diff --git a/run_tests.sh b/run_tests.sh index 0a49aa3e..482a3894 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -24,23 +24,23 @@ if [ ! "$(which pip)" ]; then fi # Install bindep and tox -pip install bindep tox +sudo pip install bindep tox # CentOS 7 requires two additional packages: # redhat-lsb-core - for bindep profile support # epel-release - required to install python-ndg_httpsclient/python2-pyasn1 if [ "$(which yum)" ]; then - yum -y install redhat-lsb-core epel-release + sudo yum -y install redhat-lsb-core epel-release fi # Install OS packages using bindep if apt-get -v >/dev/null 2>&1 ; then - apt-get update + sudo apt-get update DEBIAN_FRONTEND=noninteractive \ - apt-get -q --option "Dpkg::Options::=--force-confold" \ + sudo apt-get -q --option "Dpkg::Options::=--force-confold" \ --assume-yes install `bindep -b -f bindep.txt test` else - yum install -y `bindep -b -f bindep.txt test` + sudo yum install -y `bindep -b -f bindep.txt test` fi # run through each tox env and execute the test diff --git a/tests/ansible-role-requirements.yml b/tests/ansible-role-requirements.yml index a20581ff..bc760c69 100644 --- a/tests/ansible-role-requirements.yml +++ b/tests/ansible-role-requirements.yml @@ -14,6 +14,10 @@ src: https://git.openstack.org/openstack/openstack-ansible-memcached_server 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 diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml index dcd8b8ba..2245b745 100644 --- a/tests/group_vars/all_containers.yml +++ b/tests/group_vars/all_containers.yml @@ -13,7 +13,6 @@ # 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: diff --git a/tests/test-install-tempest.yml b/tests/host_vars/infra1.yml similarity index 72% rename from tests/test-install-tempest.yml rename to tests/host_vars/infra1.yml index 3e0e428a..15318d86 100644 --- a/tests/test-install-tempest.yml +++ b/tests/host_vars/infra1.yml @@ -1,6 +1,5 @@ - --- -# Copyright 2015, Rackspace US, Inc. +# 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. @@ -14,11 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Playbook for deploying tempest - hosts: tempest - user: root - gather_facts: true - roles: - - role: "{{ rolename | basename }}" - vars_files: - - test-vars.yml +ansible_host: 10.1.1.101 +ansible_become: True +ansible_user: root +tunnel_address: 10.1.2.101 diff --git a/tests/host_vars/localhost.yml b/tests/host_vars/localhost.yml index 3b7e6665..a16ca6d5 100644 --- a/tests/host_vars/localhost.yml +++ b/tests/host_vars/localhost.yml @@ -13,7 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -neutron_provider_networks: - network_types: "vxlan,flat" - network_mappings: "flat:eth12" - network_vxlan_ranges: "1:1000" +ansible_become: True +ansible_host: 127.0.0.1 +neutron_local_ip: 10.1.2.1 +ansible_python_interpreter: "/usr/bin/python2" +bridges: + - name: "br-mgmt" + ip_addr: "10.1.1.1" + - name: "br-vxlan" + ip_addr: "10.1.2.1" + - name: "br-vlan" + ip_addr: "10.1.3.1" + veth_peer: "eth12" diff --git a/tests/host_vars/openstack1.yml b/tests/host_vars/openstack1.yml index 3b7e6665..e08a3c7a 100644 --- a/tests/host_vars/openstack1.yml +++ b/tests/host_vars/openstack1.yml @@ -17,3 +17,8 @@ neutron_provider_networks: network_types: "vxlan,flat" network_mappings: "flat:eth12" network_vxlan_ranges: "1:1000" +ansible_host: 10.1.1.102 +ansible_become: True +ansible_user: root +tunnel_address: 10.1.2.102 +neutron_local_ip: 10.1.2.102 diff --git a/tests/host_vars/tempest1.yml b/tests/host_vars/tempest1.yml index 87ae8c5d..787c5ceb 100644 --- a/tests/host_vars/tempest1.yml +++ b/tests/host_vars/tempest1.yml @@ -13,12 +13,7 @@ # 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" +ansible_host: 10.1.1.103 +ansible_become: True +ansible_user: root +tunnel_address: 10.1.2.103 diff --git a/tests/inventory b/tests/inventory index 1d43584e..b0f73ad5 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,8 +1,8 @@ [all] -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 +localhost +infra1 +openstack1 +tempest1 [all_containers] infra1 @@ -15,9 +15,13 @@ infra1 [galera_all] infra1 +[memcached_all] +infra1 + [service_all:children] rabbitmq_all galera_all +memcached_all [keystone_all] openstack1 @@ -100,8 +104,5 @@ nova_conductor nova_console nova_scheduler -[tempest] -tempest1 - [utility_all] tempest1 diff --git a/tests/iptables-clear.sh b/tests/iptables-clear.sh deleted file mode 100755 index eb782c52..00000000 --- a/tests/iptables-clear.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/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. -# - -iptables -F -iptables -X -iptables -t nat -F -iptables -t nat -X -iptables -t mangle -F -iptables -t mangle -X -iptables -P INPUT ACCEPT -iptables -P FORWARD ACCEPT -iptables -P OUTPUT ACCEPT diff --git a/tests/test-prepare-containers.yml b/tests/tempest-overrides.yml similarity index 51% rename from tests/test-prepare-containers.yml rename to tests/tempest-overrides.yml index f85472e4..33413d95 100644 --- a/tests/test-prepare-containers.yml +++ b/tests/tempest-overrides.yml @@ -13,19 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Playbook for creating containers - hosts: all_containers - gather_facts: false - roles: - - role: "lxc_container_create" - lxc_container_backing_store: dir - global_environment_variables: - PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - post_tasks: - - name: Wait for ssh to be available - local_action: - module: wait_for - port: "{{ ansible_ssh_port | default('22') }}" - host: "{{ ansible_ssh_host | default(inventory_hostname) }}" - search_regex: OpenSSH - delay: 1 +# This ensures that libvirt-python is built from source. A pre-built wheel +# can be missing libvirt capabilities from the installed version of +# libvirt-bin, leading to nova-compute failing to start. +# TODO(jmccrory) Revisit this at some point +pip_install_options: "--no-binary libvirt-python" +tempest_plugins: + - name: designate-tempest-plugin + repo: https://git.openstack.org/openstack/designate-tempest-plugin + branch: master + +neutron_provider_networks: + network_types: "vxlan,flat" + network_mappings: "flat:eth12" + network_vxlan_ranges: "1:1000" diff --git a/tests/test-install-glance.yml b/tests/test-install-glance.yml deleted file mode 100644 index ac8899a3..00000000 --- a/tests/test-install-glance.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# 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. - -- name: Playbook for deploying glance - hosts: glance_all - user: root - gather_facts: true - pre_tasks: - - name: Ensure rabbitmq vhost - rabbitmq_vhost: - name: "{{ glance_rabbitmq_vhost }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['glance_all'][0] - - name: Ensure rabbitmq user - rabbitmq_user: - user: "{{ glance_rabbitmq_userid }}" - password: "{{ glance_rabbitmq_password }}" - vhost: "{{ glance_rabbitmq_vhost }}" - configure_priv: ".*" - read_priv: ".*" - write_priv: ".*" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['glance_all'][0] - - name: Create DB for service - mysql_db: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ glance_galera_database }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['glance_all'][0] - - name: Grant access to the DB for the service - mysql_user: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ glance_galera_database }}" - password: "{{ glance_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ glance_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['glance_all'][0] - roles: - - role: "os_glance" - vars_files: - - test-vars.yml diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml deleted file mode 100644 index 86e8625e..00000000 --- a/tests/test-install-infra.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# 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. - -- name: Playbook for deploying infra services - hosts: service_all - user: root - gather_facts: true - roles: - - role: "rabbitmq_server" - rabbitmq_cookie_token: secrete - - role: "galera_server" - galera_root_password: secrete - galera_root_user: root - galera_innodb_buffer_pool_size: 512M - galera_innodb_log_buffer_size: 32M - galera_server_id: "{{ inventory_hostname | string_2_int }}" - galera_wsrep_node_name: "{{ inventory_hostname }}" - galera_wsrep_provider_options: - - { option: "gcache.size", value: "32M" } - galera_server_id: "{{ inventory_hostname | string_2_int }}" diff --git a/tests/test-install-keystone.yml b/tests/test-install-keystone.yml deleted file mode 100644 index ef35b81b..00000000 --- a/tests/test-install-keystone.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# 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. - -- name: Playbook for deploying keystone - hosts: keystone_all - user: root - gather_facts: true - pre_tasks: - - name: Ensure rabbitmq vhost - rabbitmq_vhost: - name: "{{ keystone_rabbitmq_vhost }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['keystone_all'][0] - - name: Ensure rabbitmq user - rabbitmq_user: - user: "{{ keystone_rabbitmq_userid }}" - password: "{{ keystone_rabbitmq_password }}" - vhost: "{{ keystone_rabbitmq_vhost }}" - configure_priv: ".*" - read_priv: ".*" - write_priv: ".*" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['keystone_all'][0] - - name: Create DB for service - mysql_db: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ keystone_galera_database }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['keystone_all'][0] - - name: Grant access to the DB for the service - mysql_user: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ keystone_galera_database }}" - password: "{{ keystone_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ keystone_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['keystone_all'][0] - roles: - - role: os_keystone - vars_files: - - test-vars.yml diff --git a/tests/test-install-neutron.yml b/tests/test-install-neutron.yml deleted file mode 100644 index 8750f74d..00000000 --- a/tests/test-install-neutron.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -# 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. - -- name: Make /lib/modules accessible on neutron_agent containers - hosts: neutron_agent - user: root - gather_facts: true - tasks: - - name: Use the unconfined aa profile - lxc_container: - name: "{{ container_name }}" - container_config: - - "lxc.aa_profile=unconfined" - delegate_to: "{{ physical_host }}" - - name: Neutron extra lxc config - lxc_container: - name: "{{ container_name }}" - container_command: | - [[ ! -d "/lib/modules" ]] && mkdir -p "/lib/modules" - container_config: - - "lxc.cgroup.devices.allow=a *:* rmw" - - "lxc.mount.entry=/lib/modules lib/modules none bind 0 0" - delegate_to: "{{ physical_host }}" - - name: Wait for ssh to be available - local_action: - module: wait_for - port: "{{ ansible_ssh_port | default('22') }}" - host: "{{ ansible_ssh_host | default(inventory_hostname) }}" - search_regex: OpenSSH - delay: 1 - - name: Add iptables rule for communication w/ metadata agent - command: /sbin/iptables -t mangle -A POSTROUTING -p tcp --sport 80 -j CHECKSUM --checksum-fill - -- name: Deploy neutron - hosts: neutron_all - user: root - gather_facts: true - pre_tasks: - # NOTE: These are typically installed in the repo server where we build the - # neutron wheel - - name: Install packages required to build neutron python package - apt: - name: "{{ item }}" - with_items: - - libffi-dev - when: inventory_hostname in groups['neutron_all'] - - name: Ensure rabbitmq vhost - rabbitmq_vhost: - name: "{{ neutron_rabbitmq_vhost }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['neutron_all'][0] - - name: Ensure rabbitmq user - rabbitmq_user: - user: "{{ neutron_rabbitmq_userid }}" - password: "{{ neutron_rabbitmq_password }}" - vhost: "{{ neutron_rabbitmq_vhost }}" - configure_priv: ".*" - read_priv: ".*" - write_priv: ".*" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['neutron_all'][0] - - name: Create DB for service - mysql_db: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ neutron_galera_database }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['neutron_all'][0] - - name: Grant access to the DB for the service - mysql_user: - login_user: "root" - login_password: "secrete" - login_host: "localhost" - name: "{{ neutron_galera_database }}" - password: "{{ neutron_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ neutron_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['neutron_all'][0] - - name: Check if this is an OpenStack-CI nodepool instance - stat: - path: /etc/nodepool/provider - register: nodepool - delegate_to: localhost - - name: Determine the existing Ubuntu repo URL (only on OpenStack-CI) - shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list' - register: ubuntu_repo_url - changed_when: false - when: nodepool.stat.exists | bool - delegate_to: localhost - - name: Set Ubuntu Cloud Archive repo URL based on discovered information - set_fact: - uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive" - when: nodepool.stat.exists | bool - roles: - - role: "os_neutron" - vars_files: - - test-vars.yml diff --git a/tests/test-install-nova.yml b/tests/test-install-nova.yml deleted file mode 100644 index 9b99ccb5..00000000 --- a/tests/test-install-nova.yml +++ /dev/null @@ -1,114 +0,0 @@ ---- -# 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. - -- name: Playbook for deploying nova - hosts: nova_all - user: root - gather_facts: true - pre_tasks: - # NOTE: These are typically installed in the repo server where we build the - # nova wheel - - name: Install packages required to build nova python package - apt: - name: "{{ item }}" - with_items: - - libxml2-dev - - libxslt-dev - - libffi-dev - - pkg-config - - libvirt-dev - when: inventory_hostname in groups['nova_all'] - - name: Ensure rabbitmq vhost - rabbitmq_vhost: - name: "{{ nova_rabbitmq_vhost }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['nova_all'][0] - - name: Ensure rabbitmq user - rabbitmq_user: - user: "{{ nova_rabbitmq_userid }}" - password: "{{ nova_rabbitmq_password }}" - vhost: "{{ nova_rabbitmq_vhost }}" - configure_priv: ".*" - read_priv: ".*" - write_priv: ".*" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['nova_all'][0] - - name: Create DB for service - mysql_db: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ nova_galera_address }}" - name: "{{ nova_galera_database }}" - state: "present" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['nova_all'][0] - - name: Grant access to the DB for the service - mysql_user: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ nova_galera_address }}" - name: "{{ nova_galera_database }}" - password: "{{ nova_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ nova_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.102.101" - when: inventory_hostname == groups['nova_all'][0] - - name: Create API DB for service - mysql_db: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ nova_api_galera_address }}" - name: "{{ nova_api_galera_database }}" - state: "present" - when: inventory_hostname == groups['nova_all'][0] - - name: Grant access to the API DB for the service - mysql_user: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "{{ nova_api_galera_address }}" - name: "{{ nova_api_galera_user }}" - password: "{{ nova_api_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ nova_api_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - when: inventory_hostname == groups['nova_all'][0] - - name: Check if this is an OpenStack-CI nodepool instance - stat: - path: /etc/nodepool/provider - register: nodepool - delegate_to: localhost - - name: Determine the existing Ubuntu repo URL (only on OpenStack-CI) - shell: 'awk "/^deb .*ubuntu\/? {{ ansible_distribution_release }} main/ {print \$2; exit}" /etc/apt/sources.list' - register: ubuntu_repo_url - changed_when: false - when: nodepool.stat.exists | bool - delegate_to: localhost - - name: Set Ubuntu Cloud Archive repo URL based on discovered information - set_fact: - uca_apt_repo_url: "{{ ubuntu_repo_url.stdout | netorigin }}/ubuntu-cloud-archive" - when: nodepool.stat.exists | bool - roles: - - role: "os_nova" - vars_files: - - test-vars.yml diff --git a/tests/test-nova-functional.yml b/tests/test-nova-functional.yml index beb6bb8a..adf16cfb 100644 --- a/tests/test-nova-functional.yml +++ b/tests/test-nova-functional.yml @@ -25,4 +25,4 @@ environment: RUN_TEMPEST_OPTS: "--serial" vars_files: - - test-vars.yml + - common/test-vars.yml diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml deleted file mode 100644 index 46d9a80f..00000000 --- a/tests/test-prepare-host.yml +++ /dev/null @@ -1,94 +0,0 @@ ---- -# 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. - -- name: Playbook for configuring the LXC host - hosts: localhost - pre_tasks: - - name: Clear iptables rules - shell: ./iptables-clear.sh - # Make sure OS does not have a stale package cache. - - name: Update apt cache - apt: - update_cache: yes - when: ansible_os_family == 'Debian' - - name: Ensure root's new public ssh key is in authorized_keys - authorized_key: - user: root - key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}" - manage_dir: no - - set_fact: - lxc_container_ssh_key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}" - - name: Check if this is an OpenStack-CI nodepool instance - stat: - path: /etc/nodepool/provider - register: nodepool - - name: Set the files to copy into the container cache for OpenStack-CI instances - set_fact: - lxc_container_cache_files: - - { src: '/etc/pip.conf', dest: '/etc/pip.conf' } - when: nodepool.stat.exists | bool - post_tasks: - - name: Ensure that /etc/network/interfaces.d/ exists - file: - path: /etc/network/interfaces.d/ - state: directory - tags: - - networking-dir-create - - - name: Copy network configuration - template: - src: test-tempest-interfaces.cfg.j2 - dest: /etc/network/interfaces.d/tempest_interfaces.cfg - register: tempest_interfaces - tags: - - networking-interfaces-file - - - name: Ensure our interfaces.d configuration files are loaded automatically - lineinfile: - dest: /etc/network/interfaces - line: "source /etc/network/interfaces.d/*.cfg" - tags: - - networking-interfaces-load - - - name: Shut down the network interfaces - command: "ifdown {{ item }}" - when: tempest_interfaces | changed - with_items: - - br-mgmt - - br-vlan - - br-vxlan - tags: - - networking-interfaces-stop - - - name: Start the network interfaces - command: "ifup {{ item }}" - when: tempest_interfaces | changed - with_items: - - br-mgmt - - br-vlan - - br-vxlan - tags: - - networking-interfaces-start - - - name: Add iptables rules for lxc natting - command: /usr/local/bin/lxc-system-manage iptables-create - roles: - - role: "lxc_hosts" - lxc_net_address: 10.100.100.1 - lxc_net_netmask: 255.255.255.0 - lxc_net_dhcp_range: 10.100.100.2,10.100.100.99 - lxc_net_bridge: lxcbr0 - lxc_kernel_options: - - { key: 'fs.inotify.max_user_instances', value: 1024 } diff --git a/tests/test-prepare-keys.yml b/tests/test-prepare-keys.yml deleted file mode 100644 index a4fad4f5..00000000 --- a/tests/test-prepare-keys.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -# 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. - -# NOTE: we use become_user because setting become: no or become: false -# doesn't seem to override the ansible_become=true in the -# inventory -- name: Playbook for establishing ssh keys - hosts: localhost - become_user: "{{ ansible_ssh_user }}" - pre_tasks: - - name: Create ssh key pair for root - user: - name: "{{ ansible_ssh_user }}" - generate_ssh_key: "yes" - ssh_key_bits: 2048 - ssh_key_file: ".ssh/id_rsa" - - name: Get the calling user's key - command: cat ~/.ssh/id_rsa.pub - register: key_get - - set_fact: - lxc_container_ssh_key: "{{ key_get.stdout }}" diff --git a/tests/test-tempest-functional.yml b/tests/test-tempest-functional.yml index 5ba32399..22b97059 100644 --- a/tests/test-tempest-functional.yml +++ b/tests/test-tempest-functional.yml @@ -28,4 +28,4 @@ environment: RUN_TEMPEST_OPTS: "--serial" vars_files: - - test-vars.yml + - common/test-vars.yml diff --git a/tests/test-tempest-interfaces.cfg.j2 b/tests/test-tempest-interfaces.cfg.j2 deleted file mode 100644 index 5ab09f21..00000000 --- a/tests/test-tempest-interfaces.cfg.j2 +++ /dev/null @@ -1,58 +0,0 @@ -## The default networking requires several bridges. These bridges were named to be informative -## however they can be named what ever you like and is adaptable to any network infrastructure -## environment. This file serves as an example of how to setup basic networking and was ONLY -## built for the purpose of being an example and used expressly in the building of an ALL IN -## ONE development environment. - -auto br-mgmt -iface br-mgmt inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - # Notice the bridge port is the vlan tagged interface - bridge_ports none - address 10.100.102.1 - netmask 255.255.255.0 - offload-sg off - -auto br-vxlan -iface br-vxlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - bridge_ports none - address 10.100.101.1 - netmask 255.255.255.0 - offload-sg off - # To ensure ssh checksum is correct - up /sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill - down /sbin/iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill - # To provide internet connectivity to instances - up /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE - down /sbin/iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE - -auto br-vlan -iface br-vlan inet static - bridge_stp off - bridge_waitport 0 - bridge_fd 0 - address 10.1.13.200 - netmask 255.255.254.0 - offload-sg off - # Create veth pair, don't bomb if already exists - pre-up ip link add br-vlan-veth type veth peer name eth12 || true - # Set both ends UP - pre-up ip link set br-vlan-veth up - pre-up ip link set eth12 up - # Delete veth pair on DOWN - post-down ip link del br-vlan-veth || true - bridge_ports br-vlan-veth - -# Add an additional address to br-vlan -iface br-vlan inet static - # Flat network default gateway - # -- This needs to exist somewhere for network reachability - # -- from the router namespace for floating IP paths. - # -- Putting this here is primarily for tempest to work. - address 10.1.13.1 - netmask 255.255.255.0 diff --git a/tests/test-vars.yml b/tests/test-vars.yml deleted file mode 100644 index e697516f..00000000 --- a/tests/test-vars.yml +++ /dev/null @@ -1,152 +0,0 @@ ---- -# 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. - -cinder_backends_rbd_inuse: false -cinder_ceph_client: cinder -debug: true -external_lb_vip_address: 10.100.102.102 -galera_client_drop_config_file: false -galera_root_user: root -galera_root_password: secrete -glance_container_mysql_password: "SuperSecrete" -glance_developer_mode: true -glance_galera_address: 10.100.102.101 -glance_galera_database: glance -glance_git_install_branch: master -glance_host: "{{ internal_lb_vip_address }}" -glance_profiler_hmac_key: "secrete" -glance_rabbitmq_port: "{{ rabbitmq_port }}" -glance_rabbitmq_servers: "{{ rabbitmq_servers }}" -glance_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" -glance_rabbitmq_password: "secrete" -glance_rabbitmq_userid: glance -glance_rabbitmq_vhost: /glance -glance_requirements_git_install_branch: master -glance_service_password: "secrete" -glance_service_port: 9292 -glance_venv_tag: "testing" -internal_lb_vip_address: 10.100.102.102 -keystone_admin_tenant_name: admin -keystone_admin_user_name: admin -keystone_auth_admin_password: SuperSecretePassword -keystone_container_mysql_password: "SuperSecrete" -keystone_developer_mode: true -keystone_galera_address: 10.100.102.101 -keystone_galera_database: keystone -keystone_git_install_branch: master -keystone_rabbitmq_password: "secrete" -keystone_rabbitmq_port: "{{ rabbitmq_port }}" -keystone_rabbitmq_servers: "{{ rabbitmq_servers }}" -keystone_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" -keystone_rabbitmq_userid: keystone -keystone_rabbitmq_vhost: /keystone -keystone_requirements_git_install_branch: master -keystone_service_adminuri: "http://{{ internal_lb_vip_address }}:35357" -keystone_service_adminuri_insecure: false -keystone_service_adminurl: "{{ keystone_service_adminuri }}/v3" -keystone_service_internaluri: "http://{{ internal_lb_vip_address }}:5000" -keystone_service_internaluri_insecure: false -keystone_service_internalurl: "{{ keystone_service_internaluri }}/v3" -keystone_service_password: "secrete" -keystone_service_region: RegionOne -keystone_venv_tag: "testing" -lxd_trust_password: "SuperSecrete" -memcached_encryption_key: "secrete" -memcached_servers: 127.0.0.1 -neutron_container_mysql_password: SuperSecrete -neutron_developer_mode: true -neutron_galera_address: 10.100.102.101 -neutron_galera_database: neutron -neutron_git_install_branch: master -neutron_ha_vrrp_auth_password: secrete -neutron_management_address: "{{ internal_lb_vip_address }}" -neutron_rabbitmq_port: "{{ rabbitmq_port }}" -neutron_rabbitmq_servers: "{{ rabbitmq_servers }}" -neutron_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" -neutron_rabbitmq_password: secrete -neutron_rabbitmq_userid: neutron -neutron_rabbitmq_vhost: /neutron -neutron_requirements_git_install_branch: master -neutron_service_adminurl: http://{{ internal_lb_vip_address }}:9696 -neutron_service_password: "secrete" -neutron_service_project_name: service -neutron_service_region: RegionOne -neutron_service_user_name: neutron -neutron_venv_tag: testing -nova_api_container_mysql_password: "SuperSecrete" -nova_api_galera_address: 10.100.102.101 -nova_api_galera_database: nova_api -nova_api_galera_user: nova_api -nova_container_mysql_password: "SuperSecrete" -nova_developer_mode: true -nova_galera_address: 10.100.102.101 -nova_galera_database: nova -nova_git_install_branch: master -nova_glance_api_servers: "http://{{ glance_host }}:{{ glance_service_port }}" -nova_keystone_auth_plugin: password -nova_management_address: "10.100.102.1" -nova_metadata_port: 8775 -nova_metadata_proxy_secret: "secrete" -nova_novncproxy_vncserver_listen: localhost -nova_novncproxy_vncserver_proxyclient_address: localhost -nova_rabbitmq_port: "{{ rabbitmq_port }}" -nova_rabbitmq_servers: "{{ rabbitmq_servers }}" -nova_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" -nova_rabbitmq_password: "secrete" -nova_rabbitmq_userid: nova -nova_rabbitmq_vhost: /nova -nova_requirements_git_install_branch: master -nova_service_adminurl: "http://{{ internal_lb_vip_address }}:8774" -nova_service_password: "secrete" -nova_service_project_domain_id: default -nova_service_project_name: service -nova_service_region: RegionOne -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://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 -# can be missing libvirt capabilities from the installed version of -# libvirt-bin, leading to nova-compute failing to start. -# TODO(jmccrory) Revisit this at some point -pip_install_options: "--no-binary libvirt-python" -rabbitmq_port: 5672 -rabbitmq_servers: 10.100.102.101 -rabbitmq_use_ssl: False -tempest_developer_mode: True -tempest_git_install_branch: master -tempest_venv_tag: "{{ tempest_git_install_branch }}" -# tempest_venv_bin is the same as the default in os_tempest role, but we set -# 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: utility_all -tempest_service_available_aodh: False -tempest_service_available_ceilometer: False -tempest_service_available_cinder: False -tempest_service_available_glance: True -tempest_service_available_heat: False -tempest_service_available_horizon: False -tempest_service_available_neutron: True -tempest_service_available_nova: True -tempest_service_available_swift: False -tempest_service_available_zaqar: False -tempest_plugins: - - name: designate-tempest-plugin - repo: https://git.openstack.org/openstack/designate-tempest-plugin - branch: master diff --git a/tests/test.yml b/tests/test.yml index e48b2e37..8dcfb252 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -14,31 +14,31 @@ # limitations under the License. # Prepare the user ssh keys -- include: test-prepare-keys.yml +- include: common/test-prepare-keys.yml # Prepare the host -- include: test-prepare-host.yml +- include: common/test-prepare-host.yml # Prepare the containers -- include: test-prepare-containers.yml +- include: common/test-prepare-containers.yml # Install RabbitMQ/MariaDB -- include: test-install-infra.yml +- include: common/test-install-infra.yml # Install Keystone -- include: test-install-keystone.yml +- include: common/test-install-keystone.yml # Install Glance -- include: test-install-glance.yml +- include: common/test-install-glance.yml # Install Neutron -- include: test-install-neutron.yml +- include: common/test-install-neutron.yml # Install Nova -- include: test-install-nova.yml +- include: common/test-install-nova.yml # Install Tempest -- include: test-install-tempest.yml +- include: common/test-install-tempest.yml # Test Tempest - include: test-tempest-functional.yml diff --git a/tox.ini b/tox.ini index f025358b..c4dab8ae 100644 --- a/tox.ini +++ b/tox.ini @@ -22,12 +22,11 @@ passenv = NO_PROXY whitelist_externals = bash - git - rm - wget setenv = - VIRTUAL_ENV={envdir} PYTHONUNBUFFERED=1 + ROLE_NAME=os_tempest + VIRTUAL_ENV={envdir} + WORKING_DIR={toxinidir} [testenv:docs] @@ -53,17 +52,17 @@ commands = {posargs} +[testenv:tests_clone] +commands = + bash -c "if [ ! -d "{toxinidir}/tests/common" ]; then \ + git clone https://git.openstack.org/openstack/openstack-ansible-tests {toxinidir}/tests/common; \ + fi" + + [testenv:pep8] commands = - # Run hacking/flake8 check for all python files - bash -c "grep --recursive --binary-files=without-match \ - --files-with-match '^.!.*python$' \ - --exclude-dir .eggs \ - --exclude-dir .git \ - --exclude-dir .tox \ - --exclude-dir *.egg-info \ - --exclude-dir doc \ - {toxinidir} | xargs flake8 --verbose" + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-pep8.sh" [flake8] @@ -76,64 +75,26 @@ ignore=F403,H303 [testenv:bashate] commands = - # Run bashate check for all bash scripts - # Ignores the following rules: - # E003: Indent not multiple of 4 (we prefer to use multiples of 2) - # E006: Line longer than 79 columns (as many scripts use jinja - # templating, this is very difficult) - # E040: Syntax error determined using `bash -n` (as many scripts - # use jinja templating, this will often fail and the syntax - # error will be discovered in execution anyway) - bash -c "grep --recursive --binary-files=without-match \ - --files-with-match '^.!.*\(ba\)\?sh$' \ - --exclude-dir .tox \ - --exclude-dir .git \ - {toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040" + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-bashate.sh" [testenv:ansible] deps = {[testenv]deps} - ansible==1.9.4 - ansible-lint>=2.7.0,<3.0.0 -setenv = - {[testenv]setenv} - ANSIBLE_HOST_KEY_CHECKING = False - ANSIBLE_SSH_CONTROL_PATH = /tmp/%%h-%%r - # TODO (odyssey4me) These are only here as they are non-standard folder - # names for Ansible 1.9.x. We are using the standard folder names for - # Ansible v2.x. We can remove this when we move to Ansible 2.x. - ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/plugins/action - ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/plugins/callback - ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/plugins/filter - ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/plugins/lookup - # This is required as the default is the current path or a path specified - # in ansible.cfg - ANSIBLE_LIBRARY = {homedir}/.ansible/plugins/library - # This is required as the default is '/etc/ansible/roles' or a path - # specified in ansible.cfg - ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/.. + -rhttp://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt commands = - rm -rf {homedir}/.ansible/plugins - git clone https://git.openstack.org/openstack/openstack-ansible-plugins \ - {homedir}/.ansible/plugins - rm -rf {homedir}/.ansible/roles - ansible-galaxy install \ - --role-file={toxinidir}/tests/ansible-role-requirements.yml \ - --force - + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh" [testenv:ansible-syntax] deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} ansible-playbook -i {toxinidir}/tests/inventory \ --syntax-check \ --list-tasks \ - -e "rolename={toxinidir}" \ {toxinidir}/tests/test.yml @@ -145,6 +106,19 @@ commands = ansible-lint {toxinidir} +[testenv:func_base] +# 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 = + pip install -U --force-reinstall {opts} {packages} + + +[testenv:func_logs] +commands = + bash -c "{toxinidir}/tests/common/test-log-collect.sh" + + [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 @@ -155,27 +129,20 @@ ignore_errors = True # it doesn't work in OpenStack-CI yet. Once that's fixed, we can # drop the install_command. install_command = - pip install -U --force-reinstall {opts} {packages} + {[testenv:func_base]install_command} deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} ansible-playbook -i {toxinidir}/tests/inventory \ - -e "rolename={toxinidir}" \ + -e @{toxinidir}/tests/tempest-overrides.yml \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv - bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' - bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv' - bash -c 'command gzip --best --recursive "{toxinidir}/logs/"' - + {[testenv:func_logs]commands} [testenv:linters] deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:pep8]commands} {[testenv:bashate]commands}