diff --git a/.gitignore b/.gitignore index c804f809..6abdd115 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.swo *.swn pkg/ +.vagrant/ diff --git a/Gemfile b/Gemfile index 53046ca5..9f354f29 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,14 @@ source 'https://rubygems.org' group :development, :test do + gem 'rake', '10.1.1', :require => false + gem 'rspec-puppet', :require => false gem 'puppet-syntax' - gem 'puppetlabs_spec_helper' + gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint' gem 'puppet' + gem 'beaker', :require => false + gem 'beaker-rspec', '2.2.4', :require => false + gem 'serverspec', :require => false + gem 'pry', :require => false end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..5f72ddf4 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,163 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.2.8) + addressable (2.3.6) + archive-tar-minitar (0.5.2) + autoparse (0.3.3) + addressable (>= 2.3.1) + extlib (>= 0.9.15) + multi_json (>= 1.0.0) + aws-sdk (1.42.0) + json (~> 1.4) + nokogiri (>= 1.4.4) + beaker (1.12.1) + aws-sdk (~> 1.38) + blimpy (~> 0.6) + docker-api + fission (~> 0.4) + google-api-client (~> 0.7.1) + inifile (~> 2.0) + json (~> 1.8) + mime-types (~> 1.25) + net-scp (~> 1.1) + net-ssh (~> 2.6) + nokogiri (= 1.5.10) + rbvmomi (= 1.8.1) + unf (~> 0.1) + beaker-rspec (2.2.4) + beaker (~> 1.10) + rspec (~> 2.14) + serverspec (~> 1.0) + specinfra (~> 1.0) + blimpy (0.6.7) + fog + minitar + thor + builder (3.2.2) + coderay (1.1.0) + diff-lcs (1.2.5) + docker-api (1.11.1) + archive-tar-minitar + excon (>= 0.34.0) + json + excon (0.36.0) + extlib (0.9.16) + facter (2.0.1) + CFPropertyList (~> 2.2.6) + faraday (0.9.0) + multipart-post (>= 1.2, < 3) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.11.1) + builder + excon (~> 0.20) + formatador (~> 0.2.0) + json (~> 1.7) + mime-types + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + nokogiri (~> 1.5.0) + ruby-hmac + formatador (0.2.5) + google-api-client (0.7.1) + addressable (>= 2.3.2) + autoparse (>= 0.3.3) + extlib (>= 0.9.15) + faraday (>= 0.9.0) + jwt (>= 0.1.5) + launchy (>= 2.1.1) + multi_json (>= 1.0.0) + retriable (>= 1.4) + signet (>= 0.5.0) + uuidtools (>= 2.1.0) + hiera (1.3.3) + json_pure + highline (1.6.21) + inifile (2.0.2) + json (1.8.1) + json_pure (1.8.1) + jwt (1.0.0) + launchy (2.4.2) + addressable (~> 2.3) + metaclass (0.0.4) + method_source (0.8.2) + mime-types (1.25.1) + minitar (0.5.4) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.10.1) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) + nokogiri (1.5.10) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + puppet (3.6.1) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + rgen (~> 0.6.5) + puppet-lint (0.3.2) + puppet-syntax (1.2.0) + puppet (>= 2.7.0) + rake + puppetlabs_spec_helper (0.4.1) + mocha (>= 0.10.5) + rake + rspec (>= 2.9.0) + rspec-puppet (>= 0.1.1) + rake (10.1.1) + rbvmomi (1.8.1) + builder + nokogiri (>= 1.4.1) + trollop + retriable (1.4.1) + rgen (0.6.6) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.0) + rspec-expectations (2.99.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.99.0) + rspec-puppet (1.0.1) + rspec + ruby-hmac (0.4.0) + serverspec (1.7.0) + highline + net-ssh + rspec (~> 2.13) + specinfra (~> 1.13) + signet (0.5.0) + addressable (>= 2.2.3) + faraday (>= 0.9.0.rc5) + jwt (>= 0.1.5) + multi_json (>= 1.0.0) + slop (3.5.0) + specinfra (1.15.0) + thor (0.19.1) + trollop (2.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.6) + uuidtools (2.1.4) + +PLATFORMS + ruby + +DEPENDENCIES + beaker + beaker-rspec (= 2.2.4) + pry + puppet + puppet-lint + puppet-syntax + puppetlabs_spec_helper + rake (= 10.1.1) + rspec-puppet + serverspec diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb new file mode 100644 index 00000000..628b7909 --- /dev/null +++ b/spec/acceptance/class_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper_acceptance' +require 'pry' + +describe 'puppetboard class' do + + context 'default parameters' do + hosts.each do |host| + if fact('osfamily') == 'RedHat' + if fact('architecture') == 'amd64' + on host, "wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm; rpm -ivh epel-release-6-8.noarch.rpm" + else + on host, "wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm; rpm -ivh epel-release-6-8.noarch.rpm" + end + end + on host, "puppet module install puppetlabs/apache" + install_package host, 'python-virtualenv' + install_package host, 'git' + end + + it 'should work with no errors' do + pp = " class { 'puppetboard': } " + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + + #it 'should not answer to localhost' do + # shell("/usr/bin/curl localhost:80", :acceptable_exit_codes => 7) do |r| + # r.exit_code.should == 7 # curl (7): Couldn't connect to host + # end + #end + + end + + context 'default parameters' do + hosts.each do |host| + if fact('osfamily') == 'RedHat' + if fact('architecture') == 'amd64' + on host, "wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm; rpm -ivh epel-release-6-8.noarch.rpm" + else + on host, "wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm; rpm -ivh epel-release-6-8.noarch.rpm" + end + end + on host, "puppet module install puppetlabs/apache" + install_package host, 'python-virtualenv' + install_package host, 'git' + end + + it 'should work with no errors' do + pp= <<-EOS + # Configure Apache on this server + class { 'apache': + default_vhost => false, + purge_configs => true, + } + class { 'apache::mod::wsgi': } + + # Configure Puppetboard + class { 'puppetboard': } + + # Access Puppetboard through pboard.example.com + class { 'puppetboard::apache::vhost': + vhost_name => 'pboard.example.com', + } + EOS + + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + + #binding.pry + + it 'should answer to localhost' do + shell("/usr/bin/curl localhost:5000") do |r| + r.stdout.should =~ /niele Sluijters/ + r.exit_code.should == 0 + end + end + end +end diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 00000000..05540ed8 --- /dev/null +++ b/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml new file mode 100644 index 00000000..d065b304 --- /dev/null +++ b/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 00000000..d3abf2c4 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,27 @@ +require 'beaker-rspec' + +hosts.each do |host| + # Install Puppet + install_package host, 'rubygems' + on host, 'gem install puppet --no-ri --no-rdoc' + on host, "mkdir -p #{host['distmoduledir']}" +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 + puppet_module_install(:source => proj_root, :module_name => 'puppetboard') + hosts.each do |host| + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','stankevich-python'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-vcsrepo'), { :acceptable_exit_codes => [0,1] } + end + end +end