diff options
author | Ewoud Kohl van Wijngaarden <e.kohlvanwijngaarden@oxilion.nl> | 2013-07-02 19:22:35 +0200 |
---|---|---|
committer | Ewoud Kohl van Wijngaarden <e.kohlvanwijngaarden@oxilion.nl> | 2013-07-02 19:24:27 +0200 |
commit | 42488b04b47ec3fd87f1d45ec3fa90b588545ca1 (patch) | |
tree | c6776e08e8e7a5398f84a0563d5a229dd8dc6171 | |
parent | aaf55c9ebfa0e34f63b2ca3c2b660e1d164026dd (diff) |
Add basic testing infrastructure
-rw-r--r-- | .fixtures.yml | 8 | ||||
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | .travis.yml | 18 | ||||
-rw-r--r-- | Gemfile | 11 | ||||
-rw-r--r-- | Rakefile | 9 | ||||
-rw-r--r-- | spec/classes/munin_client_spec.rb | 14 | ||||
-rw-r--r-- | spec/classes/munin_host_spec.rb | 14 | ||||
-rw-r--r-- | spec/classes/munin_plugins_interfaces_spec.rb | 44 | ||||
-rw-r--r-- | spec/spec.opts | 1 | ||||
-rw-r--r-- | spec/spec_helper.rb | 9 |
10 files changed, 131 insertions, 0 deletions
diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..e05b8fd --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,8 @@ +fixtures: + repositories: + concat: "https://github.com/puppetlabs/puppetlabs-concat" + openbsd: "https://github.com/duritong/puppet-openbsd" + stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib" + + symlinks: + munin: "#{source_dir}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ce4053 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Gemfile.lock +spec/fixtures/ +vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3e66a86 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + - PUPPET_VERSION=2.6.0 + - PUPPET_VERSION=2.7.0 + - PUPPET_VERSION=3.2.0 +matrix: + exclude: + # No support for Ruby 1.9 before Puppet 2.7 + - rvm: 1.9.3 + env: PUPPET_VERSION=2.6.0 + # No support for Ruby 2.0 before Puppet 3.2 + - rvm: 2.0.0 + env: PUPPET_VERSION=2.6.0 + - rvm: 2.0.0 + env: PUPPET_VERSION=2.7.0 @@ -0,0 +1,11 @@ +source 'https://rubygems.org' + +if ENV.key?('PUPPET_VERSION') + puppetversion = "~> #{ENV['PUPPET_VERSION']}" +else + puppetversion = ['>= 2.6'] +end + +gem 'puppet', puppetversion +gem 'puppet-lint', '>=0.3.2' +gem 'puppetlabs_spec_helper', '>=0.2.0' diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..0d1f018 --- /dev/null +++ b/Rakefile @@ -0,0 +1,9 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"] +PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}' +PuppetLint.configuration.send("disable_class_inherits_from_params_class") +PuppetLint.configuration.send("disable_80chars") + +task :default => [:spec, :lint] diff --git a/spec/classes/munin_client_spec.rb b/spec/classes/munin_client_spec.rb new file mode 100644 index 0000000..5438b20 --- /dev/null +++ b/spec/classes/munin_client_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'munin::client' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0', + } + end + + it 'should compile' do + should include_class('munin::client') + end +end diff --git a/spec/classes/munin_host_spec.rb b/spec/classes/munin_host_spec.rb new file mode 100644 index 0000000..2216cc5 --- /dev/null +++ b/spec/classes/munin_host_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'munin::host' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0', + } + end + + it 'should compile' do + should include_class('munin::host') + end +end diff --git a/spec/classes/munin_plugins_interfaces_spec.rb b/spec/classes/munin_plugins_interfaces_spec.rb new file mode 100644 index 0000000..95aa785 --- /dev/null +++ b/spec/classes/munin_plugins_interfaces_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe 'munin::plugins::interfaces' do + context 'on CentOS' do + let :facts do + { + :operatingsystem => 'CentOS', + :interfaces => 'lo,eth0,sit0', + } + end + + it 'should compile' do + should include_class('munin::plugins::interfaces') + end + + it 'should create plugins for each interface' do + # lo + should contain_munin__plugin('if_lo').with_ensure('if_') + should contain_munin__plugin('if_err_lo').with_ensure('if_err_') + + # eth0 + should contain_munin__plugin('if_eth0').with_ensure('if_') + should contain_munin__plugin('if_err_eth0').with_ensure('if_err_') + end + + it 'should not create plugins for sit0' do + should_not contain_munin__plugin('if_sit0') + should_not contain_munin__plugin('if_err_sit0') + end + end + + context 'on OpenBSD' do + let :facts do + { + :operatingsystem => 'OpenBSD', + :interfaces => 'eth0', + } + end + + it 'should use if_errcoll_ instead of if_err_' do + should contain_munin__plugin('if_errcoll_eth0').with_ensure('if_errcoll_') + end + end +end diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..d1bd681 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1 @@ +--format documentation --colour --backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..cffe80c --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require 'puppetlabs_spec_helper/module_spec_helper' + +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +RSpec.configure do |c| + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') + c.mock_with :mocha +end |