Files
openstack-ansible-os_nova/tests/test-nova-functional.yml
Matt Thompson 39505d2b8e Standardise nova functional tests and add actual tests
This commit breaks out the tests/test.yml file into sub task files and
deploys all the necessary components (keystone, glance, neutron) to
boot nova instances.  The functional test validates a few nova ports
and then proceeds to creating to a glance image and neutron network
bits before spinning up an instance.

Additionally, this change does the following:

- fully defines the inventory rather than having test-prepare-host.yml
  add containers to it
- removes installation of lxc_python2 library, since this is no longer
  necessary
- 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 removing redundant become and
  connection options, changes 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: I80b1923cbf5c4375d2fb71bc71c326d43f1443b4
2016-03-31 14:11:51 +01:00

112 lines
3.8 KiB
YAML

---
# 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.
- name: Playbook for functional testing of nova
hosts: nova_api_os_compute
user: root
gather_facts: false
tasks:
- name: Check the nova-api-os-compute service
uri:
url: "http://localhost:8774"
status_code: 200
register: nova_api_os_compute_status
until: nova_api_os_compute_status | success
retries: 5
delay: 5
- name: Check the nova-api-metadata service
uri:
url: "http://localhost:8775"
status_code: 200
register: nova_api_metadata_status
until: nova_api_metadata_status | success
retries: 5
delay: 5
- name: Check the nova-spicehtml5proxy service
uri:
url: "http://localhost:6082/spice_auto.html"
status_code: 200
register: nova_spice_status
until: nova_spice_status | success
retries: 5
delay: 5
- name: Install testing pip packages
pip:
name: "{{ item }}"
with_items:
- python-glanceclient
- python-neutronclient
- name: Set glance_image_name fact
set_fact:
glance_image_name: "functional-image-{{ 100|random }}"
- name: Set nova_instance_name fact
set_fact:
nova_instance_name: "functional-instance-{{ 100|random }}"
- name: Set neutron_net_name fact
set_fact:
neutron_net_name: "functional-net-{{ 100|random }}"
- name: Set neutron_subnet_name fact
set_fact:
neutron_subnet_name: "functional-subnet-{{ 100|random }}"
- name: Upload the Cirros image
glance:
command: 'image-create'
openrc_path: /root/openrc
image_name: "{{ glance_image_name }}"
image_url: "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz"
image_container_format: bare
image_disk_format: qcow2
image_is_public: True
register: cirros_image_create
until: cirros_image_create | success
retries: 5
delay: 15
# NOTE: We need to ensure the image goes active before we attempt to boot
# from it below
- name: Verify image goes active
shell: |
. /root/openrc
{{ nova_venv_bin }}/glance image-show {{ glance_images[glance_image_name]['id'] }} | grep active
register: image_status
until: image_status|success
retries: 5
delay: 5
- name: Create test network
neutron:
command: create_network
openrc_path: /root/openrc
net_name: "{{ neutron_net_name }}"
- name: Create test subnet
neutron:
command: create_subnet
openrc_path: /root/openrc
net_name: "{{ neutron_net_name }}"
subnet_name: "{{ neutron_subnet_name }}"
cidr: "192.168.74.0/24"
- name: Create nova instance
shell: |
. /root/openrc
{{ nova_venv_bin }}/nova boot --image {{ glance_image_name }} --flavor 1 --nic net-id={{ neutron_networks[neutron_net_name]['id'] }} {{ nova_instance_name }}
- name: Verify nova instance goes active
shell: |
. /root/openrc
{{ nova_venv_bin }}/nova show {{ nova_instance_name }} | grep ACTIVE
register: instance_status
until: instance_status|success
retries: 5
delay: 5
vars_files:
- test-vars.yml