Skip to content

Commit

Permalink
Merge pull request #4 from jhoblitt/system_tests
Browse files Browse the repository at this point in the history
System tests
  • Loading branch information
Joshua Hoblitt committed Dec 20, 2013
2 parents 9f55770 + 169cfcd commit 89cb5d8
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 29 deletions.
21 changes: 8 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__), '..'))
Expand All @@ -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
47 changes: 47 additions & 0 deletions spec/system/selenium_hub_spec.rb
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions spec/system/selenium_node_spec.rb
Original file line number Diff line number Diff line change
@@ -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
37 changes: 26 additions & 11 deletions spec/system/selenium_spec.rb
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit 89cb5d8

Please sign in to comment.