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
commitefd4267ef4f80e4f37503ee84ae78bb39d6e3483 (patch)
tree648da7318e664d341c7df00f22edc31b3e9f4abf
parent5f7b59c32c8d4c5e67bb1d7b474d7fc2f4023ba5 (diff)
Depend on helper gem for spec_helper_acceptanceHEADmaster
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: I8233333e7c35a3a1191c0f8d070f6de5dfb7b33d
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:15 +0000 Reviewed-on: https://review.openstack.org/495601 Project: openstack-infra/puppet-httpd Branch: refs/heads/master
-rw-r--r--Gemfile10
-rw-r--r--spec/acceptance/basic_spec.rb2
-rw-r--r--spec/spec_helper_acceptance.rb66
3 files changed, 9 insertions, 69 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/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb
index 9e826f1..b16de78 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-httpd module' do 3describe 'puppet-httpd 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