Skip to content

Commit 89cb5d8

Browse files
author
Joshua Hoblitt
committed
Merge pull request jhoblitt#4 from jhoblitt/system_tests
System tests
2 parents 9f55770 + 169cfcd commit 89cb5d8

File tree

6 files changed

+135
-29
lines changed

6 files changed

+135
-29
lines changed

Gemfile

+8-13
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ else
66
gem 'puppet', :require => false
77
end
88

9-
group :development, :test do
10-
gem 'rake'
11-
gem 'puppetlabs_spec_helper'
12-
gem 'puppet-lint'
13-
gem 'puppet-syntax'
14-
end
15-
16-
group :system do
17-
gem 'rspec-system'
18-
gem 'rspec-system-puppet'
19-
gem 'rspec-system-serverspec'
20-
gem 'serverspec'
21-
end
9+
gem 'rake', :require => false
10+
gem 'puppetlabs_spec_helper', :require => false
11+
gem 'puppet-lint', :require => false
12+
gem 'puppet-syntax', :require => false
13+
gem 'rspec-system', :require => false
14+
gem 'rspec-system-puppet', :require => false
15+
gem 'rspec-system-serverspec', '>= 2.0.1', :require => false
16+
gem 'serverspec', :require => false
2217

2318
# vim:ft=ruby

manifests/init.pp

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@
8585
include wget
8686

8787
user { $user:
88-
gid => [$group],
88+
gid => $group,
89+
}
90+
group { $group:
91+
ensure => present,
8992
}
90-
group { $group: }
9193

9294
$jar_name = "selenium-server-standalone-${version}.jar"
9395

spec/spec_helper_system.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
include RSpecSystemPuppet::Helpers
66

7-
include Serverspec::Helper::RSpecSystem
8-
include Serverspec::Helper::DetectOS
9-
107
RSpec.configure do |c|
118
# Project root
129
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
@@ -24,5 +21,8 @@
2421
# Install modules and dependencies
2522
puppet_module_install(:source => proj_root, :module_name => 'selenium')
2623
shell('puppet module install puppetlabs-stdlib')
24+
shell('puppet module install maestrodev-wget')
25+
shell('puppet module install rodjek-logrotate')
26+
shell('puppet module install puppetlabs-java')
2727
end
2828
end

spec/system/selenium_hub_spec.rb

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require 'spec_helper_system'
2+
3+
describe 'selenium::hub class' do
4+
describe 'running puppet code' do
5+
# Using puppet_apply as a helper
6+
it 'should work with no errors' do
7+
pp = <<-EOS
8+
include java
9+
Class['java'] -> Class['selenium::hub']
10+
11+
class { 'selenium::hub': }
12+
EOS
13+
14+
# Run it twice and test for idempotency
15+
puppet_apply(pp) do |r|
16+
r.exit_code.should_not == 1
17+
r.refresh
18+
r.exit_code.should be_zero
19+
end
20+
end
21+
end
22+
23+
describe file('/etc/init.d/seleniumhub') do
24+
it { should be_file }
25+
it { should be_owned_by 'root' }
26+
it { should be_grouped_into 'root' }
27+
it { should be_mode 755 }
28+
end
29+
30+
%w[hub_stdout.log hub_stderr.log].each do |file|
31+
describe file("/opt/selenium/log/#{file}") do
32+
it { should be_file }
33+
it { should be_owned_by 'selenium' }
34+
it { should be_grouped_into 'selenium' }
35+
it { should be_mode 644}
36+
end
37+
end
38+
39+
describe service('seleniumhub') do
40+
it { should be_running }
41+
it { should be_enabled }
42+
end
43+
44+
describe port(4444) do
45+
it { should be_listening.with('tcp') }
46+
end
47+
end

spec/system/selenium_node_spec.rb

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require 'spec_helper_system'
2+
3+
describe 'selenium::node class' do
4+
describe 'running puppet code' do
5+
# Using puppet_apply as a helper
6+
it 'should work with no errors' do
7+
pp = <<-EOS
8+
include java
9+
Class['java'] -> Class['selenium::node']
10+
11+
class { 'selenium::node': }
12+
EOS
13+
14+
# Run it twice and test for idempotency
15+
puppet_apply(pp) do |r|
16+
r.exit_code.should_not == 1
17+
r.refresh
18+
r.exit_code.should be_zero
19+
end
20+
end
21+
end
22+
23+
describe file('/etc/init.d/seleniumnode') do
24+
it { should be_file }
25+
it { should be_owned_by 'root' }
26+
it { should be_grouped_into 'root' }
27+
it { should be_mode 755 }
28+
end
29+
30+
%w[node_stdout.log node_stderr.log].each do |file|
31+
describe file("/opt/selenium/log/#{file}") do
32+
it { should be_file }
33+
it { should be_owned_by 'selenium' }
34+
it { should be_grouped_into 'selenium' }
35+
it { should be_mode 644}
36+
end
37+
end
38+
39+
describe service('seleniumnode') do
40+
it { should be_running }
41+
it { should be_enabled }
42+
end
43+
44+
describe port(5555) do
45+
it { should be_listening.with('tcp') }
46+
end
47+
end

spec/system/selenium_spec.rb

+26-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
require 'spec_helper_system'
22

33
describe 'selenium class' do
4-
case node.facts['osfamily']
5-
when 'RedHat', 'Debian'
6-
package_name = 'selenium'
7-
service_name = 'selenium'
8-
end
9-
104
describe 'running puppet code' do
115
# Using puppet_apply as a helper
126
it 'should work with no errors' do
137
pp = <<-EOS
8+
include java
9+
Class['java'] -> Class['selenium']
10+
1411
class { 'selenium': }
1512
EOS
1613

@@ -23,12 +20,30 @@ class { 'selenium': }
2320
end
2421
end
2522

26-
describe package(package_name) do
27-
it { should be_installed }
23+
%w[/opt/selenium /opt/selenium/jars /opt/selenium/log].each do |file|
24+
describe file(file) do
25+
it { should be_directory }
26+
it { should be_owned_by 'selenium' }
27+
it { should be_grouped_into 'selenium' }
28+
it { should be_mode 755 }
29+
end
30+
end
31+
32+
describe file('/var/log/selenium') do
33+
it { should be_linked_to '/opt/selenium/log' }
34+
end
35+
36+
describe file('/opt/selenium/jars/selenium-server-standalone-2.39.0.jar') do
37+
it { should be_file }
38+
it { should be_owned_by 'selenium' }
39+
it { should be_grouped_into 'selenium' }
40+
it { should be_mode 644 }
2841
end
2942

30-
describe service(service_name) do
31-
it { should be_running }
32-
it { should be_enabled }
43+
describe file('/etc/logrotate.d/selenium') do
44+
it { should be_file }
45+
it { should be_owned_by 'root' }
46+
it { should be_grouped_into 'root' }
47+
it { should be_mode 444 }
3348
end
3449
end

0 commit comments

Comments
 (0)