diff --git a/Gemfile b/Gemfile index 3fe7aa3..3cd5087 100644 --- a/Gemfile +++ b/Gemfile @@ -6,18 +6,13 @@ else gem 'puppet', :require => false end -group :development, :test do - gem 'rake' - gem 'puppetlabs_spec_helper' - gem 'puppet-lint' - gem 'puppet-syntax' -end - -group :system do - gem 'rspec-system' - gem 'rspec-system-puppet' - gem 'rspec-system-serverspec' - gem 'serverspec' -end +gem 'rake', :require => false +gem 'puppetlabs_spec_helper', :require => false +gem 'puppet-lint', :require => false +gem 'puppet-syntax', :require => false +gem 'rspec-system', :require => false +gem 'rspec-system-puppet', :require => false +gem 'rspec-system-serverspec', '>= 2.0.1', :require => false +gem 'serverspec', :require => false # vim:ft=ruby diff --git a/manifests/init.pp b/manifests/init.pp index 7365b52..85a2446 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -85,9 +85,11 @@ include wget user { $user: - gid => [$group], + gid => $group, + } + group { $group: + ensure => present, } - group { $group: } $jar_name = "selenium-server-standalone-${version}.jar" diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 5a0ca0a..c9548a2 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -4,9 +4,6 @@ include RSpecSystemPuppet::Helpers -include Serverspec::Helper::RSpecSystem -include Serverspec::Helper::DetectOS - RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) @@ -24,5 +21,8 @@ # Install modules and dependencies puppet_module_install(:source => proj_root, :module_name => 'selenium') shell('puppet module install puppetlabs-stdlib') + shell('puppet module install maestrodev-wget') + shell('puppet module install rodjek-logrotate') + shell('puppet module install puppetlabs-java') end end diff --git a/spec/system/selenium_hub_spec.rb b/spec/system/selenium_hub_spec.rb new file mode 100644 index 0000000..ccc0381 --- /dev/null +++ b/spec/system/selenium_hub_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper_system' + +describe 'selenium::hub class' do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + include java + Class['java'] -> Class['selenium::hub'] + + class { 'selenium::hub': } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + end + + describe file('/etc/init.d/seleniumhub') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + + %w[hub_stdout.log hub_stderr.log].each do |file| + describe file("/opt/selenium/log/#{file}") do + it { should be_file } + it { should be_owned_by 'selenium' } + it { should be_grouped_into 'selenium' } + it { should be_mode 644} + end + end + + describe service('seleniumhub') do + it { should be_running } + it { should be_enabled } + end + + describe port(4444) do + it { should be_listening.with('tcp') } + end +end diff --git a/spec/system/selenium_node_spec.rb b/spec/system/selenium_node_spec.rb new file mode 100644 index 0000000..f921661 --- /dev/null +++ b/spec/system/selenium_node_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper_system' + +describe 'selenium::node class' do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + include java + Class['java'] -> Class['selenium::node'] + + class { 'selenium::node': } + EOS + + # Run it twice and test for idempotency + puppet_apply(pp) do |r| + r.exit_code.should_not == 1 + r.refresh + r.exit_code.should be_zero + end + end + end + + describe file('/etc/init.d/seleniumnode') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + + %w[node_stdout.log node_stderr.log].each do |file| + describe file("/opt/selenium/log/#{file}") do + it { should be_file } + it { should be_owned_by 'selenium' } + it { should be_grouped_into 'selenium' } + it { should be_mode 644} + end + end + + describe service('seleniumnode') do + it { should be_running } + it { should be_enabled } + end + + describe port(5555) do + it { should be_listening.with('tcp') } + end +end diff --git a/spec/system/selenium_spec.rb b/spec/system/selenium_spec.rb index 0516af2..8a07c84 100644 --- a/spec/system/selenium_spec.rb +++ b/spec/system/selenium_spec.rb @@ -1,16 +1,13 @@ require 'spec_helper_system' describe 'selenium class' do - case node.facts['osfamily'] - when 'RedHat', 'Debian' - package_name = 'selenium' - service_name = 'selenium' - end - describe 'running puppet code' do # Using puppet_apply as a helper it 'should work with no errors' do pp = <<-EOS + include java + Class['java'] -> Class['selenium'] + class { 'selenium': } EOS @@ -23,12 +20,30 @@ class { 'selenium': } end end - describe package(package_name) do - it { should be_installed } + %w[/opt/selenium /opt/selenium/jars /opt/selenium/log].each do |file| + describe file(file) do + it { should be_directory } + it { should be_owned_by 'selenium' } + it { should be_grouped_into 'selenium' } + it { should be_mode 755 } + end + end + + describe file('/var/log/selenium') do + it { should be_linked_to '/opt/selenium/log' } + end + + describe file('/opt/selenium/jars/selenium-server-standalone-2.39.0.jar') do + it { should be_file } + it { should be_owned_by 'selenium' } + it { should be_grouped_into 'selenium' } + it { should be_mode 644 } end - describe service(service_name) do - it { should be_running } - it { should be_enabled } + describe file('/etc/logrotate.d/selenium') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 444 } end end