diff --git a/.nodeset.yml b/.nodeset.yml new file mode 100644 index 0000000..cbd0d57 --- /dev/null +++ b/.nodeset.yml @@ -0,0 +1,35 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' + 'sles-11sp1-x64': + nodes: + "main.foo.vm": + prefab: 'sles-11sp1-x64' diff --git a/.travis.yml b/.travis.yml index 9d1c0cc..ad51c64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,32 @@ -language: ruby -rvm: - - 1.8.7 -script: - - "rake lint" - - "rake spec" +--- branches: only: - master +language: ruby +bundler_args: --without development +script: bundle exec rake spec SPEC_OPTS='--format documentation' +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng + - .forge-releng/publish +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 env: - - PUPPET_VERSION=2.7.11 -gemfile: .gemfile + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.2.0" + global: +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" +notifications: + email: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..783e522 --- /dev/null +++ b/Gemfile @@ -0,0 +1,21 @@ +source 'https://rubygems.org' + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-system-puppet', :require => false + gem 'puppet-lint', :require => false + gem 'serverspec', :require => false + gem 'rspec-system-serverspec', :require => false + gem 'pry', :require => false + gem 'vagrant-wrapper', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/Rakefile b/Rakefile index 14f1c24..bb60173 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,2 @@ -require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks' +require 'rspec-system/rake_task' diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb new file mode 100644 index 0000000..bf66a53 --- /dev/null +++ b/spec/spec_helper_system.rb @@ -0,0 +1,25 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' +require 'rspec-system-serverspec/helpers' +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS +include RSpecSystemPuppet::Helpers + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # Install puppet + puppet_install + + # Install modules and dependencies + puppet_module_install(:source => proj_root, :module_name => 'concat') + end +end diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb new file mode 100644 index 0000000..39ac746 --- /dev/null +++ b/spec/system/basic_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper_system' + +# Here we put the more basic fundamental tests, ultra obvious stuff. +describe "basic tests:" do + context 'make sure we have copied the module across' do + # No point diagnosing any more if the module wasn't copied properly + context shell 'ls /etc/puppet/modules/concat' do + its(:stdout) { should =~ /Modulefile/ } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + end +end diff --git a/spec/system/concat_spec.rb b/spec/system/concat_spec.rb new file mode 100644 index 0000000..af360d6 --- /dev/null +++ b/spec/system/concat_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end + + # Test that all the relevant bits exist on disk after it + # concats. + describe file('/var/lib/puppet/concat') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments') do + it { should be_directory } + end + describe file('/var/lib/puppet/concat/_tmp_file/fragments.concat') do + it { should be_file } + end + + end +end diff --git a/spec/system/empty_spec.rb b/spec/system/empty_spec.rb new file mode 100644 index 0000000..83dae01 --- /dev/null +++ b/spec/system/empty_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + force => true, + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should_not contain '1\n2' } + end + end +end diff --git a/spec/system/replace_spec.rb b/spec/system/replace_spec.rb new file mode 100644 index 0000000..7f11e5f --- /dev/null +++ b/spec/system/replace_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper_system' + + +describe 'file should not replace' do + shell('echo "file exists" >> /tmp/file') + context 'should fail' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + replace => false, + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + end +end diff --git a/spec/system/warn_spec.rb b/spec/system/warn_spec.rb new file mode 100644 index 0000000..872058b --- /dev/null +++ b/spec/system/warn_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper_system' + +describe 'basic concat test' do + context 'should run successfully' do + pp=" + concat { '/tmp/file': + owner => root, + group => root, + mode => '0644', + warn => true, + } + + concat::fragment { '1': + target => '/tmp/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/file', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end +end