Test container creation based on IP address
This test executes an LXC container listing from the LXC host, then verifies that the container is present by name and IP address. The test will work whether there is one or more IP addresses in each containers created. This patch also includes the following in order to unblock testing for this role: - A forced apt-get update - A base other-requirements.txt file to ensure that the OpenStack-CI fallback requirements aren't used, which conflict with LXC and cause the instance to hang. Change-Id: I2619b1090300a161c108fcc3f65059e8d50c851e
This commit is contained in:
parent
1bb3ea3bfd
commit
23830066ad
16
other-requirements.txt
Normal file
16
other-requirements.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# This file facilitates OpenStack-CI package installation
|
||||
# before the execution of any tests.
|
||||
#
|
||||
# See the following for details:
|
||||
# - http://docs.openstack.org/infra/bindep/
|
||||
# - https://github.com/openstack-infra/bindep
|
||||
#
|
||||
# Even if the role does not make use of this facility, it
|
||||
# is better to have this file empty, otherwise OpenStack-CI
|
||||
# will fall back to installing its default packages which
|
||||
# will potentially be detrimental to the tests executed.
|
||||
|
||||
# OpenStack-CI's Jenkins needs curl
|
||||
# TODO(odyssey4me) remove this once https://review.openstack.org/288634 has merged
|
||||
# and the disk images are rebuilt and redeployed.
|
||||
curl
|
@ -17,6 +17,9 @@
|
||||
hosts: localhost
|
||||
connection: local
|
||||
pre_tasks:
|
||||
- name: First ensure apt cache is always refreshed
|
||||
apt:
|
||||
update_cache: yes
|
||||
- name: Ensure root ssh key
|
||||
user:
|
||||
name: "{{ ansible_env.USER | default('root') }}"
|
||||
@ -84,17 +87,20 @@
|
||||
lxc_container_backing_store: dir
|
||||
global_environment_variables:
|
||||
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
post_tasks:
|
||||
- name: Confirm containers were created
|
||||
command: lxc-ls -f
|
||||
register: lxc_containers
|
||||
- name: Format output
|
||||
set_fact:
|
||||
_lxc_output: "{{ lxc_containers.stdout.split() | lower }}"
|
||||
- set_fact:
|
||||
lxc_output: "{{ _lxc_output | join(' ') }}"
|
||||
- name: Check role functions
|
||||
|
||||
- name: Test whether the role produced expected results
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: List the running LXC containers present on the host
|
||||
command: lxc-ls -1 --fancy --fancy-format name,ipv4 --running
|
||||
register: lxc_container_list
|
||||
- name: Verify that the expected containers are present with the correct addresses
|
||||
# Example stdout:
|
||||
# NAME IPV4
|
||||
# ---------------------------------------
|
||||
# container1 172.16.12.3, 10.100.100.101
|
||||
# container2 10.100.100.102, 172.16.12.4
|
||||
assert:
|
||||
that:
|
||||
- "'container1 running 10.100.100.101' in lxc_output"
|
||||
- "'container2 running 10.100.100.102' in lxc_output"
|
||||
- lxc_container_list.stdout | search("container1\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.101(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+")
|
||||
- lxc_container_list.stdout | search("container2\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},\s+)*10.100.100.102(,\s+\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})*\s+")
|
||||
|
Loading…
Reference in New Issue
Block a user