From 321cedd50460a2b673ff7d083bd7b0f176d94b5a Mon Sep 17 00:00:00 2001 From: Matt Thompson Date: Thu, 31 Mar 2016 14:30:18 +0100 Subject: [PATCH] Cinder test cleanup This commit does the following: - fully defines the inventory rather than having test-prepare-host.yml add containers to it - updates test-prepare-keys.yml to use localhost instead of 127.0.0.1, uses become_user=jenkins instead of become=false, and removes redundant connection - updates test-prepare-host.yml by changing 127.0.0.1 to localhost, and removes mocking ansible_env - groups vars in defined in each individual file into a single test-vars.yml file Change-Id: I198aab420f5d4c0aa17ef64a05ce300e18d0b108 --- tests/group_vars/all_containers | 27 ++++++++++++++++ tests/inventory | 37 +++++++++++++++++++-- tests/test-cinder-functional.yml | 5 ++- tests/test-install-cinder.yml | 43 ++----------------------- tests/test-install-keystone.yml | 22 ++----------- tests/test-prepare-host.yml | 34 ++------------------ tests/test-prepare-keys.yml | 8 +++-- tests/test-vars.yml | 55 ++++++++++++++++++++++++++++++++ 8 files changed, 129 insertions(+), 102 deletions(-) create mode 100644 tests/group_vars/all_containers create mode 100644 tests/test-vars.yml diff --git a/tests/group_vars/all_containers b/tests/group_vars/all_containers new file mode 100644 index 00000000..4cc97942 --- /dev/null +++ b/tests/group_vars/all_containers @@ -0,0 +1,27 @@ +--- +# 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: "lxcbr0" + interface: "eth1" + netmask: "255.255.252.0" + type: "veth" +physical_host: localhost +properties: + service_name: "{{ inventory_hostname }}" diff --git a/tests/inventory b/tests/inventory index ba414392..47f85d72 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,8 +1,39 @@ [all] localhost ansible_connection=local ansible_become=True +infra1 ansible_host=10.100.100.2 ansible_become=True ansible_user=root +openstack1 ansible_host=10.100.100.3 ansible_become=True ansible_user=root + +[all_containers] +infra1 +openstack1 + +[rabbitmq_all] +infra1 + +[galera_all] +infra1 + +[service_all:children] +rabbitmq_all +galera_all + +[keystone_all] +openstack1 + +[cinder_api] +openstack1 + +[cinder_scheduler] +openstack1 + +[cinder_backup] +openstack1 [cinder_volume] -localhost ansible_connection=local ansible_become=True +localhost -[cinder_all] -localhost ansible_connection=local ansible_become=True +[cinder_all:children] +cinder_api +cinder_scheduler +cinder_backup +cinder_volume diff --git a/tests/test-cinder-functional.yml b/tests/test-cinder-functional.yml index 9e7bb9c0..dc787fbc 100644 --- a/tests/test-cinder-functional.yml +++ b/tests/test-cinder-functional.yml @@ -37,6 +37,5 @@ until: volume_status|success retries: 5 delay: 5 - vars: - cinder_venv_tag: testing - cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" + vars_files: + - test-vars.yml diff --git a/tests/test-install-cinder.yml b/tests/test-install-cinder.yml index 2beb4460..5fa9be1e 100644 --- a/tests/test-install-cinder.yml +++ b/tests/test-install-cinder.yml @@ -37,44 +37,5 @@ when: inventory_hostname == groups['cinder_all'][0] roles: - role: "{{ rolename | basename }}" - vars: - external_lb_vip_address: 10.100.100.3 - internal_lb_vip_address: 10.100.100.3 - cinder_galera_address: 10.100.100.2 - cinder_venv_tag: "testing" - cinder_developer_mode: true - cinder_git_install_branch: stable/mitaka - cinder_requirements_git_install_branch: f8cf7eba898a1424549c730d6692ec4e9573c0ed # HEAD of "master" as of 23.03.2016 - cinder_service_password: "secrete" - cinder_container_mysql_password: "SuperSecrete" - cinder_profiler_hmac_key: "secrete" - cinder_backends: - lvm: - volume_group: cinder-volumes - volume_driver: cinder.volume.drivers.lvm.LVMVolumeDriver - volume_backend_name: LVM_iSCSI - cinder_rabbitmq_password: "secrete" - cinder_rabbitmq_userid: cinder - cinder_rabbitmq_vhost: /cinder - cinder_glance_api_servers: "http://glance_server:9292" - galera_root_password: "secrete" - galera_client_drop_config_file: false - rabbitmq_servers: 10.100.100.2 - rabbitmq_use_ssl: true - rabbitmq_port: 5671 - 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" - openrc_os_auth_url: "{{ keystone_service_internalurl }}" - openrc_os_password: "{{ keystone_auth_admin_password }}" - openrc_os_domain_name: "Default" - memcached_servers: 127.0.0.1 - memcached_encryption_key: "secrete" - debug: true - verbose: true + vars_files: + - test-vars.yml diff --git a/tests/test-install-keystone.yml b/tests/test-install-keystone.yml index 9d5a686d..c3536367 100644 --- a/tests/test-install-keystone.yml +++ b/tests/test-install-keystone.yml @@ -61,23 +61,5 @@ when: inventory_hostname == groups['keystone_all'][0] roles: - role: os_keystone - vars: - external_lb_vip_address: 10.100.100.3 - internal_lb_vip_address: 10.100.100.3 - keystone_galera_address: 10.100.100.2 - keystone_galera_database: keystone - keystone_venv_tag: "testing" - keystone_developer_mode: true - keystone_git_install_branch: stable/mitaka - keystone_requirements_git_install_branch: f8cf7eba898a1424549c730d6692ec4e9573c0ed # HEAD of "master" as of 23.03.2016 - keystone_auth_admin_token: "SuperSecreteTestToken" - keystone_auth_admin_password: "SuperSecretePassword" - keystone_service_password: "secrete" - keystone_rabbitmq_password: "secrete" - keystone_container_mysql_password: "SuperSecrete" - keystone_rabbitmq_port: 5671 - keystone_rabbitmq_userid: keystone - keystone_rabbitmq_vhost: /keystone - keystone_rabbitmq_servers: 10.100.100.2 - keystone_rabbitmq_use_ssl: false - galera_client_drop_config_file: false + vars_files: + - test-vars.yml diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml index a3808e7d..f00d55c4 100644 --- a/tests/test-prepare-host.yml +++ b/tests/test-prepare-host.yml @@ -24,10 +24,10 @@ - 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'] }}" + key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}" manage_dir: no - set_fact: - lxc_container_ssh_key: "{{ hostvars['127.0.0.1']['lxc_container_ssh_key'] }}" + 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 @@ -58,33 +58,3 @@ name: "trusty.tgz" sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c" chroot_path: trusty/rootfs-amd64 - # The $HOME directory is mocked to work with tox - # by defining the 'ansible_env' hash. This should - # NEVER be done outside of testing. - ansible_env: ## NEVER DO THIS OUTSIDE OF TESTING - HOME: "/tmp" - post_tasks: - # Inventory is being pre-loaded using a post tasks instead of through a dynamic - # inventory system. While this is not a usual method for deployment it's being - # done for functional testing. - - name: Create container hosts - add_host: - groups: "{{ item.groups }}" - hostname: "{{ item.name }}" - inventory_hostname: "{{ item.name }}" - ansible_ssh_host: "{{ item.address }}" - ansible_become: true - properties: - service_name: "{{ item.service }}" - container_networks: - management_address: - address: "{{ item.address }}" - bridge: "lxcbr0" - interface: "eth1" - netmask: "255.255.252.0" - type: "veth" - physical_host: localhost - container_name: "{{ item.name }}" - with_items: - - { name: "infra1", service: "infra1", address: "10.100.100.2", groups: "all,all_containers,rabbitmq_all,galera_all,service_all" } - - { name: "openstack1", service: "openstack1", address: "10.100.100.3", groups: "all,all_containers,keystone_all,cinder_api,cinder_scheduler,cinder_backup,cinder_all" } diff --git a/tests/test-prepare-keys.yml b/tests/test-prepare-keys.yml index c09f2f67..d9c96361 100644 --- a/tests/test-prepare-keys.yml +++ b/tests/test-prepare-keys.yml @@ -13,10 +13,12 @@ # 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: Create ssh key pairs for use with containers - hosts: 127.0.0.1 - connection: local - become: false + hosts: localhost + become_user: "{{ ansible_ssh_user }}" pre_tasks: - name: Create ssh key pair for root user: diff --git a/tests/test-vars.yml b/tests/test-vars.yml new file mode 100644 index 00000000..b6e08b2d --- /dev/null +++ b/tests/test-vars.yml @@ -0,0 +1,55 @@ +cinder_backends: + lvm: + volume_group: cinder-volumes + volume_driver: cinder.volume.drivers.lvm.LVMVolumeDriver + volume_backend_name: LVM_iSCSI +cinder_container_mysql_password: "SuperSecrete" +cinder_developer_mode: true +cinder_galera_address: 10.100.100.2 +cinder_git_install_branch: stable/mitaka +cinder_glance_api_servers: "http://glance_server:9292" +cinder_profiler_hmac_key: "secrete" +cinder_rabbitmq_password: "secrete" +cinder_rabbitmq_userid: cinder +cinder_rabbitmq_vhost: /cinder +cinder_requirements_git_install_branch: stable/mitaka +cinder_service_password: "secrete" +cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" +cinder_venv_tag: "testing" +debug: true +external_lb_vip_address: 10.100.100.3 +galera_client_drop_config_file: false +galera_root_password: "secrete" +internal_lb_vip_address: 10.100.100.3 +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.100.2 +keystone_galera_database: keystone +keystone_git_install_branch: stable/mitaka +keystone_rabbitmq_password: "secrete" +keystone_rabbitmq_port: 5671 +keystone_rabbitmq_servers: 10.100.100.2 +keystone_rabbitmq_use_ssl: false +keystone_rabbitmq_userid: keystone +keystone_rabbitmq_vhost: /keystone +keystone_requirements_git_install_branch: stable/mitaka +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_venv_tag: "testing" +memcached_encryption_key: "secrete" +memcached_servers: 127.0.0.1 +openrc_os_auth_url: "{{ keystone_service_internalurl }}" +openrc_os_domain_name: "Default" +openrc_os_password: "{{ keystone_auth_admin_password }}" +rabbitmq_port: 5671 +rabbitmq_servers: 10.100.100.2 +rabbitmq_use_ssl: true +verbose: true