Implement native zuul v3 tests

Change-Id: I5160ce88aefa2c5b70e4a4cb085867198e60b45a
This commit is contained in:
Jens Harbott 2017-09-29 09:29:40 +00:00 committed by Jens Harbott (frickler)
parent f6ce85b324
commit 577adaea35
7 changed files with 87 additions and 4 deletions

33
.zuul.yaml Normal file
View File

@ -0,0 +1,33 @@
- job:
name: openstack-chef-repo-rake
parent: base
description: Run rake tests with openstack-chef-repo
required-projects: openstack/openstack-chef-repo
pre-run: playbooks/pre
run: playbooks/rake
- job:
name: openstack-chef-repo-integration
parent: base
description: Run integration tests with openstack-chef-repo
required-projects: openstack/openstack-chef-repo
pre-run: playbooks/pre
run: playbooks/integration
post-run: playbooks/post
timeout: 3600
- project-template:
name: openstack-chef-repo-jobs
check:
jobs:
- openstack-chef-repo-rake
- openstack-chef-repo-integration
gate:
jobs:
- openstack-chef-repo-rake
- openstack-chef-repo-integration
- project:
name: openstack/openstack-chef-repo
templates:
- openstack-chef-repo-jobs

View File

@ -168,8 +168,8 @@ def _setup_local_network # rubocop:disable Metrics/MethodLength
end end
# Helper for setting up tempest and upload the default cirros image. # Helper for setting up tempest and upload the default cirros image.
def _setup_tempest(client_opts) def _setup_tempest(client_opts, log_dir)
sh %(sudo chef-client #{client_opts} -E integration-#{@platform} -r 'recipe[openstack-integration-test::setup]') sh %(sudo chef-client #{client_opts} -E integration-#{@platform} -r 'recipe[openstack-integration-test::setup]' > #{log_dir}/chef-client-setup-tempest.txt 2>&1 )
end end
def _save_logs(prefix, log_dir) def _save_logs(prefix, log_dir)
@ -184,6 +184,7 @@ end
desc "Integration test on Infra" desc "Integration test on Infra"
task :integration => [:create_key, :berks_vendor] do task :integration => [:create_key, :berks_vendor] do
log_dir = ENV['WORKSPACE']+'/logs' log_dir = ENV['WORKSPACE']+'/logs'
sh %(mkdir #{log_dir})
# This is a workaround for allowing chef-client to run in local mode # This is a workaround for allowing chef-client to run in local mode
sh %(sudo mkdir -p /etc/chef && sudo cp .chef/encrypted_data_bag_secret /etc/chef/openstack_data_bag_secret) sh %(sudo mkdir -p /etc/chef && sudo cp .chef/encrypted_data_bag_secret /etc/chef/openstack_data_bag_secret)
_run_env_queries _run_env_queries
@ -198,9 +199,9 @@ task :integration => [:create_key, :berks_vendor] do
begin begin
puts "####### Pass #{i}" puts "####### Pass #{i}"
# Kick off chef client in local mode, will converge OpenStack right on the gate job "in place" # Kick off chef client in local mode, will converge OpenStack right on the gate job "in place"
sh %(sudo chef-client #{client_opts} -E integration-#{@platform} -r 'role[minimal]') sh %(sudo chef-client #{client_opts} -E integration-#{@platform} -r 'role[minimal]' > #{log_dir}/chef-client-pass#{i}.txt 2>&1 )
if i == 1 if i == 1
_setup_tempest(client_opts) _setup_tempest(client_opts, log_dir)
_setup_local_network _setup_local_network
end end
_run_basic_queries _run_basic_queries

View File

@ -0,0 +1,5 @@
build-essential [platform:dpkg]
liblzma-dev [platform:dpkg]
xz-devel [platform:rpm]
zlib1g-dev [platform:dpkg]
zlib-devel [platform:rpm]

View File

@ -0,0 +1,8 @@
- hosts: all
tasks:
- name: run integration
shell:
cmd: chef exec rake integration
chdir: '{{ ansible_user_dir }}/src/git.openstack.org/openstack/openstack-chef-repo'
environment:
WORKSPACE: '{{ ansible_user_dir }}'

7
playbooks/post.yaml Normal file
View File

@ -0,0 +1,7 @@
- hosts: all
tasks:
- name: Collect logs
synchronize:
dest: '{{ zuul.executor.log_root }}/{{ inventory_hostname }}'
mode: pull
src: '{{ ansible_user_dir }}/logs/'

21
playbooks/pre.yaml Normal file
View File

@ -0,0 +1,21 @@
- hosts: all
roles:
- bindep
vars:
bindep_file: /home/zuul/src/git.openstack.org/openstack/openstack-chef-repo/bindep.txt
- hosts: all
vars:
chefdk: chefdk_1.6.1-1_amd64.deb
tasks:
- name: Purge some packages
shell: apt-get -y purge libvirt0 libvirt-dev python-libvirt
become: yes
- name: Fetch chefdk package
get_url:
dest: /tmp/{{ chefdk }}
url: https://packages.chef.io/stable/ubuntu/16.04/{{ chefdk }}
- name: Install chefdk package
shell: dpkg -i /tmp/{{ chefdk }}
become: yes

8
playbooks/rake.yaml Normal file
View File

@ -0,0 +1,8 @@
- hosts: all
roles:
- revoke-sudo
tasks:
- name: run rake tests
shell:
cmd: chef exec rake
chdir: '{{ zuul.project.src_dir }}'