Puppet module to manage reviewday
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spec_helper_acceptance.rb 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. require 'beaker-rspec'
  2. hosts.each do |host|
  3. # puppet 3 isn't available from apt.puppetlabs.com so install it from the Xenial repos
  4. on host, "which apt-get && apt-get install puppet -y", { :acceptable_exit_codes => [0,1] }
  5. # otherwise use the beaker helpers to install the yum.puppetlabs.com repo and puppet
  6. r = on host, "which yum", { :acceptable_exit_codes => [0,1] }
  7. if r.exit_code == 0
  8. install_puppet
  9. end
  10. add_platform_foss_defaults(host, 'unix')
  11. on host, "mkdir -p #{host['distmoduledir']}"
  12. end
  13. RSpec.configure do |c|
  14. # Project root
  15. proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
  16. modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]
  17. # Readable test descriptions
  18. c.formatter = :documentation
  19. # Configure all nodes in nodeset
  20. c.before :suite do
  21. # Install module and dependencies
  22. hosts.each do |host|
  23. # Clean out any module cruft
  24. shell('rm -fr /etc/puppet/modules/*')
  25. # install git
  26. install_package host, 'git'
  27. zuul_ref = ENV['ZUUL_REF']
  28. zuul_branch = ENV['ZUUL_BRANCH']
  29. zuul_url = ENV['ZUUL_URL']
  30. # Install dependent modules via git or zuul
  31. r = on host, "test -e /usr/zuul-env/bin/zuul-cloner", { :acceptable_exit_codes => [0,1] }
  32. repo = 'openstack-infra/system-config'
  33. if r.exit_code == 0
  34. zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner '
  35. zuul_clone_cmd += '--cache-dir /opt/git '
  36. zuul_clone_cmd += "--zuul-ref #{zuul_ref} "
  37. zuul_clone_cmd += "--zuul-branch #{zuul_branch} "
  38. zuul_clone_cmd += "--zuul-url #{zuul_url} "
  39. zuul_clone_cmd += "git://git.openstack.org #{repo}"
  40. on host, zuul_clone_cmd
  41. else
  42. on host, "git clone https://git.openstack.org/#{repo} #{repo}"
  43. end
  44. on host, "ZUUL_REF=#{zuul_ref} ZUUL_BRANCH=#{zuul_branch} ZUUL_URL=#{zuul_url} bash #{repo}/tools/install_modules_acceptance.sh"
  45. on host, "rm -fr /etc/puppet/modules/#{modname}"
  46. # Install the module being tested
  47. puppet_module_install(:source => proj_root, :module_name => modname)
  48. on host, "rm -fr #{repo}"
  49. # List modules installed to help with debugging
  50. on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 }
  51. end
  52. end
  53. end