From da91e5b0153f14521d562134e12b826148298b5f Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Thu, 18 Aug 2016 11:21:32 -0400 Subject: [PATCH] Functional testing for os_rally role The role gate will now actually run simple Rally scenario against Keystone to validate that the install and configuration is correct. Change-Id: Ie5d52636700e8c276b0e793e815ae513d25415bb --- tasks/database-setup.yml | 2 +- tests/files/scenario.json | 12 ++++++ tests/group_vars/all_containers.yml | 27 ++++++++++++ tests/inventory | 24 ++++++++++- tests/test-functional-rally.yml | 35 ++++++++++++++++ tests/test-install-infra.yml | 2 +- tests/test-install-keystone.yml | 20 +-------- tests/test-install-rally.yml | 27 +----------- tests/test-prepare-host.yml | 30 +++---------- tests/test-vars.yml | 65 +++++++++++++++++++++++++++++ tests/test.yml | 5 ++- 11 files changed, 177 insertions(+), 72 deletions(-) create mode 100644 tests/files/scenario.json create mode 100644 tests/group_vars/all_containers.yml create mode 100644 tests/test-functional-rally.yml create mode 100644 tests/test-vars.yml diff --git a/tasks/database-setup.yml b/tasks/database-setup.yml index a02fd7b..37e0819 100644 --- a/tasks/database-setup.yml +++ b/tasks/database-setup.yml @@ -23,6 +23,6 @@ - name: Create/upgrade Rally DB schema command: "{{ rally_bin }}/rally-manage db create" when: - - rally_deployment_list_result.stderr | search("Table 'rally.deployments' doesn't exist") + - rally_deployment_list_result.stdout | search("Table 'rally.deployments' doesn't exist") tags: - rally-db-setup \ No newline at end of file diff --git a/tests/files/scenario.json b/tests/files/scenario.json new file mode 100644 index 0000000..8111980 --- /dev/null +++ b/tests/files/scenario.json @@ -0,0 +1,12 @@ +{ + "KeystoneBasic.create_delete_user": [ + { + "args": {}, + "runner": { + "type": "constant", + "times": 10, + "concurrency": 3 + } + } + ] +} \ No newline at end of file diff --git a/tests/group_vars/all_containers.yml b/tests/group_vars/all_containers.yml new file mode 100644 index 0000000..4cc9794 --- /dev/null +++ b/tests/group_vars/all_containers.yml @@ -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 77754d5..714078b 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,24 @@ [all] -localhost ansible_connection=local ansible_become=True \ No newline at end of file +localhost ansible_connection=local ansible_become=True +infra1 ansible_ssh_host=10.100.100.2 ansible_host=10.100.100.2 ansible_become=True ansible_user=root +openstack1 ansible_ssh_host=10.100.100.3 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] +infra1 + +[rally_all] +openstack1 \ No newline at end of file diff --git a/tests/test-functional-rally.yml b/tests/test-functional-rally.yml new file mode 100644 index 0000000..54a1b96 --- /dev/null +++ b/tests/test-functional-rally.yml @@ -0,0 +1,35 @@ +--- +# Copyright 2016, Comcast Corporation +# +# 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: Run a Rally scenario to ensure proper install/config + hosts: rally_all + user: root + gather_facts: false + tasks: + - name: Create the deployment + shell: | + . /root/openrc + . {{ rally_bin }}/activate + {{ rally_bin }}/rally deployment create --fromenv --name=existing + - name: Copy the rally scenario + copy: + src: "{{ playbook_dir }}/files/scenario.json" + dest: "/var/tmp/scenario.json" + - name: Run the rally scenario + shell: | + . {{ rally_bin }}/activate + {{ rally_bin }}/rally task start /var/tmp/scenario.json + vars_files: + - test-vars.yml \ No newline at end of file diff --git a/tests/test-install-infra.yml b/tests/test-install-infra.yml index b59a635..b0b145e 100644 --- a/tests/test-install-infra.yml +++ b/tests/test-install-infra.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Deploy infra services - hosts: galera_all + hosts: service_all user: root gather_facts: true roles: diff --git a/tests/test-install-keystone.yml b/tests/test-install-keystone.yml index e1738cf..c353636 100644 --- a/tests/test-install-keystone.yml +++ b/tests/test-install-keystone.yml @@ -61,21 +61,5 @@ when: inventory_hostname == groups['keystone_all'][0] roles: - role: os_keystone - vars: - external_lb_vip_address: 10.100.100.2 - internal_lb_vip_address: 10.100.100.2 - keystone_galera_address: 10.100.100.2 - keystone_galera_database: keystone - keystone_venv_tag: testing - keystone_developer_mode: true - 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 \ No newline at end of file + vars_files: + - test-vars.yml diff --git a/tests/test-install-rally.yml b/tests/test-install-rally.yml index c16cc6d..410266c 100644 --- a/tests/test-install-rally.yml +++ b/tests/test-install-rally.yml @@ -44,28 +44,5 @@ when: inventory_hostname == groups['rally_all'][0] roles: - role: "{{ rolename | basename }}" - # post_tasks: - # - include: test-rally-functional.yml - vars: - rally_galera_address: 10.100.100.2 - rally_galera_database: rally - rally_galera_password: "SuperSecrete" - galera_client_drop_config_file: false - galera_root_password: "secrete" - rally_venv_tag: "testing" - rally_developer_mode: true - external_lb_vip_address: 10.100.100.2 - internal_lb_vip_address: 10.100.100.2 - 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_service_region: RegionOne - openrc_os_auth_url: "{{ keystone_service_internalurl }}" - openrc_os_password: "{{ keystone_auth_admin_password }}" - openrc_os_domain_name: Default \ No newline at end of file + vars_files: + - test-vars.yml diff --git a/tests/test-prepare-host.yml b/tests/test-prepare-host.yml index f880ff9..0531d4b 100644 --- a/tests/test-prepare-host.yml +++ b/tests/test-prepare-host.yml @@ -18,6 +18,11 @@ 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 @@ -41,28 +46,3 @@ lxc_net_bridge: lxcbr0 lxc_kernel_options: - { key: 'fs.inotify.max_user_instances', value: 1024 } - 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,keystone_all" } - - { name: "openstack1", service: "openstack1", address: "10.100.100.3", groups: "all,all_containers,rally_all" } diff --git a/tests/test-vars.yml b/tests/test-vars.yml new file mode 100644 index 0000000..242ef25 --- /dev/null +++ b/tests/test-vars.yml @@ -0,0 +1,65 @@ +--- +# Copyright 2016, Comcast Corporation +# +# 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. + +internal_lb_vip_address: 10.100.100.2 +external_lb_vip_address: 10.100.100.2 + +galera_client_drop_config_file: False +galera_root_password: "secrete" +galera_root_user: "root" + +keystone_galera_address: "{{ internal_lb_vip_address }}" +keystone_galera_database: keystone +keystone_venv_tag: "testing" +keystone_developer_mode: True +keystone_git_install_branch: master +keystone_requirements_git_install_branch: master +keystone_admin_user_name: admin +keystone_admin_tenant_name: admin +keystone_auth_admin_token: "SuperSecreteTestToken" +keystone_auth_admin_password: "SuperSecretePassword" +keystone_service_password: "secrete" +keystone_rabbitmq_password: "secrete" +keystone_container_mysql_password: "SuperSecrete" +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_service_region: RegionOne +keystone_rabbitmq_port: 5672 +keystone_rabbitmq_userid: keystone +keystone_rabbitmq_vhost: /keystone +keystone_rabbitmq_servers: "{{ internal_lb_vip_address }}" +keystone_rabbitmq_use_ssl: False + +rabbitmq_servers: "{{ internal_lb_vip_address }}" +rabbitmq_use_ssl: False +rabbitmq_port: 5672 + +memcached_servers: 127.0.0.1 +memcached_encryption_key: "secrete" + +openrc_os_password: "{{ keystone_auth_admin_password }}" +openrc_os_domain_name: "Default" +openrc_os_auth_url: "http://{{ hostvars[groups['keystone_all'][0]]['ansible_ssh_host'] }}:5000/v3" + +rally_galera_address: "{{ internal_lb_vip_address }}" +rally_galera_database: rally +rally_galera_password: "SuperSecrete" +rally_venv_tag: "testing" +rally_developer_mode: True +rally_bin: "/openstack/venvs/rally-{{ rally_venv_tag }}/bin" diff --git a/tests/test.yml b/tests/test.yml index cdd9fd5..059a212 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -29,4 +29,7 @@ - include: test-install-keystone.yml # Install Rally -- include: test-install-rally.yml \ No newline at end of file +- include: test-install-rally.yml + +# Functional testing of Rally Install +- include: test-functional-rally.yml \ No newline at end of file