Use Cirros for CI testing

Utilizing Cirros for the guest operating system when performing a
basic test saves a significant amount of time and resources for the
test as it prevents the creation of a disk image.

Additionally, the native support for configuration drives allows
the amount of time we're waiting on the guest OS to be greatly
reduced.

Change-Id: I5a4c497d3502c975db060d3ee08ea2056399a062
Closes-Bug: #1460052
This commit is contained in:
Julia Kreger 2015-05-31 12:54:56 -04:00
parent 1dbbec87b4
commit 6b9581d908
7 changed files with 29 additions and 6 deletions

View File

@ -8,6 +8,11 @@ mysql_password:
# If testing is true, then the environment is setup for using libvirt
# virtual machines for the hardware instead of real hardware.
# testing: true
#
# Normally this user should be ubuntu, however if cirros is used,
# a user may wish to define a specific user for testing VM
# connectivity during atest sequence
testing_user: ubuntu
http_boot_folder: /httpboot
ssh_public_key_path: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub"
latest_os_ironic_url: https://raw.githubusercontent.com/juliakreger/ansible-modules-extras/features/new-openstack/cloud/os_ironic.py

View File

@ -16,6 +16,10 @@
wait_for: state=started port=22 host={{ item.split(',')[11] }} timeout=900
with_lines:
- cat {{ baremetal_csv_file }}
- name: "Pausing for 4 seconds to allow testvm to become fully operational and to avoid any potential sshd startup race."
# NOTE(TheJulia): AFAIK sshd opens it's socket and then loads/generates
# keys, which can become visible as a race, hence the four second pause.
pause: seconds=4
- name: "Adding testvms to Ansible Inventory"
add_host: name="{{ item.split(',')[11] }}:22" groups=testvm
with_lines:

View File

@ -13,7 +13,10 @@
# limitations under the License.
---
- name: "Execute ping step to verify connectivity and login to the host. If this fails, the configdrive may not have loaded."
ping:
# NOTE(TheJulia): This is executed as a raw command to validate the remote
# hostname. This is because cirros lacks sftp support.
raw: hostname
register: instance_hostname
- name: 'Error if hostname is set to "ubuntu"'
# TODO: Presently this step is unable to cycle through each host and verify
# it's hostname is properly set. Perhaps if there was some way to extract
@ -22,5 +25,7 @@
#
# TODO: As time goes on, we may move to leveraging inventory information
# which will allow this role to do validation of the remote node.
fail: msg='If this fails, the configdrive may not have been used as the hostname was set to the default "ubuntu"'
when: ansible_hostname == "ubuntu"
# NOTE(TheJulia): If we go down the path of additional validation, we need
# to keep things like Cirros in mind.
fail: msg='If this fails, the configdrive may not have been used as the hostname was set to the default.'
when: '"ubuntu" in instance_hostname.stdout or "cirros" in instance_hostname.stdout'

View File

@ -54,3 +54,5 @@ deploy_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_
deploy_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:8080/coreos_production_pxe_image-oem.cpio.gz"
deploy_image_filename: "trusty-server-cloudimg-amd64.img"
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
# Use cirros instead of building an image via diskimage-builder
use_cirros: false

View File

@ -235,6 +235,13 @@
- name: "Download CoreOS image"
get_url: url=http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz dest={{ http_boot_folder }}/coreos_production_pxe_image-oem.cpio.gz
when: test_core_os_image_present.stat.exists == false
- name: "Download cirros to use for deployment if requested"
get_url: url=http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img dest="{{deploy_image}}"
# TODO(TheJulia): We may want to revise any boolean operators to
# comparison statements like the one below when they are able to be
# set via the command line as there are oddities across ansible
# versions with auto-translation of true/false values.
when: use_cirros == true or "'true' in use_cirros"
- name: "Test if Ubuntu 14.04 server cloud amd64 is present"
stat: path={{ deploy_image }}
register: test_os_image_present

View File

@ -45,8 +45,8 @@
- hosts: testvm
name: "Tests connectivity to the VM"
sudo: no
gather_facts: yes
remote_user: ubuntu
gather_facts: no
remote_user: "{{testing_user}}"
roles:
- role: bifrost-test-vm
- hosts: localhost

View File

@ -20,7 +20,7 @@ ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml --syntax-check -
set +e
# Execute test playbook
ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml
ansible-playbook -vvvv -i inventory/localhost test-bifrost.yaml -e use_cirros=true -e testing_user=cirros
EXITCODE=$?
if [ $EXITCODE != 0 ]; then
echo "*************************"