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
commit4b1adec999ada414a1b9df00686914fc6ea7745e (patch)
tree3e10b96039761c41a51a93404a0806f775db2718
parent84d7a8e2b08376f768a8822f744a0a85729376d8 (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: I2d36cc46c473598a8a66259554b454b73ae98b83
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: Wed, 23 Aug 2017 07:50:51 +0000 Reviewed-on: https://review.openstack.org/495589 Project: openstack-infra/puppet-ethercalc Branch: refs/heads/master
-rw-r--r--Gemfile10
-rw-r--r--spec/spec_helper_acceptance.rb65
2 files changed, 8 insertions, 67 deletions
diff --git a/Gemfile b/Gemfile
index e350f81..9854cc9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,9 +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
7end 13end
8 14
9# 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