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
commit4ea93acf4d26b11b16f937721b42c51f01c5816e (patch)
tree445444f2edf66e3863c8886fd88802cc1186b1c8
parent166f51154a6b1a50d71278ecaf64fc2647fdcdcd (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: If0f66d60444c4dbcd0b46772fb017c44bceef1ad
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Workflow+1: Clark Boylan <cboylan@sapwetik.org> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 22 Aug 2017 22:25:13 +0000 Reviewed-on: https://review.openstack.org/495599 Project: openstack-infra/puppet-haveged Branch: refs/heads/master
-rw-r--r--Gemfile12
-rw-r--r--spec/acceptance/basic_spec.rb2
-rw-r--r--spec/spec_helper_acceptance.rb66
3 files changed, 9 insertions, 71 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/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb
index ae9a7d3..445131a 100644
--- a/spec/acceptance/basic_spec.rb
+++ b/spec/acceptance/basic_spec.rb
@@ -1,4 +1,4 @@
1require 'spec_helper_acceptance' 1require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance'
2 2
3describe 'puppet-haveged module' do 3describe 'puppet-haveged module' do
4 def pp_path 4 def pp_path
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
deleted file mode 100644
index de96291..0000000
--- a/spec/spec_helper_acceptance.rb
+++ /dev/null
@@ -1,66 +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
15 on host, "mkdir -p #{host['distmoduledir']}"
16end
17
18RSpec.configure do |c|
19 # Project root
20 proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
21 modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
22
23 # Readable test descriptions
24 c.formatter = :documentation
25
26 # Configure all nodes in nodeset
27 c.before :suite do
28 # Install module and dependencies
29 hosts.each do |host|
30
31 # Clean out any module cruft
32 shell('rm -fr /etc/puppet/modules/*')
33
34 # install git
35 install_package host, 'git'
36
37 zuul_ref = ENV['ZUUL_REF']
38 zuul_branch = ENV['ZUUL_BRANCH']
39 zuul_url = ENV['ZUUL_URL']
40
41 # Install dependent modules via git or zuul
42 r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
43 repo = 'openstack-infra/system-config'
44 if r.exit_code == 0
45 zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
46 zuul_clone_cmd += '--cache-dir /opt/git '
47 zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
48 zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
49 zuul_clone_cmd += "--zuul-url #{zuul_url} "
50 zuul_clone_cmd += "git://git.openstack.org #{repo}"
51 on host, zuul_clone_cmd
52 else
53 on host, "git clone https://git.openstack.org/#{repo} #{repo}"
54 end
55
56 on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/tools/install_modules_acceptance.sh"
57 on host, "rm -fr /etc/puppet/modules/#{modname}"
58
59 # Install the module being tested
60 puppet_module_install(:source => proj_root, :module_name => modname)
61 on host, "rm -fr #{repo}"
62 # List modules installed to help with debugging
63 on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
64 end
65 end
66end