From ce665cceff729e5c047626795aee5ae59824e814 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Sat, 6 Apr 2013 03:29:15 +0100 Subject: [PATCH] Moved some of the puppet setup stuff in system tests to rspec-system-puppet Signed-off-by: Ken Barber --- Gemfile | 2 +- spec/spec_helper_system.rb | 44 ++++++-------------------------------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/Gemfile b/Gemfile index 5ff9461..405a51c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false - gem 'rspec-system' + gem 'rspec-system-puppet' end if puppetversion = ENV['PUPPET_GEM_VERSION'] diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index f4b91e3..47bf9e7 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -1,6 +1,7 @@ # This helper file is specific to the system tests for puppetlabs-firewall # and should be included by all tests under spec/system require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' RSpec.configure do |c| # Project root for the firewall code @@ -8,44 +9,13 @@ RSpec.configure do |c| # This is where we 'setup' the nodes before running our tests c.system_setup_block = proc do - # TODO: find a better way of importing these into this namespace - include RSpecSystem::Helpers - include RSpecSystem::Log + # TODO: find a better way of importing this into this namespace + include RSpecSystemPuppet::Helpers - # TODO: this setup stuff is fairly generic, should move this into a plugin - # for rspec-system. + # Install puppet + system_puppet_install - # Grab facts from node - facts = system_node.facts - - # Remove annoying mesg n from profile, otherwise on Debian we get: - # stdin: is not a tty which messes with our tests later on. - if facts['osfamily'] == 'Debian' - log.info("Remove 'mesg n' from profile to stop noise") - system_run("sed -i 's/^mesg n/# mesg n/' /root/.profile") - end - - # Grab PL repository and install PL copy of puppet - log.info "Starting installation of puppet from PL repos" - if facts['osfamily'] == 'RedHat' - system_run('rpm -ivh http://yum.puppetlabs.com/el/5/products/i386/puppetlabs-release-5-6.noarch.rpm') - system_run('yum install -y puppet') - elsif facts['osfamily'] == 'Debian' - system_run("wget http://apt.puppetlabs.com/puppetlabs-release-#{facts['lsbdistcodename']}.deb") - system_run("dpkg -i puppetlabs-release-#{facts['lsbdistcodename']}.deb") - system_run('apt-get update') - system_run('apt-get install -y puppet') - end - - # Prep modules dir - log.info("Preparing modules dir") - system_run('mkdir -p /etc/puppet/modules') - - # Copy the current code into appropriate module dir - # TODO: we could always use the build process, copy tarball across etc. - # just a shame the puppet module tool doesn't handle standalone tarballs - # yet. - log.info("Now transferring module onto node") - system_rcp(:sp => proj_root, :dp => '/etc/puppet/modules/firewall') + # Copy this module into the module path of the test node + system_puppet_module_from_path(:source => proj_root, :module_name => 'firewall') end end -- 2.45.2