Enable cross-repo testing for OSA integrated tests

When 'Depends-On: <change-id>' is used in a patch,
Zuul cloner must be used in order to ensure that
both patches are actually used for the gate test.

This patch implements the use of zuul-cloner [1]
for gate tests and falls back to using git if
zuul-cloner is not present.

[1] http://docs.openstack.org/infra/zuul/cloner.html

Change-Id: I2d5d7c94af7688d403b09e16565ef0086fa5c49c
This commit is contained in:
Jesse Pretorius
2017-04-21 14:19:55 +01:00
parent f5c72e5076
commit 62bc0d70f2
2 changed files with 72 additions and 2 deletions

View File

@@ -85,6 +85,19 @@ if [ -n "${DATA_DISK_DEVICE}" ]; then
export BOOTSTRAP_OPTS="${BOOTSTRAP_OPTS} bootstrap_host_data_disk_device=${DATA_DISK_DEVICE}"
fi
# Grab all the zuul environment variables that
# were exported by the jenkins user into a file.
# This is used for cross-repo testing.
if [ -f zuul.env ]; then
# The ZUUL variables we get in the file are
# not quoted, so we change the file to ensure
# that they are. We also ensure that each
# var is exported so that it's accessible in
# any subshell.
sed -i 's|\(.*\)=\(.*\)$|export \1="\2"|' zuul.env
source zuul.env
fi
# Bootstrap Ansible
source "$(dirname "${0}")/bootstrap-ansible.sh"

View File

@@ -18,6 +18,16 @@
connection: local
user: root
tasks:
- name: Check whether zuul-cloner is installed and provide the path to it
shell: |
which zuul-cloner || { [[ -x /usr/zuul-env/bin/zuul-cloner ]] && echo '/usr/zuul-env/bin/zuul-cloner'; }
args:
executable: /bin/bash
changed_when: false
failed_when: false
register: _zuul_cloner_check
- name: Remove target directory if required
shell: |
if [[ ! -d "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}/.git" ]]; then
@@ -28,7 +38,29 @@
when:
- item.scm == "git" or item.scm is undefined
with_items: "{{ roles }}"
- name: Clone git repos
- name: Prepare git clone list
set_fact:
git_roles: >
{%- set filtered_role_list = [] %}
{%- for role in roles %}
{%- if not role.src | match(".*git.openstack.org.*") %}
{%- set _ = filtered_role_list.append(role) %}
{%- endif %}
{%- endfor %}
{{- filtered_role_list -}}
zuul_roles: >
{%- set filtered_role_list = [] %}
{%- for role in roles %}
{%- if role.src | match(".*git.openstack.org.*") %}
{%- set _ = filtered_role_list.append(role) %}
{%- endif %}
{%- endfor %}
{{- filtered_role_list -}}
when:
- _zuul_cloner_check.rc == 0
- name: Clone git repos (with git)
git:
repo: "{{ item.src }}"
dest: "{{ item.path | default(role_path_default) }}/{{ item.name | default(item.src | basename) }}"
@@ -38,11 +70,36 @@
force: true
when:
- item.scm == "git" or item.scm is undefined
with_items: "{{ roles }}"
with_items: "{{ git_roles | default(roles) }}"
register: git_clone
until: git_clone | success
retries: "{{ git_clone_retries }}"
delay: "{{ git_clone_retry_delay }}"
- name: Create clone map
copy:
content: |
clonemap:
- name: 'openstack/openstack-ansible-security'
dest: '{{ role_path_default }}/openstack-ansible-security'
- name: 'openstack/openstack-ansible-(?!security)(.*)'
dest: '{{ role_path_default }}/\1'
dest: "/tmp/zuul-clonemap.yml"
when:
- _zuul_cloner_check.rc == 0
- name: Clone git repos (with zuul-cloner)
shell: |
{{ _zuul_cloner_check.stdout }} \
-m /tmp/zuul-clonemap.yml \
--cache-dir /opt/git \
git://git.openstack.org \
{% for role in zuul_roles %}
{{ role.src | regex_replace('https://git.openstack.org/', '') }} \
{% endfor %}
when:
- _zuul_cloner_check.rc == 0
vars:
roles: "{{ lookup('file', role_file) | from_yaml }}"
role_file: '../ansible-role-requirements.yml'