Browse Source

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: I8233333e7c35a3a1191c0f8d070f6de5dfb7b33d
Colleen Murphy 1 year ago
parent
commit
efd4267ef4
3 changed files with 9 additions and 69 deletions
  1. 8
    2
      Gemfile
  2. 1
    1
      spec/acceptance/basic_spec.rb
  3. 0
    66
      spec/spec_helper_acceptance.rb

+ 8
- 2
Gemfile View File

@@ -1,9 +1,15 @@
1 1
 source 'https://rubygems.org'
2 2
 
3
+if 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"}
5
+else
6
+  gem_checkout_method = {:git => 'https://git.openstack.org/openstack-infra/puppet-openstack_infra_spec_helper'}
7
+end
8
+gem_checkout_method[:require] = false
9
+
3 10
 group :development, :test, :system_tests do
4 11
   gem 'puppet-openstack_infra_spec_helper',
5
-      :git     => 'https://git.openstack.org/openstack-infra/puppet-openstack_infra_spec_helper',
6
-      :require => false
12
+      gem_checkout_method
7 13
 end
8 14
 
9 15
 # vim:ft=ruby

+ 1
- 1
spec/acceptance/basic_spec.rb View File

@@ -1,4 +1,4 @@
1
-require 'spec_helper_acceptance'
1
+require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance'
2 2
 
3 3
 describe 'puppet-httpd module' do
4 4
   def pp_path

+ 0
- 66
spec/spec_helper_acceptance.rb View File

@@ -1,66 +0,0 @@
1
-require 'beaker-rspec'
2
-
3
-hosts.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']}"
16
-end
17
-
18
-RSpec.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
66
-end

Loading…
Cancel
Save