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: I2d36cc46c473598a8a66259554b454b73ae98b83
Colleen Murphy 1 year ago
parent
commit
4b1adec999
2 changed files with 8 additions and 67 deletions
  1. 8
    2
      Gemfile
  2. 0
    65
      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

+ 0
- 65
spec/spec_helper_acceptance.rb View File

@@ -1,65 +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
-  on host, "mkdir -p #{host['distmoduledir']}"
15
-end
16
-
17
-RSpec.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
65
-end

Loading…
Cancel
Save