Reorganize test playbooks
The following changes have been made to reorganize the structure of this role's test playbooks, bringing them into line with other OpenStack-Ansible roles: - move each playbook to an individual file - rename playbooks descriptively - define hosts and groups directly in the inventory file - include group vars required by containers - store extra variables in a single shared test-vars file - remove use of the openstack_hosts role - include callback plugin for human readable logging of test tasks Change-Id: I4829e368003f58685cb96b7ee743255d00542187
This commit is contained in:
parent
a94f88dddc
commit
a37735c3fb
@ -14,10 +14,6 @@
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create
|
||||
scm: git
|
||||
version: master
|
||||
- name: openstack_hosts
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
|
||||
scm: git
|
||||
version: master
|
||||
- name: galera_client
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-galera_client
|
||||
scm: git
|
||||
|
26
tests/group_vars/all_containers.yml
Normal file
26
tests/group_vars/all_containers.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
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 }}"
|
@ -1,6 +1,13 @@
|
||||
[all]
|
||||
localhost ansible_connection=local ansible_become=True
|
||||
container1 ansible_ssh_host=10.100.100.101 ansible_host=10.100.100.101 ansible_become=True ansible_user=root
|
||||
container2 ansible_ssh_host=10.100.100.102 ansible_host=10.100.100.102 ansible_become=True ansible_user=root
|
||||
container3 ansible_ssh_host=10.100.100.103 ansible_host=10.100.100.103 ansible_become=True ansible_user=root
|
||||
|
||||
[hosts]
|
||||
localhost ansible_ssh_host=127.0.0.1
|
||||
[galera_test_hosts]
|
||||
container1
|
||||
container2
|
||||
container3
|
||||
|
||||
[all_containers:children]
|
||||
galera_test_hosts
|
||||
|
@ -13,44 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Playbook for testing
|
||||
- name: Run functional tests
|
||||
hosts: galera_test_hosts
|
||||
user: root
|
||||
gather_facts: true
|
||||
vars:
|
||||
galera_root_password: secrete
|
||||
galera_root_user: root
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running Function Tests ====="
|
||||
tasks:
|
||||
- name: Create DB for service on 10.100.100.101
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.101"
|
||||
name: "OSA-test"
|
||||
state: "present"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.101'
|
||||
- name: Grant access to the DB on 10.100.100.102
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.102"
|
||||
name: "osa-tester"
|
||||
password: "tester-secrete"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "OSA-test.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
tags:
|
||||
- neutron-db-setup
|
||||
when: ansible_ssh_host == '10.100.100.102'
|
||||
- name: check cluster state incoming addresses
|
||||
- name: Check cluster incoming addresses
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
@ -58,7 +26,7 @@
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_incoming_addresses
|
||||
- name: check cluster state
|
||||
- name: Check cluster local state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
@ -66,7 +34,7 @@
|
||||
--silent \
|
||||
--skip-column-names
|
||||
register: wsrep_local_state_comment
|
||||
- name: check cluster state
|
||||
- name: Check cluster evs state
|
||||
command: |
|
||||
mysql -h {{ ansible_ssh_host }} \
|
||||
-p"{{ galera_root_password }}" \
|
||||
@ -82,3 +50,27 @@
|
||||
- "'10.100.100.101' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.102' in wsrep_incoming_addresses.stdout"
|
||||
- "'10.100.100.103' in wsrep_incoming_addresses.stdout"
|
||||
- name: Create DB for service on 10.100.100.101
|
||||
mysql_db:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.101"
|
||||
name: "OSA-test"
|
||||
state: "present"
|
||||
when: ansible_ssh_host == '10.100.100.101'
|
||||
- name: Grant access to the DB on 10.100.100.102
|
||||
mysql_user:
|
||||
login_user: "{{ galera_root_user }}"
|
||||
login_password: "{{ galera_root_password }}"
|
||||
login_host: "10.100.100.102"
|
||||
name: "osa-tester"
|
||||
password: "tester-secrete"
|
||||
host: "{{ item }}"
|
||||
state: "present"
|
||||
priv: "OSA-test.*:ALL"
|
||||
with_items:
|
||||
- "localhost"
|
||||
- "%"
|
||||
when: ansible_ssh_host == '10.100.100.102'
|
||||
vars_files:
|
||||
- test-vars.yml
|
27
tests/test-install-galera-server.yml
Normal file
27
tests/test-install-galera-server.yml
Normal file
@ -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.
|
||||
|
||||
- name: Install galera server
|
||||
hosts: galera_test_hosts
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "{{ message }}"
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
vars_files:
|
||||
- test-vars.yml
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Playbook for pre-role upgrade testing
|
||||
- name: Create test containers
|
||||
hosts: all_containers
|
||||
connection: local
|
||||
gather_facts: false
|
||||
@ -51,4 +51,4 @@
|
||||
port: "{{ ansible_ssh_port | default('22') }}"
|
||||
host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
|
||||
search_regex: OpenSSH
|
||||
delay: 1
|
||||
delay: 1
|
@ -13,37 +13,19 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Playbook for pre-role testing 1of3
|
||||
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 users key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: key_get
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ key_get.stdout }}"
|
||||
|
||||
- name: Playbook for pre-role testing 2of3
|
||||
- name: Perform basic LXC host setup
|
||||
hosts: localhost
|
||||
connection: local
|
||||
pre_tasks:
|
||||
- name: First ensure apt cache is always refreshed
|
||||
- name: Ensure apt cache is always refreshed
|
||||
apt:
|
||||
update_cache: yes
|
||||
- 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
|
||||
@ -74,36 +56,3 @@
|
||||
name: "trusty.tgz"
|
||||
sha256sum: "56c6a6e132ea7d10be2f3e8104f47136ccf408b30e362133f0dc4a0a9adb4d0c"
|
||||
chroot_path: trusty/rootfs-amd64
|
||||
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: "all,all_containers,galera_test_hosts"
|
||||
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.255.0"
|
||||
type: "veth"
|
||||
physical_host: localhost
|
||||
container_name: "{{ item.name }}"
|
||||
with_items:
|
||||
- { name: "container1", service: "service1", address: "10.100.100.101" }
|
||||
- { name: "container2", service: "service2", address: "10.100.100.102" }
|
||||
- { name: "container3", service: "service3", address: "10.100.100.103" }
|
||||
|
||||
- name: Playbook for pre-role testing 2of2
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: "openstack_hosts"
|
33
tests/test-prepare-keys.yml
Normal file
33
tests/test-prepare-keys.yml
Normal file
@ -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.
|
||||
|
||||
# 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: localhost
|
||||
become_user: "{{ ansible_ssh_user }}"
|
||||
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 users key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: key_get
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ key_get.stdout }}"
|
10
tests/test-vars.yml
Normal file
10
tests/test-vars.yml
Normal file
@ -0,0 +1,10 @@
|
||||
galera_cluster_members: "{{ groups['galera_test_hosts'] }}"
|
||||
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 }}"
|
100
tests/test.yml
100
tests/test.yml
@ -13,92 +13,44 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Run basic prep
|
||||
- include: test-prep.yml
|
||||
# Prepare the user ssh keys
|
||||
- include: test-prepare-keys.yml
|
||||
|
||||
# Prepare the host
|
||||
- include: test-prepare-host.yml
|
||||
|
||||
# Run container clean up and build
|
||||
- include: test-container-create.yml
|
||||
- include: test-prepare-containers.yml
|
||||
|
||||
# Deploy the environment
|
||||
- name: Playbook for role testing
|
||||
hosts: galera_test_hosts
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
# Install Galera server
|
||||
- include: test-install-galera-server.yml
|
||||
vars:
|
||||
galera_cluster_members: "{{ groups['galera_test_hosts'] }}"
|
||||
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" }
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
message: "===== Running Current MariaDB Deployment ====="
|
||||
|
||||
# Run playbook test
|
||||
- include: test-functional.yml
|
||||
# Run functional tests
|
||||
- include: test-galera-server-functional.yml
|
||||
|
||||
############################# UPGRADE TESTING #############################
|
||||
|
||||
# Run container clean up and build
|
||||
- include: test-container-create.yml
|
||||
- include: test-prepare-containers.yml
|
||||
|
||||
# Deploy the environment running a 5.5 to 10.0 upgrade
|
||||
- name: Playbook for role upgrade testing
|
||||
hosts: galera_test_hosts
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
# Install previous version of Galera server
|
||||
- include: test-install-galera-server.yml
|
||||
vars:
|
||||
galera_cluster_members: "{{ groups['galera_test_hosts'] }}"
|
||||
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" }
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running MariaDB 5.5 Deployment for Upgrade ====="
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_mariadb_server_package: "mariadb-galera-server-5.5"
|
||||
galera_apt_repo_url: "https://mirror.rackspace.com/mariadb/repo/5.5/ubuntu"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
message: "===== Running MariaDB 5.5 Deployment for Upgrade ====="
|
||||
galera_mariadb_server_package: "mariadb-galera-server-5.5"
|
||||
galera_apt_repo_url: "https://mirror.rackspace.com/mariadb/repo/5.5/ubuntu"
|
||||
|
||||
# Run initial playbook test
|
||||
- include: test-functional.yml
|
||||
# Run initial functional tests
|
||||
- include: test-galera-server-functional.yml
|
||||
|
||||
# Deploy the environment running a 5.5 to 10.0 upgrade
|
||||
- name: Playbook for role upgrade testing
|
||||
hosts: galera_test_hosts
|
||||
serial: 1
|
||||
user: root
|
||||
gather_facts: true
|
||||
# Perform upgrade of Galera server
|
||||
- include: test-install-galera-server.yml
|
||||
vars:
|
||||
galera_cluster_members: "{{ groups['galera_test_hosts'] }}"
|
||||
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" }
|
||||
pre_tasks:
|
||||
- debug:
|
||||
msg: "===== Running MariaDB 5.5 to current Upgrade ====="
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
galera_server_id: "{{ inventory_hostname | string_2_int }}"
|
||||
galera_ignore_cluster_state: true
|
||||
galera_upgrade: true
|
||||
message: "===== Running MariaDB 5.5 to Current Upgrade ====="
|
||||
galera_ignore_cluster_state: true
|
||||
galera_upgrade: true
|
||||
|
||||
# Run final playbook test
|
||||
- include: test-functional.yml
|
||||
# Run final functional tests
|
||||
- include: test-galera-server-functional.yml
|
||||
|
5
tox.ini
5
tox.ini
@ -15,6 +15,7 @@ whitelist_externals =
|
||||
bash
|
||||
git
|
||||
rm
|
||||
wget
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
ANSIBLE_HOST_KEY_CHECKING = False
|
||||
@ -108,12 +109,16 @@ commands =
|
||||
rm -rf {homedir}/.ansible
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-plugins \
|
||||
{homedir}/.ansible/plugins
|
||||
# This plugin makes the ansible-playbook output easier to read
|
||||
wget -O {homedir}/.ansible/plugins/callback/human_log.py \
|
||||
https://gist.githubusercontent.com/cliffano/9868180/raw/f360f306b3c6d689734a6aa8773a00edf16a0054/human_log.py
|
||||
ansible-galaxy install \
|
||||
--role-file={toxinidir}/tests/ansible-role-requirements.yml \
|
||||
--ignore-errors \
|
||||
--force
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
-e "rolename={toxinidir}" \
|
||||
-vv \
|
||||
{toxinidir}/tests/test.yml
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user