From 577adaea355470d6c26983e3cbff0a960c79e848 Mon Sep 17 00:00:00 2001 From: Jens Harbott Date: Fri, 29 Sep 2017 09:29:40 +0000 Subject: [PATCH] Implement native zuul v3 tests Change-Id: I5160ce88aefa2c5b70e4a4cb085867198e60b45a --- .zuul.yaml | 33 +++++++++++++++++++++++++++++++++ Rakefile | 9 +++++---- bindep.txt | 5 +++++ playbooks/integration.yaml | 8 ++++++++ playbooks/post.yaml | 7 +++++++ playbooks/pre.yaml | 21 +++++++++++++++++++++ playbooks/rake.yaml | 8 ++++++++ 7 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 .zuul.yaml create mode 100644 playbooks/integration.yaml create mode 100644 playbooks/post.yaml create mode 100644 playbooks/pre.yaml create mode 100644 playbooks/rake.yaml diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..06df859 --- /dev/null +++ b/.zuul.yaml @@ -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 diff --git a/Rakefile b/Rakefile index c2ea2bd..b4dc7f1 100644 --- a/Rakefile +++ b/Rakefile @@ -168,8 +168,8 @@ def _setup_local_network # rubocop:disable Metrics/MethodLength end # Helper for setting up tempest and upload the default cirros image. -def _setup_tempest(client_opts) - sh %(sudo chef-client #{client_opts} -E integration-#{@platform} -r 'recipe[openstack-integration-test::setup]') +def _setup_tempest(client_opts, log_dir) + 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 def _save_logs(prefix, log_dir) @@ -184,6 +184,7 @@ end desc "Integration test on Infra" task :integration => [:create_key, :berks_vendor] do log_dir = ENV['WORKSPACE']+'/logs' + sh %(mkdir #{log_dir}) # 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) _run_env_queries @@ -198,9 +199,9 @@ task :integration => [:create_key, :berks_vendor] do begin puts "####### Pass #{i}" # 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 - _setup_tempest(client_opts) + _setup_tempest(client_opts, log_dir) _setup_local_network end _run_basic_queries diff --git a/bindep.txt b/bindep.txt index e69de29..0ee354c 100644 --- a/bindep.txt +++ b/bindep.txt @@ -0,0 +1,5 @@ +build-essential [platform:dpkg] +liblzma-dev [platform:dpkg] +xz-devel [platform:rpm] +zlib1g-dev [platform:dpkg] +zlib-devel [platform:rpm] diff --git a/playbooks/integration.yaml b/playbooks/integration.yaml new file mode 100644 index 0000000..c9c65b0 --- /dev/null +++ b/playbooks/integration.yaml @@ -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 }}' diff --git a/playbooks/post.yaml b/playbooks/post.yaml new file mode 100644 index 0000000..362b2fa --- /dev/null +++ b/playbooks/post.yaml @@ -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/' diff --git a/playbooks/pre.yaml b/playbooks/pre.yaml new file mode 100644 index 0000000..077f9da --- /dev/null +++ b/playbooks/pre.yaml @@ -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 + diff --git a/playbooks/rake.yaml b/playbooks/rake.yaml new file mode 100644 index 0000000..264407a --- /dev/null +++ b/playbooks/rake.yaml @@ -0,0 +1,8 @@ +- hosts: all + roles: + - revoke-sudo + tasks: + - name: run rake tests + shell: + cmd: chef exec rake + chdir: '{{ zuul.project.src_dir }}'