Skip to content

Commit

Permalink
update beaker plumbing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Feb 2, 2017
1 parent b3b2725 commit 408f695
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
14 changes: 4 additions & 10 deletions spec/acceptance/udev_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
require 'spec_helper_acceptance'

describe 'udev class' do
maj = fact_on 'master', 'operatingsystemmajrelease'

package_name = nil
case maj.to_i
when 5, 6
package_name = 'udev'
when 7
if $systemd
package_name = 'systemd'
else
package_name = 'udev'
end

describe 'running puppet code' do
Expand All @@ -25,9 +21,7 @@ class { 'udev': udev_log => 'debug' }
}
EOS

# Run it twice and test for idempotency
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
apply2(pp)
end
end

Expand Down
57 changes: 39 additions & 18 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,57 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'

unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
# This will install the latest available package on el and deb based
# systems fail on windows and osx, and install via gem on other *nixes
foss_opts = {:default_action => 'gem_install'}

if default.is_pe?; then
install_pe;
else
install_puppet(foss_opts);
end

hosts.each do |host|
on hosts, "mkdir -p #{host['distmoduledir']}"
end
# Install Puppet
unless ENV['RS_PROVISION'] == 'no'
ENV['PUPPET_INSTALL_TYPE'] ||= 'agent'
# puppet_install_helper does not understand pessimistic version constraints
# so we are ignoring PUPPET_VERSION. Use PUPPET_INSTALL_VERSION instead.
ENV.delete 'PUPPET_VERSION'
run_puppet_install_helper
end

RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

# Readable test descriptions
c.formatter = :documentation

# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'udev')
hosts.each do |host|
copy_module_to(host, :source => proj_root, :module_name => 'udev')

on host, puppet('module', 'install', 'puppetlabs-stdlib'), {:acceptable_exit_codes => [0, 1]}
on host, puppet('module', 'install', 'stahnma-epel'), {:acceptable_exit_codes => [0, 1]}
end
end
end

def apply(pp, options = {})
if ENV.key?('PUPPET_DEBUG')
options[:debug] = true
end

apply_manifest(pp, options)
end

# Run it twice and test for idempotency
def apply2(pp)
apply(pp, :catch_failures => true)
apply(pp, :catch_changes => true)
end

# probe stolen from:
# https://github.com/camptocamp/puppet-systemd/blob/master/lib/facter/systemd.rb#L26
#
# See these issues for an explination of why this is nessicary rather than
# using fact() from beaker-facter in the DSL:
#
# https://tickets.puppetlabs.com/browse/BKR-1040
# https://tickets.puppetlabs.com/browse/BKR-1041
#
if shell('ps -p 1 -o comm=').stdout =~ /systemd/
$systemd = true
else
$systemd = false
end

0 comments on commit 408f695

Please sign in to comment.