From 4c4054781880f4e37c4c6f7adddc17a31b61a939 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Wed, 10 Aug 2016 11:40:41 -0400 Subject: [PATCH] Ansible 2.1.1 role testing Change-Id: I2db8435b0ae5b6004ebe1985c5606c0c39900a95 Signed-off-by: Kevin Carter --- .gitignore | 7 +- manual-test.rc | 33 ++++++++++ run_tests.sh | 10 +-- tests/group_vars/all_containers.yml | 1 - .../localhost.yml} | 20 ++---- tests/inventory | 9 ++- tests/test-designate-functional.yml | 9 ++- tests/test-install-designate.yml | 17 +++-- tests/test-install-infra.yml | 32 --------- tests/test-install-keystone.yml | 65 ------------------- tests/test-install-tempest.yml | 1 + tests/test-prepare-containers.yml | 33 ---------- tests/test-prepare-host.yml | 65 ------------------- tests/test-vars.yml | 57 ++-------------- tests/test.yml | 13 ++-- tox.ini | 33 +++++++--- 16 files changed, 105 insertions(+), 300 deletions(-) create mode 100644 manual-test.rc rename tests/{test-prepare-keys.yml => host_vars/localhost.yml} (55%) delete mode 100644 tests/test-install-infra.yml delete mode 100644 tests/test-install-keystone.yml delete mode 100644 tests/test-prepare-containers.yml delete mode 100644 tests/test-prepare-host.yml diff --git a/.gitignore b/.gitignore index ca2ac14..21adf3c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ doc/build/ *.log *.sql *.sqlite +logs/* # OS generated files # ###################### @@ -61,6 +62,10 @@ releasenotes/build # Test temp files tests/plugins +tests/playbooks +tests/test.retry -# Vagrant testing artifacts +# Vagrant artifacts .vagrant + + diff --git a/manual-test.rc b/manual-test.rc new file mode 100644 index 0000000..f7e7771 --- /dev/null +++ b/manual-test.rc @@ -0,0 +1,33 @@ +export VIRTUAL_ENV=$(pwd) +export ANSIBLE_HOST_KEY_CHECKING=False +export 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. +export ANSIBLE_ACTION_PLUGINS=${HOME}/.ansible/plugins/action +export ANSIBLE_CALLBACK_PLUGINS=${HOME}/.ansible/plugins/callback +export ANSIBLE_FILTER_PLUGINS=${HOME}/.ansible/plugins/filter +export ANSIBLE_LOOKUP_PLUGINS=${HOME}/.ansible/plugins/lookup + +# This is required as the default is the current path or a path specified +# in ansible.cfg +export ANSIBLE_LIBRARY=${HOME}/.ansible/plugins/library + +# This is required as the default is '/etc/ansible/roles' or a path +# specified in ansible.cfg +export ANSIBLE_ROLES_PATH=${HOME}/.ansible/roles:$(pwd)/.. + +export ANSIBLE_SSH_ARGS="-o ControlMaster=no \ + -o UserKnownHostsFile=/dev/null \ + -o StrictHostKeyChecking=no \ + -o ServerAliveInterval=64 \ + -o ServerAliveCountMax=1024 \ + -o Compression=no \ + -o TCPKeepAlive=yes \ + -o VerifyHostKeyDNS=no \ + -o ForwardX11=no \ + -o ForwardAgent=yes" + +echo "Run manual functional tests by executing the following:" +echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml -e \"rolename=$(pwd)\"" diff --git a/run_tests.sh b/run_tests.sh index 0a49aa3..482a389 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/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml index 4cc9794..83ce021 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-prepare-keys.yml b/tests/host_vars/localhost.yml similarity index 55% rename from tests/test-prepare-keys.yml rename to tests/host_vars/localhost.yml index 5a1c9ec..14bf3b0 100644 --- a/tests/test-prepare-keys.yml +++ b/tests/host_vars/localhost.yml @@ -13,19 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Playbook for establishing ssh keys - hosts: 127.0.0.1 - connection: local - become: false - 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 }}" +bridges: + - "br-mgmt" + +ansible_python_interpreter: "/usr/bin/python2" \ No newline at end of file diff --git a/tests/inventory b/tests/inventory index fbf94da..94420ac 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,5 +1,5 @@ [all] -localhost ansible_connection=local ansible_become=True +localhost ansible_become=True infra1 ansible_host=10.100.100.101 ansible_become=True openstack1 ansible_host=10.100.100.102 ansible_become=True @@ -39,12 +39,19 @@ openstack1 [keystone_all] openstack1 +[utility_all] +openstack1 + [service_all:children] rabbitmq_all galera_all +memcached_all [rabbitmq_all] infra1 [galera_all] infra1 + +[memcached_all] +infra1 \ No newline at end of file diff --git a/tests/test-designate-functional.yml b/tests/test-designate-functional.yml index cb353e3..558b7d7 100644 --- a/tests/test-designate-functional.yml +++ b/tests/test-designate-functional.yml @@ -13,16 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Playbook for functional testing of designate - hosts: designate_all +- name: Playbook for tempest testing of designate + hosts: utility_all user: root gather_facts: false tasks: - name: Run tempest shell: | . {{ tempest_venv_bin }}/activate - {{ tempest_venv_bin | dirname }}/run_tempest.sh --no-virtual-env ${RUN_TEMPEST_OPTS} designate_tempest_plugin.tests.scenario.v2.test_zones - environment: - RUN_TEMPEST_OPTS: "--serial" + {{ tempest_venv_bin | dirname }}/run_tempest.sh --no-virtual-env --serial designate_tempest_plugin.tests.scenario.v2.test_zones vars_files: + - playbooks/test-vars.yml - test-vars.yml diff --git a/tests/test-install-designate.yml b/tests/test-install-designate.yml index a437386..9cb6e41 100644 --- a/tests/test-install-designate.yml +++ b/tests/test-install-designate.yml @@ -22,7 +22,7 @@ rabbitmq_vhost: name: "{{ designate_rabbitmq_vhost }}" state: "present" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['rabbitmq_all'][0]]['ansible_host'] }}" when: inventory_hostname == groups['designate_all'][0] - name: Ensure rabbitmq user rabbitmq_user: @@ -33,7 +33,7 @@ read_priv: ".*" write_priv: ".*" state: "present" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['rabbitmq_all'][0]]['ansible_host'] }}" when: inventory_hostname == groups['designate_all'][0] - name: Create DB for service mysql_db: @@ -42,7 +42,7 @@ login_host: "localhost" name: "{{ designate_galera_database }}" state: "present" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" when: inventory_hostname == groups['designate_all'][0] - name: Grant access to the DB for the service mysql_user: @@ -57,7 +57,7 @@ with_items: - "localhost" - "%" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" when: inventory_hostname == groups['designate_all'][0] - name: Create pool_manager DB for service mysql_db: @@ -66,7 +66,7 @@ login_host: "{{ designate_galera_address }}" name: "{{ designate_pool_manager_galera_database }}" state: "present" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" - name: Grant access to the pool_manager DB for the service mysql_user: login_user: "{{ galera_root_user }}" @@ -80,7 +80,7 @@ with_items: - "localhost" - "%" - delegate_to: "10.100.100.101" + delegate_to: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" - name: Install bind9 apt: package: bind9 @@ -94,10 +94,12 @@ name: bind9 state: restarted roles: - - role: "{{ rolename | basename }}" + - role: "os_designate" vars_files: + - playbooks/test-vars.yml - test-vars.yml + - name: Import pools hosts: designate_all[0] user: root @@ -112,4 +114,5 @@ . /root/openrc {{ designate_bin }}/designate-manage pool update --file /etc/designate/pools.yaml vars_files: + - playbooks/test-vars.yml - test-vars.yml diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml deleted file mode 100644 index d8e0235..0000000 --- a/tests/test-install-infra.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -# 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: 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 9645f73..0000000 --- a/tests/test-install-keystone.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# 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: 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.100.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.100.101" - when: inventory_hostname == groups['keystone_all'][0] - - name: Create DB for service - mysql_db: - login_user: "{{ galera_root_user }}" - login_password: "{{ galera_root_password }}" - login_host: "localhost" - name: "{{ keystone_galera_database }}" - state: "present" - delegate_to: "10.100.100.101" - when: inventory_hostname == groups['keystone_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: "localhost" - name: "{{ keystone_galera_user }}" - password: "{{ keystone_container_mysql_password }}" - host: "{{ item }}" - state: "present" - priv: "{{ keystone_galera_database }}.*:ALL" - with_items: - - "localhost" - - "%" - delegate_to: "10.100.100.101" - when: inventory_hostname == groups['keystone_all'][0] - roles: - - role: os_keystone - vars_files: - - test-vars.yml diff --git a/tests/test-install-tempest.yml b/tests/test-install-tempest.yml index 9c11951..4bf446c 100644 --- a/tests/test-install-tempest.yml +++ b/tests/test-install-tempest.yml @@ -20,4 +20,5 @@ roles: - role: "os_tempest" vars_files: + - playbooks/test-vars.yml - test-vars.yml diff --git a/tests/test-prepare-containers.yml b/tests/test-prepare-containers.yml deleted file mode 100644 index 932d681..0000000 --- a/tests/test-prepare-containers.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -# 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: Playbook for creating containers - hosts: all_containers - connection: local - gather_facts: false - roles: - - role: "lxc_container_create" - lxc_container_release: trusty - 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 diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml deleted file mode 100644 index 74ab045..0000000 --- a/tests/test-prepare-host.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -# 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: Playbook for configuring the LXC host - hosts: localhost - connection: local - become: yes - pre_tasks: - # 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['127.0.0.1']['lxc_container_ssh_key'] }}" - manage_dir: no - - set_fact: - lxc_container_ssh_key: "{{ hostvars['127.0.0.1']['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 - roles: - - role: "lxc_hosts" - lxc_net_address: 10.100.100.1 - lxc_net_dhcp_range: 10.100.100.200,10.100.100.250 - lxc_net_bridge: lxcbr0 - lxc_kernel_options: - - { key: 'fs.inotify.max_user_instances', value: 1024 } - - role: "openstack_openrc" - post_tasks: - # In the gate these packages get installed into .tox/functional, which is - # not where we need them to be. If we can figure out how to override this - # we can revert to using the pip module instead. - - name: Install pip packages - command: /usr/local/bin/pip install {{ item }} - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - with_items: - - lxc-python2 - - python-openstackclient - - python-designateclient - vars_files: - - test-vars.yml diff --git a/tests/test-vars.yml b/tests/test-vars.yml index fa2706d..14f8b76 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -13,55 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -debug: True -external_lb_vip_address: 10.100.100.102 -internal_lb_vip_address: 10.100.100.102 -galera_client_drop_config_file: false -galera_root_user: root -galera_root_password: "secrete" -rabbitmq_servers: 10.100.100.101 -rabbitmq_use_ssl: False -rabbitmq_port: 5672 -memcached_servers: 127.0.0.1 -memcached_encryption_key: "secrete" -keystone_venv_tag: "testing" -keystone_developer_mode: true -keystone_git_install_branch: master -keystone_requirements_git_install_branch: master -keystone_service_password: "secrete" -keystone_galera_address: 10.100.100.101 -keystone_galera_database: keystone -keystone_galera_user: keystone -keystone_container_mysql_password: "SuperSecrete" -keystone_auth_admin_token: "SuperSecreteTestToken" -keystone_admin_user_name: admin -keystone_admin_tenant_name: admin -keystone_auth_admin_password: "SuperSecretePassword" -keystone_service_adminuri_insecure: false -keystone_service_internaluri_insecure: false -keystone_service_internaluri: "http://{{ internal_lb_vip_address }}:5000" -keystone_service_internalurl: "{{ keystone_service_internaluri }}/v3" -keystone_service_adminuri: "http://{{ internal_lb_vip_address }}:35357" -keystone_service_adminurl: "{{ keystone_service_adminuri }}/v3" -keystone_rabbitmq_vhost: /keystone -keystone_rabbitmq_userid: keystone -keystone_rabbitmq_password: "secrete" -keystone_rabbitmq_use_ssl: false -keystone_rabbitmq_port: 5672 -keystone_rabbitmq_servers: 10.100.100.101 -openrc_os_auth_url: "{{ keystone_service_internalurl }}" -openrc_os_password: "{{ keystone_auth_admin_password }}" -openrc_os_domain_name: "Default" + designate_venv_tag: "testing" designate_developer_mode: true designate_git_install_branch: master designate_requirements_git_install_branch: master designate_service_password: "secrete" -designate_galera_address: 10.100.100.101 +designate_galera_address: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" designate_galera_database: designate designate_galera_user: designate designate_container_mysql_password: "SuperSecrete" -designate_pool_manager_galera_address: 10.100.100.101 +designate_pool_manager_galera_address: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}" designate_pool_manager_galera_database: designate_pool_manager designate_pool_manager_galera_user: designate_pool_manager designate_pool_manager_container_mysql_password: "SuperSecrete" @@ -72,23 +34,12 @@ designate_rabbitmq_servers: "{{ rabbitmq_servers }}" designate_rabbitmq_use_ssl: "{{ rabbitmq_use_ssl }}" designate_rabbitmq_port: "{{ rabbitmq_port }}" designate_bin: "/openstack/venvs/designate-{{ designate_venv_tag }}/bin" -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-designate-functional.yml tempest_venv_bin: "/opt/tempest_{{ tempest_venv_tag }}/bin" tempest_log_dir: "/var/log/" -tempest_main_group: designate_all -tempest_service_available_aodh: False -tempest_service_available_ceilometer: False -tempest_service_available_cinder: False -tempest_service_available_glance: False -tempest_service_available_heat: False -tempest_service_available_horizon: False -tempest_service_available_neutron: False -tempest_service_available_nova: False -tempest_service_available_swift: False tempest_plugins: - name: designate-tempest-plugin repo: https://git.openstack.org/openstack/designate-tempest-plugin diff --git a/tests/test.yml b/tests/test.yml index 330aa33..e84bf1d 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -13,20 +13,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Prepare the user ssh keys -- include: test-prepare-keys.yml - -# Prepare the host -- include: test-prepare-host.yml +# Setup the host +- include: playbooks/test-setup-host.yml # Prepare the containers -- include: test-prepare-containers.yml +- include: playbooks/test-prepare-containers.yml # Install RabbitMQ/MariaDB -- include: test-install-infra.yml +- include: playbooks/test-install-infra.yml # Install Keystone -- include: test-install-keystone.yml +- include: playbooks/test-install-keystone.yml # Install Designate - include: test-install-designate.yml diff --git a/tox.ini b/tox.ini index 55a5f11..2bb6734 100644 --- a/tox.ini +++ b/tox.ini @@ -94,7 +94,7 @@ commands = [testenv:ansible] deps = {[testenv]deps} - ansible==1.9.4 + ansible==2.1.1 ansible-lint>=2.7.0,<3.0.0 setenv = {[testenv]setenv} @@ -113,6 +113,7 @@ setenv = # This is required as the default is '/etc/ansible/roles' or a path # specified in ansible.cfg ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/.. + ANSIBLE_TRANSPORT = "ssh" commands = rm -rf {homedir}/.ansible/plugins git clone https://git.openstack.org/openstack/openstack-ansible-plugins \ @@ -121,6 +122,11 @@ commands = ansible-galaxy install \ --role-file={toxinidir}/tests/ansible-role-requirements.yml \ --force + rm -rf {homedir}/.ansible/roles/os_designate + bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/os_designate" + rm -rf {toxinidir}/tests/playbooks + git clone https://git.openstack.org/openstack/openstack-ansible-tests \ + {toxinidir}/tests/playbooks [testenv:ansible-syntax] @@ -133,7 +139,6 @@ commands = ansible-playbook -i {toxinidir}/tests/inventory \ --syntax-check \ --list-tasks \ - -e "rolename={toxinidir}" \ {toxinidir}/tests/test.yml @@ -145,6 +150,22 @@ 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 'mkdir -p {toxinidir}/logs' + 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: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,7 +176,7 @@ 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 = @@ -163,13 +184,9 @@ setenv = commands = {[testenv:ansible]commands} ansible-playbook -i {toxinidir}/tests/inventory \ - -e "rolename={toxinidir}" \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv - bash -c 'mkdir -p {toxinidir}/logs' - 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]