summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColleen Murphy <colleen@gazlene.net>2017-08-18 10:28:34 +0200
committerColleen Murphy <colleen@gazlene.net>2017-08-18 10:28:34 +0200
commitca36d793b316a025422fbe0a5aae17b9dc24edad (patch)
tree044f6f1f4a7ab3543118c1f52a694833f3005cdd
parent8ba2b661ed948c371db996bdcc20a7cf194ffcba (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: Ib1db911eafec6b208c9f0375d22d0cf8a18cc48b
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 21:57:58 +0000 Reviewed-on: https://review.openstack.org/495119 Project: openstack-infra/puppet-accessbot Branch: refs/heads/master
-rw-r--r--Gemfile10
-rwxr-xr-xspec/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 27ea995..5f3161b 100755
--- 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 'basic accessbot' do 3describe 'basic accessbot' do
4 4
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