summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColleen Murphy <colleen@gazlene.net>2017-08-18 10:41:43 +0200
committerColleen Murphy <colleen@gazlene.net>2017-08-18 10:41:43 +0200
commitb922097fc70feae82d1d0681d2ead5958d79d56b (patch)
tree4f2432d826de824e6e1a7e688e0772cbbc1682bc
parent5cfa4479778ae2e8a7b3551ce1439f74845235c2 (diff)
Depend on helper gem for spec_helper_acceptance
Instead of keeping a local copy of spec_helper_acceptance.rb and requiring updates to all modules for any change, we can move it into the common helper gem and require it from there. This will make it easier to create and review changes that affect all puppet modules. Also change the Gemfile to look for the gem in the local workspace if running in a zuul environment. Change-Id: Ib53678193c4380decc7c6b666c5ec6900da81b4f
Notes
Notes (review): Code-Review+2: Paul Belanger <pabelanger@redhat.com> Workflow+1: Paul Belanger <pabelanger@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 26 Mar 2018 22:00:47 +0000 Reviewed-on: https://review.openstack.org/495611 Project: openstack-infra/puppet-logrotate Branch: refs/heads/master
-rw-r--r--Gemfile12
-rw-r--r--spec/spec_helper_acceptance.rb65
2 files changed, 8 insertions, 69 deletions
diff --git a/Gemfile b/Gemfile
index fbec945..9854cc9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,11 +1,15 @@
1source 'https://rubygems.org' 1source 'https://rubygems.org'
2 2
3if ENV['ZUUL_REF'] && File.exists?("#{ENV['WORKSPACE']}/openstack-infra/puppet-openstack_infra_spec_helper")
4 gem_checkout_method = {:path => "#{ENV['WORKSPACE']}/openstack-infra/puppet-openstack_infra_spec_helper"}
5else
6 gem_checkout_method = {:git => 'https://git.openstack.org/openstack-infra/puppet-openstack_infra_spec_helper'}
7end
8gem_checkout_method[:require] = false
9
3group :development, :test, :system_tests do 10group :development, :test, :system_tests do
4 gem 'puppet-openstack_infra_spec_helper', 11 gem 'puppet-openstack_infra_spec_helper',
5 :git => 'https://git.openstack.org/openstack-infra/puppet-openstack_infra_spec_helper', 12 gem_checkout_method
6 :require => false
7 # Not all modules can do this, so we add it here to the ones that can
8 gem 'puppet-lint-empty_string-check'
9end 13end
10 14
11# vim:ft=ruby 15# vim:ft=ruby
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
deleted file mode 100644
index 002ab34..0000000
--- a/spec/spec_helper_acceptance.rb
+++ /dev/null
@@ -1,65 +0,0 @@
1require 'beaker-rspec'
2
3hosts.each do |host|
4
5 # puppet 3 isn't available from apt.puppetlabs.com so install it from the Xenial repos
6 on host, "which apt-get && apt-get install puppet -y", { :acceptable_exit_codes => [0,1] }
7 # otherwise use the beaker helpers to install the yum.puppetlabs.com repo and puppet
8 r = on host, "which yum", { :acceptable_exit_codes => [0,1] }
9 if r.exit_code == 0
10 install_puppet
11 end
12 add_platform_foss_defaults(host, 'unix')
13
14 on host, "mkdir -p #{host['distmoduledir']}"
15end
16
17RSpec.configure do |c|
18 # Project root
19 proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
20 modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
21
22 # Readable test descriptions
23 c.formatter = :documentation
24
25 # Configure all nodes in nodeset
26 c.before :suite do
27 # Install module and dependencies
28 hosts.each do |host|
29
30 # Clean out any module cruft
31 shell('rm -fr /etc/puppet/modules/*')
32
33 # install git
34 install_package host, 'git'
35
36 zuul_ref = ENV['ZUUL_REF']
37 zuul_branch = ENV['ZUUL_BRANCH']
38 zuul_url = ENV['ZUUL_URL']
39
40 # Install dependent modules via git or zuul
41 r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
42 repo = 'openstack-infra/system-config'
43 if r.exit_code == 0
44 zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
45 zuul_clone_cmd += '--cache-dir /opt/git '
46 zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
47 zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
48 zuul_clone_cmd += "--zuul-url #{zuul_url} "
49 zuul_clone_cmd += "git://git.openstack.org #{repo}"
50 on host, zuul_clone_cmd
51 else
52 on host, "git clone https://git.openstack.org/#{repo} #{repo}"
53 end
54
55 on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/tools/install_modules_acceptance.sh"
56 on host, "rm -fr /etc/puppet/modules/#{modname}"
57
58 # Install the module being tested
59 puppet_module_install(:source => proj_root, :module_name => modname)
60 on host, "rm -fr #{repo}"
61 # List modules installed to help with debugging
62 on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
63 end
64 end
65end