Switch to 2-node configuration for IR plugin testing

Change-Id: Ifeed49ee6a5f57fc2ebf69adbae16894ad3c69a2
This commit is contained in:
Federico Ressi 2020-04-08 15:21:32 +02:00
parent c9716ccac2
commit ac7a4a6d61
19 changed files with 229 additions and 137 deletions

View File

@ -1,39 +1,8 @@
---
- hosts: all
vars:
zuul_output_dir: '{{ ansible_user_dir }}/zuul-output'
test_collect_dir: '{{ zuul_output_dir }}/logs'
- hosts: primary
roles:
- role: tobiko-ensure-python3
- name: "run Tox InfraRed plugin"
role: tox
vars:
tox_envlist: infrared
tox_extra_args: '-- --collect-dir {{ test_collect_dir | quote }}'
tasks:
- name: "list collected files"
command: >
ls '{{ test_collect_dir }}'
register: list_test_result_files
- name: "set collected files fact"
set_fact:
collected_files: '{{ list_test_result_files.stdout_lines }}'
- name: "show collected files"
debug: var=collected_files
- name: "check collected files"
assert:
that:
- item in collected_files
loop:
- tobiko.log
- tobiko.conf
- test_results.html
- test_results.subunit
- test_results.xml
- role: tobiko-inventory
- role: tox
- role: tobiko-check-collected-files

View File

@ -8,7 +8,7 @@ VAGRANTFILE_API_VERSION = "2"
CPUS = 4
# Customize the amount of memory on the VM
MEMORY = ENV.fetch("VM_SIZE", "512").to_i
MEMORY = ENV.fetch("VM_SIZE", "1024").to_i
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.

View File

@ -1,25 +1,5 @@
---
- hosts: all
tasks:
- name: "show platform id variables"
debug:
msg:
ansible_architecture: '{{ ansible_architecture }}'
ansible_distribution: '{{ ansible_distribution }}'
ansible_distribution_major_version: '{{ ansible_distribution_major_version }}'
ansible_os_family: '{{ ansible_os_family }}'
- name: "include platform variables"
include_vars: "{{ item }}"
with_first_found:
- "provision-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
- "provision-{{ ansible_distribution }}.{{ ansible_architecture }}.yaml"
- "provision-{{ ansible_distribution }}.yaml"
- "provision-{{ ansible_os_family }}.yaml"
register: include_platform_vars
- hosts: primary
tasks:
- name: "copy /etc/resolv.conf"
@ -66,11 +46,6 @@
- ''
- '.pub'
- name: "make Ansible inventory file with vagrant nodes"
template:
src: 'ansible_hosts.j2'
dest: '/vagrant/ansible_hosts'
- hosts: all
tasks:
@ -92,12 +67,12 @@
- hosts: primary
tasks:
- name: "check ICMP connectivity"
shell: |
set -xe
ping -c 1 '{{ item.1.ip }}'
ping -c 1 '{{ item.1.hostname }}'
changed_when: false
register: check_icmp_connectivity
loop: '{{ vagrant_nodes | dictsort }}'
@ -107,5 +82,29 @@
ssh '{{ item.1.ip }}' hostname
ssh '{{ item.1.hostname }}' hostname
ssh '{{ item.0 }}' hostname
changed_when: false
register: check_ssh_connectivity
loop: '{{ vagrant_nodes | dictsort }}'
- name: "set test_inventory_hostvars_yaml fact"
set_fact:
test_inventory_hostvars_yaml: |
---
{% for name, node in (vagrant_nodes | dictsort) %}
{{ name }}:
ansible_host: {{ node.hostname }}
{% endfor %}
- name: "set test_inventory_hostvars fact"
set_fact:
test_inventory_hostvars:
'{{ test_inventory_hostvars_yaml | from_yaml }}'
- debug: var=test_inventory_hostvars
- hosts: primary
roles:
- role: tobiko-inventory
vars:
test_inventory_file: /vagrant/ansible_hosts

View File

@ -1,9 +0,0 @@
[vagrant]
{% for node in (vagrant_nodes | dictsort) %}
{{ node.0 }}
{% endfor %}
[vagrant:vars]
ansible_python_interpreter = {{ ansible_python_interpreter }}

View File

@ -11,4 +11,3 @@
{% for node in (vagrant_nodes | dictsort) %}
{{ node.1.ip }} {{ node.1.hostname }}
{% endfor %}

View File

@ -1,18 +1,16 @@
---
- hosts: primary
vars:
test_src_dir: /vagrant
test_collect_dir: '{{ test_src_dir }}/test_results'
roles:
- tobiko-ensure-tox
- tobiko-ensure-git
- tobiko-ensure-rsync
tasks:
- name: "remove collected files"
- name: "remove '{{ test_collect_dir }}' dir"
file:
path: '{{ test_collect_dir }}'
state: absent
@ -35,25 +33,10 @@
when: run_tox is failed
failed_when: yes
- name: "list collected files"
command: >
ls '{{ test_collect_dir }}'
register: list_test_result_files
- name: "set collected files fact"
set_fact:
collected_files: '{{ list_test_result_files.stdout_lines }}'
- name: "show collected files"
debug: var=collected_files
- name: "check collected files"
assert:
that:
- item in collected_files
loop:
- tobiko.log
- tobiko.conf
- test_results.html
- test_results.subunit
- test_results.xml
- hosts: primary
vars:
test_src_dir: /vagrant
test_collect_dir: '{{ test_src_dir }}/test_results'
roles:
- tobiko-check-collected-files

View File

@ -1,3 +0,0 @@
---
ansible_python_interpreter: /usr/libexec/platform-python

View File

@ -1,3 +0,0 @@
---
ansible_python_interpreter: /usr/bin/python3

View File

@ -0,0 +1,4 @@
---
dependencies:
- role: tobiko-common

View File

@ -0,0 +1,40 @@
---
- name: "find for collected files in '{{ test_collect_dir }}'"
find:
paths:
- "{{ test_collect_dir }}"
patterns:
- "tobiko.conf"
- "tobiko.log"
- "{{ test_report_name }}*.log"
- "{{ test_report_name }}*.subunit"
- "{{ test_report_name }}*.html"
- "{{ test_report_name }}*.xml"
register: find_collected_files
- name: "set collected_files fact"
set_fact:
collected_files: >
{{ find_collected_files.files |
map(attribute='path') |
map('basename') |
list }}
- block:
- name: "check collected files"
assert:
that:
- item in collected_files
loop:
- tobiko.log
- tobiko.conf
- '{{ test_report_name }}.html'
- '{{ test_report_name }}.subunit'
- '{{ test_report_name }}.xml'
rescue:
- debug: var=collected_files
failed_when: yes

View File

@ -0,0 +1,5 @@
---
test_inventory_user: '{{ ansible_user }}'
test_inventory_hostvars: {}
test_inventory_file: '{{ test_src_dir | realpath }}/ansible_hosts'

View File

@ -0,0 +1,4 @@
---
dependencies:
- role: tobiko-common

View File

@ -0,0 +1,65 @@
---
- name: "read platform vars from file"
include_vars: "{{ item }}"
with_first_found:
- "test-inventory-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
- "test-inventory-{{ ansible_distribution }}.{{ ansible_architecture }}.yaml"
- "test-inventory-{{ ansible_distribution }}.yaml"
- "test-inventory-{{ ansible_os_family }}.yaml"
register: include_platform_vars
- debug: var=test_inventory_python_interpreter
- when: test_inventory_user is not defined
block:
- name: "get remote username"
command: whoami
changed_when: false
become: false
register: get_inventory_user
- name: "set test_inventory_user fact"
set_fact:
test_inventory_user: "{{ get_inventory_user.stdout_lines | first }}"
- debug: var=test_inventory_user
- name: "get default test_inventory_hostvars entries from hostvars"
set_fact:
test_inventory_hostvars: >
{{ {hostname: {varname: value} } |
combine(test_inventory_hostvars) }}
vars:
hostname: '{{ item.0 }}'
varname: '{{ item.1 }}'
value: '{{ hostvars[hostname][varname] }}'
loop: "{{ hostvars.keys() | product(['ansible_host']) | list }}"
loop_control:
label: '{{ hostname }}.{{ varname }} = {{ value }}'
when:
- hostvars[hostname][varname] is defined
- test_inventory_hostvars[hostname][varname] is not defined
- debug: var=test_inventory_hostvars
- name: "writes inventory file to: '{{ test_inventory_file }}'"
template:
src: 'test_inventory.j2'
dest: '{{ test_inventory_file }}'
- name: "read inventory file from: '{{ test_inventory_file }}'"
command: "cat '{{ test_inventory_file }}'"
changed_when: false
register: read_test_inventory_file
- name: "show inventory file: '{{ test_inventory_file }}'"
debug: var=read_test_inventory_file.stdout_lines

View File

@ -0,0 +1,8 @@
[all]
{% for name, vars in (test_inventory_hostvars | dictsort) %}
{{ name }} ansible_host={{ vars.ansible_host }}
{% endfor %}
[all:vars]
ansible_python_interpreter = {{ test_inventory_python_interpreter }}
ansible_user = {{ test_inventory_user }}

View File

@ -0,0 +1,3 @@
---
test_inventory_python_interpreter: /usr/bin/python

View File

@ -0,0 +1,3 @@
---
test_inventory_python_interpreter: /usr/libexec/platform-python

View File

@ -0,0 +1,3 @@
---
test_inventory_python_interpreter: /usr/bin/python3

View File

@ -8,12 +8,20 @@
description: |
Run test cases using tobiko infrared plugin
run: playbooks/infrared/run.yaml
vars:
test_collect_dir: '{{ zuul_output_dir }}/logs'
test_inventory_file: '{{ zuul_work_dir }}/ansible_hosts'
tox_envlist: infrared
tox_extra_args: -- --host secondary --collect-dir {{ test_collect_dir | quote }}
tox_environ:
ANSIBLE_INVENTORY: '{{ test_inventory_file }}'
zuul_output_dir: '{{ ansible_user_dir }}/zuul-output'
- job:
name: tobiko-tox-infrared-centos-7
parent: tobiko-tox-infrared
nodeset: centos-7
nodeset: centos-7-2-node
voting: false
description: |
Run py36 test cases using tobiko infrared plugin on CentOS 7
@ -22,7 +30,7 @@
- job:
name: tobiko-tox-infrared-centos-8
parent: tobiko-tox-infrared
nodeset: centos-8
nodeset: centos-8-2-node
voting: false
description: |
Run py36 test cases using tobiko infrared plugin on CentOS 8
@ -30,7 +38,7 @@
- job:
name: tobiko-tox-infrared-ubuntu-bionic
parent: tobiko-tox-infrared
nodeset: ubuntu-bionic
nodeset: ubuntu-bionic-2-node
voting: false
description: |
Run py36 test cases using tobiko infrared plugin on Ubuntu Bionic

View File

@ -1,33 +1,47 @@
- nodeset:
name: openstack-three-node-centos-7
nodes:
- name: controller
label: centos-7
- name: compute1
label: centos-7
- name: compute2
label: centos-7
groups:
# Node where tests are executed and test results collected
- name: tempest
nodes:
- controller
# Nodes running the compute service
- name: compute
nodes:
- compute1
- compute2
# Nodes that are not the controller
- name: subnode
nodes:
- compute1
- compute2
# Switch node for multinode networking setup
- name: switch
nodes:
- controller
# Peer nodes for multinode networking setup
- name: peers
nodes:
- compute1
- compute2
name: centos-8-2-node
nodes:
- name: primary
label: centos-8
- name: secondary
label: centos-8
groups:
- name: subnodes
nodes:
- secondary
- nodeset:
name: openstack-three-node-centos-7
nodes:
- name: controller
label: centos-7
- name: compute1
label: centos-7
- name: compute2
label: centos-7
groups:
# Node where tests are executed and test results collected
- name: tempest
nodes:
- controller
# Nodes running the compute service
- name: compute
nodes:
- compute1
- compute2
# Nodes that are not the controller
- name: subnode
nodes:
- compute1
- compute2
# Switch node for multinode networking setup
- name: switch
nodes:
- controller
# Peer nodes for multinode networking setup
- name: peers
nodes:
- compute1
- compute2