Add minimal functional gate
Change-Id: Ibb758b2e5a7f8bccffe307932aa4f472687f7acb Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
774688ca92
commit
ba854228fa
@ -33,4 +33,5 @@ galaxy_info:
|
||||
- python
|
||||
- development
|
||||
- openstack
|
||||
dependencies: []
|
||||
dependencies:
|
||||
- plugins
|
||||
|
@ -10,7 +10,11 @@
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
|
||||
scm: git
|
||||
version: master
|
||||
- name: lxc_hosts
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts
|
||||
- name: nspawn_hosts
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-nspawn_hosts
|
||||
scm: git
|
||||
version: master
|
||||
- name: plugins
|
||||
src: https://git.openstack.org/openstack/openstack-ansible-plugins
|
||||
scm: git
|
||||
version: master
|
||||
|
@ -13,13 +13,19 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Gather nspawn container host facts
|
||||
hosts: "localhost"
|
||||
gather_facts: true
|
||||
container_networks:
|
||||
management_address:
|
||||
address: "{{ ansible_host | default('localhost') }}"
|
||||
bridge: "br-mgmt"
|
||||
interface: "eth1"
|
||||
netmask: "255.255.252.0"
|
||||
type: "veth"
|
||||
static_routes:
|
||||
- cidr: 10.100.100.0/24
|
||||
gateway: 10.100.100.1
|
||||
|
||||
- name: Create container(s)
|
||||
hosts: "{{ container_group|default('all_containers') }}"
|
||||
gather_facts: false
|
||||
user: root
|
||||
roles:
|
||||
- role: "nspawn_container_create"
|
||||
bridges:
|
||||
- name: "br-mgmt"
|
||||
ip_addr: "172.29.236.100"
|
||||
netmask: "255.255.252.0"
|
||||
- name: "br-vlan"
|
@ -14,20 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
container_name: "{{ inventory_hostname }}"
|
||||
|
||||
container_networks:
|
||||
management_address:
|
||||
address: "{{ ansible_host }}"
|
||||
bridge: "br-mgmt"
|
||||
interface: "eth1"
|
||||
netmask: "255.255.252.0"
|
||||
type: "veth"
|
||||
static_routes:
|
||||
- cidr: 10.100.100.0/24
|
||||
gateway: 10.100.100.1
|
||||
container_tech: nspawn
|
||||
|
||||
properties:
|
||||
service_name: "{{ inventory_hostname }}"
|
||||
|
||||
global_environment_variables:
|
||||
foo: "bar"
|
||||
deployment_environment_variables:
|
||||
foo: bar
|
||||
|
@ -17,3 +17,5 @@ bridges:
|
||||
- "br-mgmt"
|
||||
|
||||
ansible_python_interpreter: "/usr/bin/python2"
|
||||
|
||||
physical_host: localhost
|
||||
|
48
tests/templates/test-networks.service.j2
Normal file
48
tests/templates/test-networks.service.j2
Normal file
@ -0,0 +1,48 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=test networks service
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=root
|
||||
RemainAfterExit=yes
|
||||
|
||||
{% set seen_start_interfaces = [] %}
|
||||
{% for item in bridges %}
|
||||
{% if item is mapping %}
|
||||
{% if item.name not in seen_start_interfaces %}
|
||||
{% set _ = seen_start_interfaces.append(item.name) %}
|
||||
|
||||
# Interface [{{ item.name }}]
|
||||
ExecStart=-/sbin/ip link add dev "{{ item.name }}" type bridge
|
||||
ExecStart=-/sbin/ip link set dev "{{ item.name }}" up
|
||||
{% if item.address is defined and item.netmask is defined %}
|
||||
ExecStart=-/sbin/ip address add "{{ item.address }}/{{ item.netmask }}" dev "{{ item.bridge }}"
|
||||
{% endif %}
|
||||
{% if item.veth_peer is defined %}
|
||||
ExecStart=-/sbin/ip link add "{{ item.name }}-veth" type veth peer name "{{ item.veth_peer }}"
|
||||
ExecStart=-/sbin/ip link set "{{ item.name }}-veth" up
|
||||
ExecStart=-/sbin/ip link set "{{ item.veth_peer }}-veth" up
|
||||
ExecStart=-/sbin/ip link set dev "{{ item.name }}-veth" master "{{ item.name }}"
|
||||
ExecStop=-/sbin/ip link delete dev "{{ item.veth_peer }}-veth"
|
||||
ExecStop=-/sbin/ip link delete dev "{{ item.name }}-veth"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
ExecStop=-/sbin/ip link delete dev "{{ item }}"
|
||||
{% else %}
|
||||
{% if item not in seen_start_interfaces %}
|
||||
{% set _ = seen_start_interfaces.append(item) %}
|
||||
|
||||
# Interface [{{ item }}]
|
||||
ExecStart=-/sbin/ip link add dev "{{ item }}" type bridge
|
||||
ExecStart=-/sbin/ip link set dev "{{ item }}" up
|
||||
ExecStop=-/sbin/ip link delete dev "{{ item }}"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
122
tests/test.yml
122
tests/test.yml
@ -13,11 +13,121 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Prepare the user ssh keys
|
||||
- include: common/test-prepare-keys.yml
|
||||
- name: Playbook for role testing
|
||||
hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
pre_tasks:
|
||||
- name: Show host facts
|
||||
debug:
|
||||
var: hostvars
|
||||
|
||||
# Prepare the host
|
||||
- include: common/test-prepare-host.yml
|
||||
- name: Create test network service
|
||||
template:
|
||||
src: "templates/test-networks.service.j2"
|
||||
dest: "/etc/systemd/system/test-networks.service"
|
||||
|
||||
# Test container creation
|
||||
- include: test-containers-create.yml
|
||||
- name: Enable test network service
|
||||
systemd:
|
||||
name: "test-networks.service"
|
||||
state: "restarted"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure root ssh key
|
||||
user:
|
||||
name: "{{ ansible_env.USER | default('root') }}"
|
||||
generate_ssh_key: "yes"
|
||||
ssh_key_bits: 2048
|
||||
ssh_key_file: ".ssh/id_rsa"
|
||||
|
||||
- name: Get root ssh key
|
||||
slurp:
|
||||
src: '~/.ssh/id_rsa.pub'
|
||||
register: _root_ssh_key
|
||||
|
||||
- name: Prepare container ssh key fact
|
||||
set_fact:
|
||||
nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
|
||||
|
||||
# This is a very dirty hack due to images.linuxcontainers.org
|
||||
# constantly failing to resolve in openstack-infra.
|
||||
- name: Implement hard-coded hosts entries for consistently failing name
|
||||
lineinfile:
|
||||
path: "/etc/hosts"
|
||||
line: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "91.189.91.21 images.linuxcontainers.org us.images.linuxcontainers.org"
|
||||
- "91.189.88.37 images.linuxcontainers.org uk.images.linuxcontainers.org"
|
||||
|
||||
# This is a temporary hack to override the nspawn image source to
|
||||
# the reverse proxy if the test is run in OpenStack-Infra.
|
||||
- name: Check if this is an OpenStack-CI nodepool instance
|
||||
stat:
|
||||
path: /etc/nodepool/provider
|
||||
register: nodepool
|
||||
|
||||
- name: Discover the nspawn_image_cache_server value when in nodepool
|
||||
shell: |
|
||||
source /etc/ci/mirror_info.sh
|
||||
echo "${NODEPOOL_MIRROR_HOST}:8080/images.linuxcontainers"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: nspawn_reverse_proxy
|
||||
when:
|
||||
- nodepool.stat.exists | bool
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: Set a fact to override nspawn_image_cache_server value when in nodepool
|
||||
set_fact:
|
||||
nspawn_image_cache_server_mirrors: ["http://{{ nspawn_reverse_proxy.stdout.strip('/') }}"]
|
||||
when:
|
||||
- nodepool.stat.exists | bool
|
||||
|
||||
roles:
|
||||
- role: "nspawn_hosts"
|
||||
|
||||
- name: Create container(s)
|
||||
hosts: "all_containers"
|
||||
gather_facts: false
|
||||
become: true
|
||||
roles:
|
||||
- role: "nspawn_container_create"
|
||||
post_tasks:
|
||||
- name: Test connectivity to external address (1)
|
||||
command: ping -i 5 -c 6 8.8.8.8
|
||||
register: ping_external_address
|
||||
failed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: Stop container
|
||||
command: "machinectl poweroff container3"
|
||||
register: container_stop
|
||||
changed_when: container_stop.rc == 0
|
||||
failed_when: not container_stop.rc in [0, 2]
|
||||
until: container_stop.rc in [0, 2]
|
||||
retries: 3
|
||||
delay: 2
|
||||
|
||||
- name: Start container
|
||||
command: "machinectl start container3"
|
||||
register: container_start
|
||||
changed_when: container_start.rc == 0
|
||||
until: container_start | success
|
||||
retries: 3
|
||||
delay: 2
|
||||
|
||||
- name: Test connectivity to external address (2)
|
||||
command: ping -i 5 -c 6 8.8.8.8
|
||||
register: ping_external_address
|
||||
failed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: Verify connectivity to external address
|
||||
assert:
|
||||
that:
|
||||
- ping_external_address.rc == 0
|
||||
|
29
zuul.d/jobs.yaml
Normal file
29
zuul.d/jobs.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
# Copyright 2017, 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.
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-nspawn-ubuntu-xenial
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: ubuntu-xenial
|
||||
|
||||
- job:
|
||||
name: openstack-ansible-nspawn-centos-7
|
||||
parent: openstack-ansible-functional
|
||||
nodeset: centos-7
|
||||
|
||||
# - job:
|
||||
# name: openstack-ansible-nspawn-opensuse-423
|
||||
# parent: openstack-ansible-functional
|
||||
# nodeset: opensuse-423
|
30
zuul.d/project.yaml
Normal file
30
zuul.d/project.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2017, 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.
|
||||
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- openstack-ansible-linters
|
||||
- openstack-ansible-nspawn-ubuntu-xenial
|
||||
- openstack-ansible-nspawn-centos-7
|
||||
# - openstack-ansible-nspawn-opensuse-423
|
||||
experimental:
|
||||
jobs:
|
||||
- openstack-ansible-integrated-deploy-aio
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-ansible-linters
|
||||
- openstack-ansible-nspawn-ubuntu-xenial
|
||||
- openstack-ansible-nspawn-centos-7
|
||||
# - openstack-ansible-nspawn-opensuse-423
|
Loading…
Reference in New Issue
Block a user