Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tests #4

Merged
merged 2 commits into from
Dec 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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