Browse Source

Create a test matrix role

Modify test-matrix.py so that is can be used as an ansible module.
Add a role in d-g that runs test matrix for the given branch,
role and features file.

Change-Id: Ie36ba0cd7cfcd450b75000a76a64d856f2a83eba
changes/02/524402/28
Andrea Frittoli (andreaf) 4 years ago
parent
commit
3d0fc8bf6d
9 changed files with 130 additions and 15 deletions
  1. +8
    -0
      .zuul.yaml
  2. +1
    -1
      devstack-vm-gate-wrap.sh
  3. +3
    -2
      devstack-vm-gate.sh
  4. +28
    -0
      roles/test-matrix/README.rst
  5. +4
    -0
      roles/test-matrix/defaults/main.yaml
  6. +0
    -0
      roles/test-matrix/files/features.yaml
  7. +44
    -7
      roles/test-matrix/library/test_matrix.py
  8. +37
    -0
      roles/test-matrix/tasks/main.yaml
  9. +5
    -5
      test-features.sh

+ 8
- 0
.zuul.yaml View File

@ -3,3 +3,11 @@
nodes:
- name: primary
label: ubuntu-xenial
- project:
name: openstack-infra/devstack-gate
check:
jobs:
- devstack:
files:
- ^roles/

+ 1
- 1
devstack-vm-gate-wrap.sh View File

@ -149,7 +149,7 @@ export BASE=/opt/stack
export ZUUL_URL=${ZUUL_URL:-http://zuul.openstack.org/p}
# The feature matrix to select devstack-gate components
export DEVSTACK_GATE_FEATURE_MATRIX=${DEVSTACK_GATE_FEATURE_MATRIX:-features.yaml}
export DEVSTACK_GATE_FEATURE_MATRIX=${DEVSTACK_GATE_FEATURE_MATRIX:-roles/test-matrix/files/features.yaml}
# Set to 1 to install, configure and enable the Tempest test suite; more flags may be
# required to be set to customize the test run, e.g. DEVSTACK_GATE_TEMPEST_STRESS=1


+ 3
- 2
devstack-vm-gate.sh View File

@ -312,8 +312,9 @@ function setup_localrc {
test_matrix_role='subnode'
fi
MY_ENABLED_SERVICES=$(cd $BASE/new/devstack-gate && $PYTHON_PATH ./test-matrix.py -b $branch_for_matrix -f $DEVSTACK_GATE_FEATURE_MATRIX -r $test_matrix_role)
local original_enabled_services=$(cd $BASE/new/devstack-gate && $PYTHON_PATH ./test-matrix.py -b $branch_for_matrix -f $DEVSTACK_GATE_FEATURE_MATRIX -r primary)
TEST_MATRIX='roles/test-matrix/library/test_matrix.py -n'
MY_ENABLED_SERVICES=$(cd $BASE/new/devstack-gate && $PYTHON_PATH $TEST_MATRIX -b $branch_for_matrix -f $DEVSTACK_GATE_FEATURE_MATRIX -r $test_matrix_role)
local original_enabled_services=$(cd $BASE/new/devstack-gate && $PYTHON_PATH $TEST_MATRIX -b $branch_for_matrix -f $DEVSTACK_GATE_FEATURE_MATRIX -r primary)
echo "MY_ENABLED_SERVICES: ${MY_ENABLED_SERVICES}"
echo "original_enabled_services: ${original_enabled_services}"


+ 28
- 0
roles/test-matrix/README.rst View File

@ -0,0 +1,28 @@
Set the a enabled_services fact based based on the test matrix
**Role Variables**
.. zuul:rolevar:: test_matrix_features
:default: files/features.yaml
The YAML file that defines the test matrix.
.. zuul:rolevar:: test_matrix_branch
:default: {{ zuul.override_checkout | default(zuul.branch) }}
The git branch for which to calculate the test matrix.
.. zuul:rolevar:: test_matrix_role
:default: primary
The role of the node for which the test matrix is calculated.
Valid values are 'primary' and 'subnode'.
.. zuul:rolevar:: test_matrix_configs
:default: []
:type: list
Feature configuration for the test matrix. This option allows enabling
more features, as defined in ``test_matrix_features``.
The default value is an empty list, however 'neutron' is added by default
from stable/ocata onwards.

+ 4
- 0
roles/test-matrix/defaults/main.yaml View File

@ -0,0 +1,4 @@
test_matrix_features: files/features.yaml
test_matrix_branch: "{{ zuul.override_checkout | default(zuul.branch) }}"
test_matrix_role: primary
test_matrix_configs: []

features.yaml → roles/test-matrix/files/features.yaml View File


test-matrix.py → roles/test-matrix/library/test_matrix.py View File


+ 37
- 0
roles/test-matrix/tasks/main.yaml View File

@ -0,0 +1,37 @@
- name: Deploy then features matrix and d-g bash functions
copy:
src: "{{ test_matrix_features }}"
dest: "{{ ansible_user_dir }}"
- name: Ensure virtualenv is installed
become: true
package:
name: virtualenv
state: present
when: ansible_os_family != 'Darwin'
- name: Install PyYAML to parse the test matrix
pip:
name: PyYAML
virtualenv: "/tmp/.test_matrix_venv"
- name: Append neutron to configs for stable/ocata+
set_fact:
test_matrix_configs: "{{ test_matrix_configs }} + [ 'neutron' ]"
when:
- '"neutron" not in test_matrix_configs'
- test_matrix_branch | match("^(stable/[o-z].*|master)$")
- name: Run the test matrix
test_matrix:
features: "{{ ansible_user_dir }}/{{ test_matrix_features | basename }}"
branch: "{{ test_matrix_branch }}"
role: "{{ test_matrix_role }}"
configs: "{{ test_matrix_configs }}"
vars:
ansible_python_interpreter: "/tmp/.test_matrix_venv/bin/python"
register: test_matrix_result
- name: Set the enabled_services fact
set_fact:
enabled_services: "{{ test_matrix_result.services }}"

+ 5
- 5
test-features.sh View File

@ -40,27 +40,27 @@ function assert_list_equal {
}
function test_full_master {
local results=$(DEVSTACK_GATE_TEMPEST=1 ./test-matrix.py)
local results=$(DEVSTACK_GATE_TEMPEST=1 ./roles/test-matrix/library/test_matrix.py -n)
assert_list_equal $TEMPEST_FULL_MASTER $results
}
function test_full_feature_ec {
local results=$(DEVSTACK_GATE_TEMPEST=1 ./test-matrix.py -b feature/ec)
local results=$(DEVSTACK_GATE_TEMPEST=1 ./roles/test-matrix/library/test_matrix.py -n -b feature/ec)
assert_list_equal $TEMPEST_FULL_MASTER $results
}
function test_neutron_master {
local results=$(DEVSTACK_GATE_NEUTRON=1 DEVSTACK_GATE_TEMPEST=1 ./test-matrix.py)
local results=$(DEVSTACK_GATE_NEUTRON=1 DEVSTACK_GATE_TEMPEST=1 ./roles/test-matrix/library/test_matrix.py -n)
assert_list_equal $TEMPEST_NEUTRON_MASTER $results
}
function test_heat_slow_master {
local results=$(DEVSTACK_GATE_TEMPEST_HEAT_SLOW=1 DEVSTACK_GATE_NEUTRON=1 DEVSTACK_GATE_TEMPEST=1 ./test-matrix.py)
local results=$(DEVSTACK_GATE_TEMPEST_HEAT_SLOW=1 DEVSTACK_GATE_NEUTRON=1 DEVSTACK_GATE_TEMPEST=1 ./roles/test-matrix/library/test_matrix.py -n)
assert_list_equal $TEMPEST_HEAT_SLOW_MASTER $results
}
function test_grenade_new_master {
local results=$(DEVSTACK_GATE_TEMPEST_HEAT_SLOW=1 DEVSTACK_GATE_GRENADE=pullup DEVSTACK_GATE_TEMPEST=1 ./test-matrix.py)
local results=$(DEVSTACK_GATE_TEMPEST_HEAT_SLOW=1 DEVSTACK_GATE_GRENADE=pullup DEVSTACK_GATE_TEMPEST=1 ./roles/test-matrix/library/test_matrix.py -n)
assert_list_equal $GRENADE_NEW_MASTER $results
}


Loading…
Cancel
Save