Add playbook and role to run tobiko
In Tobiko project we want to run job based on TripleO. To achieve that we need to use some Tobiko specific playbooks which are added by this patch. This role will be used in Tobiko's TripleO based job which is proposed in https://review.opendev.org/#/c/651828/ Change-Id: Ieffc859a92c8ef99dbc6d2c725d3c4bed8012b7a
This commit is contained in:

committed by
Marios Andreou

parent
dc0ba8b9af
commit
0046662a0b
13
playbooks/tobiko.yml
Normal file
13
playbooks/tobiko.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Prepare and run Tobiko
|
||||
hosts: undercloud
|
||||
vars:
|
||||
debug: true
|
||||
tobiko_config: true
|
||||
tobiko_run: true
|
||||
tempest_cloud_name: overcloud
|
||||
tags:
|
||||
- overcloud-validate
|
||||
- standalone
|
||||
roles:
|
||||
- {role: validate-tobiko}
|
88
roles/validate-tobiko/README.md
Normal file
88
roles/validate-tobiko/README.md
Normal file
@@ -0,0 +1,88 @@
|
||||
validate-tobiko
|
||||
================
|
||||
|
||||
Ansible role for running [Tobiko](https://opendev.org/x/tobiko/)
|
||||
tests on undercloud or overcloud.
|
||||
|
||||
This role should be run on deployed undercloud or overcloud. It may also be run
|
||||
e.g. after update or upgrade of cloud.
|
||||
This role supports run on standalone deployment too.
|
||||
Example of tests which are run by this role are:
|
||||
|
||||
* tobiko.tests.scenario.neutron.test_floating_ip - to test connectivity to VM with
|
||||
floating IP,
|
||||
* tobiko.tests.scenario.nova.test_server.ServerStackResourcesTest.test_server - to
|
||||
test server actions.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
* `tobiko_config`: false/true - to prepare tobiko's config or not (default: yes)
|
||||
* `tobiko_run`: false/true - to run tobiko tests or not (default: false)
|
||||
* `tobiko_envlist`: <string> - The name of tox envlist to be run (default:
|
||||
scenario)
|
||||
* `tobiko_extra_args`: <string> - Extra arguments to be passed to tobiko tox
|
||||
command (default: "")
|
||||
* `tobiko_config_dir`: <string> - directory where tobiko config files will be
|
||||
stored (default: "{{ working_dir }}/.tobiko")
|
||||
* `tobiko_config_file`: <string> - name of tobiko config file (default:
|
||||
"tobiko.conf")
|
||||
* `tobiko_log_dir`: <string> - directory where tobiko log files will be
|
||||
stored (default: "{{ working_dir }}/.tobiko")
|
||||
* `tobiko_log_file`: <string> - name of tobiko log file (default: "tobiko.log")
|
||||
* `tobiko_key_file_name`: <string> - path to ssh key used by tobiko in tests
|
||||
(default: "~/.ssh/id_rsa")
|
||||
* `tobiko_floating_ip_network`: <string> - name of floating IP network used by
|
||||
tobiko in tests (default: "public")
|
||||
* `public_network_type`: <string> - type of public neutron network used for floating
|
||||
IPs during tobiko testing (default: flat)
|
||||
* `public_network_pool_start`: <string> - neutron public network allocation pool start
|
||||
(default: {{ floating_ip_cidr|nthhost(100) }})
|
||||
* `public_network_pool_end`: <string> - neutron public network allocation pool end
|
||||
(default: {{ floating_ip_cidr|nthhost(120) }})
|
||||
* `public_network_gateway`: <string> - gateway IP for neutron public network, when
|
||||
not set, neutron will choose it automatically
|
||||
(default: {{ floating_ip_cidr|nthhost(1) }})
|
||||
* `public_physical_network`: <string> - name of physical network used in neutron for public
|
||||
network (default: datacentre)
|
||||
* `public_segmentation_id`: <string> - segmentation_id for neutron public network
|
||||
(default: '')
|
||||
* `floating_ip_cidr`: <string> - the network CIDR to be used for a public floating IP
|
||||
network during testing (default: {{ undercloud_network_cidr }})
|
||||
|
||||
|
||||
Using validate-tobiko role with tripleo-quickstart
|
||||
---------------------------------------------------
|
||||
|
||||
To run tobiko with tripleo-quickstart, run the following command:
|
||||
|
||||
$WORKSPACE/tripleo-quickstart
|
||||
|
||||
bash quickstart.sh \
|
||||
--tags all \
|
||||
--no-clone \
|
||||
--release master \
|
||||
--extra-vars run_tobiko=True \
|
||||
$VIRTHOST
|
||||
|
||||
Note: by using --extra-vars, we can change the validate-tobiko role variables.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
---
|
||||
- name: Run tobiko
|
||||
hosts: undercloud
|
||||
gather_facts: false
|
||||
roles:
|
||||
- validate-tobiko
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Apache 2.0
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
RDO-CI Team
|
23
roles/validate-tobiko/defaults/main.yml
Normal file
23
roles/validate-tobiko/defaults/main.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
tobiko_config: true
|
||||
tobiko_run: true
|
||||
|
||||
tobiko_envlist: "scenario"
|
||||
tobiko_extra_args: ""
|
||||
tobiko_config_dir: "{{ working_dir }}/.tobiko"
|
||||
tobiko_config_file: "tobiko.conf"
|
||||
|
||||
tobiko_log_dir: "{{ working_dir }}/.tobiko"
|
||||
tobiko_log_file_base: "tobiko"
|
||||
tobiko_key_file_name: "~/.ssh/id_rsa"
|
||||
|
||||
tobiko_floating_ip_network: "public"
|
||||
public_network_type: "flat"
|
||||
public_physical_network: datacentre
|
||||
public_segmentation_id: ''
|
||||
floating_ip_cidr: "{{ undercloud_network_cidr }}"
|
||||
public_network_pool_start: "{{ floating_ip_cidr|nthhost(100) }}"
|
||||
public_network_pool_end: "{{ floating_ip_cidr|nthhost(120) }}"
|
||||
public_network_gateway: "{{ floating_ip_cidr|nthhost(1) }}"
|
||||
|
||||
python_package_prefix: "python"
|
3
roles/validate-tobiko/meta/main.yml
Normal file
3
roles/validate-tobiko/meta/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
dependencies:
|
||||
- extras-common
|
34
roles/validate-tobiko/tasks/main.yml
Normal file
34
roles/validate-tobiko/tasks/main.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
- name: gather facts used by role
|
||||
setup:
|
||||
gather_subset: "!min,python,processor"
|
||||
when: >
|
||||
ansible_python is not defined or
|
||||
ansible_processor_vcpus is not defined
|
||||
|
||||
- name: set python_cmd
|
||||
set_fact:
|
||||
python_cmd: "python{{ ansible_python.version.major }}"
|
||||
cacheable: true
|
||||
when: python_cmd is not defined
|
||||
|
||||
- name: change python_package_prefix for python > 2
|
||||
set_fact:
|
||||
python_package_prefix: "python{{ ansible_python.version.major }}"
|
||||
cacheable: true
|
||||
when: ansible_python.version.major > 2
|
||||
|
||||
- include: prepare-tobiko.yml
|
||||
when: tobiko_config|bool
|
||||
tags:
|
||||
- prepare-tobiko
|
||||
|
||||
- include: run-tobiko.yml
|
||||
when: tobiko_run|bool
|
||||
tags:
|
||||
- tobiko-run
|
||||
|
||||
- include: tobiko-results.yml
|
||||
when: tobiko_run|bool
|
||||
tags:
|
||||
- tobiko-results
|
69
roles/validate-tobiko/tasks/prepare-tobiko.yml
Normal file
69
roles/validate-tobiko/tasks/prepare-tobiko.yml
Normal file
@@ -0,0 +1,69 @@
|
||||
---
|
||||
- name: Install packages to generate subunit results
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- "{{ python_package_prefix }}-os-testr"
|
||||
- "{{ python_package_prefix }}-subunit"
|
||||
- subunit-filters
|
||||
state: present
|
||||
|
||||
- name: Install packages required for create venv
|
||||
become: true
|
||||
package:
|
||||
state: present
|
||||
name:
|
||||
- gcc
|
||||
- libffi-devel
|
||||
- openssl-devel
|
||||
|
||||
- name: Install virtualenv
|
||||
become: true
|
||||
package:
|
||||
state: present
|
||||
name: "{{ python_package_prefix }}-virtualenv"
|
||||
|
||||
- name: Install pip
|
||||
become: true
|
||||
package:
|
||||
state: present
|
||||
name: "{{ python_package_prefix }}-pip"
|
||||
|
||||
- name: Copy tobiko to undercloud node
|
||||
synchronize:
|
||||
src: "{{ ansible_user_dir }}/src/opendev.org/x/tobiko"
|
||||
dest: "{{ working_dir }}"
|
||||
use_ssh_args: true
|
||||
recursive: true
|
||||
|
||||
- name: Get number of existing tobiko log files
|
||||
shell: >
|
||||
number_of_files=$(ls {{ tobiko_log_dir }} | grep -E "{{ tobiko_log_file_base }}-[0-9]+.log$" -c);
|
||||
echo $(( $number_of_files + 1 ));
|
||||
register: current_tobiko_log_file_number
|
||||
|
||||
- name: Set tobiko_file_name
|
||||
set_fact:
|
||||
tobiko_log_file: "{{ tobiko_log_file_base }}-{{ current_tobiko_log_file_number.stdout }}.log"
|
||||
|
||||
- name: Ensure tobiko config dir exists
|
||||
file:
|
||||
path: "{{ tobiko_config_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Create tobiko config file
|
||||
template:
|
||||
src: "tobiko.conf.j2"
|
||||
dest: "{{ tobiko_config_dir }}/{{ tobiko_config_file }}"
|
||||
mode: 0755
|
||||
|
||||
- name: Create tobiko network config script
|
||||
template:
|
||||
src: "configure_public_network.sh.j2"
|
||||
dest: "{{ tobiko_config_dir }}/configure_public_network.sh"
|
||||
mode: 0755
|
||||
|
||||
- name: Ensure floating IP network exists
|
||||
shell: >
|
||||
bash {{ tobiko_config_dir }}/configure_public_network.sh
|
12
roles/validate-tobiko/tasks/run-tobiko.yml
Normal file
12
roles/validate-tobiko/tasks/run-tobiko.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: Execute Tobiko
|
||||
shell: >
|
||||
set -o pipefail &&
|
||||
tools/ci/tox -e {{ tobiko_envlist }} {{ tobiko_extra_args }} 2>&1 {{ timestamper_cmd }} > {{ tobiko_log_dir }}/{{ tobiko_log_file }};
|
||||
args:
|
||||
chdir: "{{ working_dir }}/tobiko"
|
||||
executable: /bin/bash
|
||||
register: tobiko_tests_run
|
||||
ignore_errors: true
|
||||
environment:
|
||||
OS_CLOUD: "{{ tempest_cloud_name }}"
|
32
roles/validate-tobiko/tasks/tobiko-results.yml
Normal file
32
roles/validate-tobiko/tasks/tobiko-results.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Check for .stestr directory
|
||||
stat:
|
||||
path: "{{ working_dir }}/tobiko/.stestr"
|
||||
register: testr_dir
|
||||
|
||||
- name: Define testr facts
|
||||
set_fact:
|
||||
testr_command: "{{ python_cmd }} -m stestr.cli"
|
||||
|
||||
- name: Generate testrepository.subunit results file
|
||||
shell: >
|
||||
set -o pipefail &&
|
||||
{{ testr_command }} last --subunit > {{ tobiko_log_dir }}/testrepository.subunit
|
||||
args:
|
||||
chdir: "{{ working_dir }}/tobiko"
|
||||
|
||||
- name: Generate HTML results file
|
||||
shell: |
|
||||
set -o pipefail &&
|
||||
subunit2html {{ tobiko_log_dir }}/testrepository.subunit {{ tobiko_log_dir }}/{{ tobiko_log_file }}.html
|
||||
|
||||
- name: Fetch HTML results
|
||||
fetch:
|
||||
src: "{{ tobiko_log_dir }}/{{ tobiko_log_file }}.html"
|
||||
dest: "{{ local_working_dir }}/{{ tobiko_log_file }}.html"
|
||||
flat: true
|
||||
|
||||
- name: Fail if tobiko tests did not succeed
|
||||
assert:
|
||||
that:
|
||||
- "tobiko_tests_run.rc == 0"
|
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
export OS_CLOUD={{ tempest_cloud_name }}
|
||||
|
||||
openstack network list -c Name -f value | grep -q -e "^{{ tobiko_floating_ip_network }}$"
|
||||
if [ $? -eq 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
openstack network create {{ tobiko_floating_ip_network }} --external \
|
||||
{% if public_physical_network != '' %}
|
||||
--provider-network-type {{ public_network_type }} \
|
||||
{% if public_segmentation_id != '' %}
|
||||
--provider-segment {{ public_segmentation_id }} \
|
||||
{% endif %}
|
||||
--provider-physical-network {{ public_physical_network }}
|
||||
{% endif %}
|
||||
|
||||
openstack subnet create ext-subnet \
|
||||
--allocation-pool \
|
||||
start={{ public_network_pool_start }},end={{ public_network_pool_end }} \
|
||||
--no-dhcp \
|
||||
--gateway {{ public_network_gateway }} \
|
||||
--network {{ tobiko_floating_ip_network }} \
|
||||
--subnet-range {{ floating_ip_cidr }}
|
18
roles/validate-tobiko/templates/tobiko.conf.j2
Normal file
18
roles/validate-tobiko/templates/tobiko.conf.j2
Normal file
@@ -0,0 +1,18 @@
|
||||
[DEFAULT]
|
||||
debug = True
|
||||
log_file = "{{ tobiko_log_file }}"
|
||||
log_dir = "{{ working_dir }}"
|
||||
|
||||
{% if tobiko_no_proxy_servers is defined %}
|
||||
[http]
|
||||
no_proxy = "{{ tobiko_no_proxy_servers }}"
|
||||
{% endif %}
|
||||
|
||||
[nova]
|
||||
key_file = "{{ tobiko_key_file_name }}"
|
||||
|
||||
[neutron]
|
||||
floating_network = "{{ tobiko_floating_ip_network }}"
|
||||
|
||||
[glance]
|
||||
images_dir = "{{ working_dir }}"/.tobiko/cache/glance/images"
|
Reference in New Issue
Block a user