Add convergence test for test repo.

For test repo we should build out keystone + infra services, as they are
the most commonly used roles/tasks.

We still need to add some funcitonal tests but this should give a good
base. The test repo will consume it's own test plays in the same way as
other repositories would. We use a "git clone ." to avoid a situation
where we clone the old repo containing the errors we are trying to fix.

Additional fix, we don't need a "when" clause on the rabbit/db creation
tasks - since these are already delegated and a "run_once" will suffice.
This fix is required for the tests to pass.

Change-Id: I482500872f9e29a71e1576f67a0ad390be2a3ece
This commit is contained in:
Andy McCrae 2016-08-25 13:29:49 +01:00 committed by Andy McCrae
parent a9f1ea9a6f
commit c01f249046
11 changed files with 152 additions and 24 deletions

View File

@ -20,7 +20,7 @@
name: "{{ db_name }}"
state: "present"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
run_once: True
- name: Grant access to the DB for the service
mysql_user:
login_user: "root"
@ -35,4 +35,4 @@
- "localhost"
- "%"
delegate_to: "{{ groups['galera_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
run_once: True

View File

@ -17,7 +17,7 @@
name: "{{ vhost_name }}"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
run_once: True
- name: Ensure rabbitmq user
rabbitmq_user:
user: "{{ user_name }}"
@ -28,5 +28,4 @@
write_priv: ".*"
state: "present"
delegate_to: "{{ groups['rabbitmq_all'][0] }}"
when: inventory_hostname == "{{ host_name }}"
run_once: True

View File

@ -1 +0,0 @@
localhost

0
run_tests.sh Normal file → Executable file
View File

View File

@ -0,0 +1,40 @@
- name: apt_package_pinning
src: https://git.openstack.org/openstack/openstack-ansible-apt_package_pinning
scm: git
version: master
- name: pip_install
src: https://git.openstack.org/openstack/openstack-ansible-pip_install
scm: git
version: master
- name: memcached_server
src: https://git.openstack.org/openstack/openstack-ansible-memcached_server
scm: git
version: master
- name: lxc_hosts
src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts
scm: git
version: master
- name: lxc_container_create
src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create
scm: git
version: master
- name: galera_client
src: https://git.openstack.org/openstack/openstack-ansible-galera_client
scm: git
version: master
- name: galera_server
src: https://git.openstack.org/openstack/openstack-ansible-galera_server
scm: git
version: master
- name: rabbitmq_server
src: https://git.openstack.org/openstack/openstack-ansible-rabbitmq_server
scm: git
version: master
- name: memcached_server
src: https://git.openstack.org/openstack/openstack-ansible-memcached_server
scm: git
version: master
- name: os_keystone
src: https://git.openstack.org/openstack/openstack-ansible-os_keystone
scm: git
version: master

View 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: "br-mgmt"
interface: "eth1"
netmask: "255.255.255.0"
type: "veth"
physical_host: localhost
properties:
service_name: "{{ inventory_hostname }}"

View File

@ -1,5 +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.
@ -13,11 +13,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Include here all the functional tests for the test repo.
- name: Playbook for deploying nova
hosts: localhost
user: root
gather_facts: true
tasks:
- debug:
msg: "Functional tests to be included here"
bridges:
- "br-mgmt"

30
tests/inventory Normal file
View File

@ -0,0 +1,30 @@
[all]
localhost ansible_connection=local ansible_become=True
infra1 ansible_ssh_host=10.100.101.2 ansible_host=10.100.101.2 ansible_become=True ansible_user=root
keystone1 ansible_ssh_host=10.100.101.3 ansible_host=10.100.101.3 ansible_become=True ansible_user=root
keystone2 ansible_ssh_host=10.100.101.4 ansible_host=10.100.101.4 ansible_become=True ansible_user=root
[all_containers]
infra1
keystone1
keystone2
[rabbitmq_all]
infra1
[galera_all]
infra1
[memcached_all]
infra1
[service_all:children]
rabbitmq_all
galera_all
memcached_all
[keystone_all]
keystone1
keystone2
[utility_all]

29
tests/test.yml Normal file
View File

@ -0,0 +1,29 @@
---
# 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.
# Prepare the user ssh keys
- include: playbooks/test-prepare-keys.yml
# Prepare the host
- include: playbooks/test-prepare-host.yml
# Prepare the containers
- include: playbooks/test-prepare-containers.yml
# Install RabbitMQ/MariaDB/Memcached
- include: playbooks/test-install-infra.yml
# Install Keystone
- include: playbooks/test-install-keystone.yml

View File

@ -0,0 +1,10 @@
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.101.1
netmask 255.255.255.0
offload-sg off

19
tox.ini
View File

@ -117,9 +117,11 @@ commands =
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
ansible-galaxy install \
--role-file={toxinidir}/tests/ansible-role-requirements.yml \
--force
rm -rf {toxinidir}/tests/playbooks
git clone . {toxinidir}/tests/playbooks
[testenv:ansible-syntax]
@ -129,10 +131,10 @@ setenv =
{[testenv:ansible]setenv}
commands =
{[testenv:ansible]commands}
ansible-playbook -i {toxinidir}/inventory \
ansible-playbook -i {toxinidir}/tests/inventory \
--syntax-check \
--list-tasks \
{toxinidir}/test.yml
{toxinidir}/tests/test.yml
[testenv:ansible-lint]
@ -155,10 +157,9 @@ setenv =
{[testenv:ansible]setenv}
commands =
{[testenv:ansible]commands}
#NOTE(evrardjp): currently there is no functional test of the
#test repository. Only syntax checks are done.
#ansible-playbook -i {toxinidir}/inventory \
# {toxinidir}/test.yml -vvvv
ansible-playbook -i {toxinidir}/tests/inventory \
-e "network_conf_filename=tests/tests-network-interfaces.cfg.j2" \
{toxinidir}/tests/test.yml -vvvv
[testenv:linters]