Skip to content

Commit 8523e66

Browse files
author
Joshua Hoblitt
committed
rename class selenium::install -> selenium and refactor it as common base
1 parent 50e63e6 commit 8523e66

File tree

8 files changed

+197
-170
lines changed

8 files changed

+197
-170
lines changed

manifests/config.pp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@
2525
$user = $selenium::params::user,
2626
$group = $selenium::params::group,
2727
$install_root = $selenium::params::install_root,
28-
$options = $selenium::params::default_options,
28+
$options = $selenium::params::server_options,
2929
$java = $selenium::params::java,
30-
$jar_name = $selenium::install::jar_name,
30+
$jar_name = $selenium::jar_name,
3131
) {
3232
validate_string($display)
3333
validate_string($user)
3434
validate_string($group)
3535
validate_string($install_root)
3636
validate_string($options)
3737
validate_string($java)
38+
validate_string($jar_name)
3839

3940
# prog is the 'name' of the init.d script.
40-
$prog = $name
41+
$prog = $name
4142

4243
file { "/etc/init.d/${prog}":
4344
ensure => 'file',

manifests/install.pp renamed to manifests/init.pp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# == Class: megaraid::lsiget
2-
#
3-
# installs the `lsiget` utility for LSI MegaRAID controllers
4-
#
5-
# See: http://mycusthelp.info/LSI/_cs/AnswerDetail.aspx?inc=8264
1+
# == Class: selenium
62
#
73
#
84
# === Parameters
@@ -12,27 +8,35 @@
128
#
139
# === Examples
1410
#
15-
# class{ 'megaraid::lsiget': }
11+
# class{ 'selenium': }
1612
#
1713
#
1814
# === Authors
1915
#
2016
# Joshua Hoblitt <[email protected]>
2117
#
2218
#
23-
class selenium::install(
24-
$version = '2.35.0',
25-
$url = undef,
26-
) {
19+
class selenium(
20+
$user = $selenium::params::user,
21+
$group = $selenium::params::group,
22+
$install_root = $selenium::params::install_root,
23+
$java = $selenium::params::java,
24+
$version = $selenium::params::version,
25+
$url = undef,
26+
) inherits selenium::params {
27+
validate_string($user)
28+
validate_string($group)
29+
validate_string($install_root)
30+
validate_string($java)
2731
validate_string($version)
2832
validate_string($url)
2933

3034
include wget
3135

32-
user { $selenium::server::user:
33-
gid => [$selenium::server::group],
36+
user { $user:
37+
gid => [$group],
3438
}
35-
group { $selenium::server::group: }
39+
group { $group: }
3640

3741
$jar_name = "selenium-server-standalone-${version}.jar"
3842

@@ -43,16 +47,16 @@
4347
}
4448

4549
File {
46-
owner => $selenium::server::user,
47-
group => $selenium::server::group,
50+
owner => $user,
51+
group => $group,
4852
}
4953

50-
file { $selenium::server::install_root:
54+
file { $install_root:
5155
ensure => directory,
5256
}
5357

54-
$jar_path = "${selenium::server::install_root}/jars"
55-
$log_path = "${selenium::server::install_root}/log"
58+
$jar_path = "${install_root}/jars"
59+
$log_path = "${install_root}/log"
5660

5761
file { $jar_path:
5862
ensure => directory,
@@ -73,7 +77,7 @@
7377
source => $jar_url,
7478
destination => "${jar_path}/${jar_name}",
7579
timeout => 90,
76-
execuser => $selenium::server::user,
80+
execuser => $user,
7781
require => File[$jar_path],
7882
}
7983

manifests/params.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
$user = 'selenium'
99
$group = $user
1010
$install_root = '/opt/selenium'
11-
$default_options = '-Dwebdriver.enable.native.events=1'
11+
$server_options = '-Dwebdriver.enable.native.events=1'
12+
$hub_options = '-role hub'
1213
$java = 'java'
14+
$version = '2.35.0'
1315

1416
case $::osfamily {
1517
'redhat': {}

manifests/server.pp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,21 @@
88
#
99
class selenium::server(
1010
$display = $selenium::params::display,
11-
$user = $selenium::params::user,
12-
$group = $selenium::params::group,
13-
$install_root = $selenium::params::install_root,
14-
$options = $selenium::params::default_options,
15-
$java = $selenium::params::java,
11+
$options = $selenium::params::server_options,
1612
) inherits selenium::params {
1713
validate_string($display)
18-
validate_string($user)
19-
validate_string($group)
20-
validate_string($install_root)
2114
validate_string($options)
22-
validate_string($java)
2315

24-
class { 'selenium::install': } ->
16+
include selenium
17+
18+
Class[ 'selenium' ] ->
2519
selenium::config{ 'seleniumstandalone':
2620
display => $display,
27-
user => $user,
28-
group => $group,
29-
install_root => $install_root,
30-
java => $java,
21+
user => $selenium::user,
22+
group => $selenium::group,
23+
install_root => $selenium::install_root,
24+
options => $options,
25+
java => $selenium::java,
3126
} ->
3227
class { 'selenium::service': } ->
3328
Class[ 'selenium::server' ]

spec/classes/selenium_install_spec.rb

Lines changed: 0 additions & 46 deletions
This file was deleted.

spec/classes/selenium_server_spec.rb

Lines changed: 21 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,37 @@
22

33
describe 'selenium::server', :type => :class do
44

5-
shared_examples 'server' do |user, group|
5+
shared_examples 'server' do |params|
6+
p = {
7+
:display => ':0',
8+
:options => '-Dwebdriver.enable.native.events=1',
9+
}
10+
11+
p.merge!(params) if params
12+
613
it do
7-
should contain_class('selenium::server')
8-
should contain_class('selenium::install')
9-
should contain_file('/etc/init.d/seleniumstandalone')
14+
should include_class('selenium')
15+
should contain_selenium__config('seleniumstandalone').with({
16+
'display' => p[:display],
17+
'options' => p[:options],
18+
})
1019
should contain_class('selenium::service')
11-
should contain_user(user).with_gid(group)
12-
should contain_group(group)
20+
should contain_class('selenium::server')
1321
end
1422
end
1523

1624
context 'for osfamily RedHat' do
1725
let(:facts) {{ :osfamily => 'RedHat' }}
1826

1927
context 'no params' do
20-
it_behaves_like 'server', 'selenium', 'selenium'
28+
it_behaves_like 'server', {}
2129
end
2230

2331
context 'display => :42' do
24-
let(:params) {{ :display => ':42' }}
32+
p = { :display => ':42' }
33+
let(:params) { p }
2534

26-
it_behaves_like 'server', 'selenium', 'selenium'
35+
it_behaves_like 'server', p
2736
end
2837

2938
context 'display => :42' do
@@ -36,66 +45,11 @@
3645
end
3746
end
3847

39-
context 'user => foo' do
40-
let(:params) {{ :user => 'foo' }}
41-
42-
it_behaves_like 'server', 'foo', 'selenium'
43-
end
44-
45-
context 'user => []' do
46-
let(:params) {{ :user => [] }}
47-
48-
it 'should fail' do
49-
expect {
50-
should contain_class('selenium::server')
51-
}.to raise_error
52-
end
53-
end
54-
55-
context 'group => foo' do
56-
let(:params) {{ :group => 'foo' }}
57-
58-
it_behaves_like 'server', 'selenium', 'foo'
59-
end
60-
61-
context 'group => []' do
62-
let(:params) {{ :group => [] }}
63-
64-
it 'should fail' do
65-
expect {
66-
should contain_class('selenium::server')
67-
}.to raise_error
68-
end
69-
end
70-
71-
context 'install_root => /foo/selenium' do
72-
let(:params) {{ :install_root => '/foo/selenium' }}
73-
74-
it_behaves_like 'server', 'selenium', 'selenium'
75-
76-
it do
77-
should contain_file('/foo/selenium').with({
78-
'ensure' => 'directory',
79-
'owner' => 'selenium',
80-
'group' => 'selenium',
81-
})
82-
end
83-
end
84-
85-
context 'install_root => []' do
86-
let(:params) {{ :install_root => [] }}
87-
88-
it 'should fail' do
89-
expect {
90-
should contain_class('selenium::server')
91-
}.to raise_error
92-
end
93-
end
94-
9548
context 'options => -foo' do
96-
let(:params) {{ :options => '-foo' }}
49+
p = { :options => '-foo' }
50+
let(:params) { p }
9751

98-
it_behaves_like 'server', 'selenium', 'selenium'
52+
it_behaves_like 'server', p
9953
end
10054

10155
context 'options => []' do
@@ -107,22 +61,6 @@
10761
}.to raise_error
10862
end
10963
end
110-
111-
context 'java => /opt/java' do
112-
let(:params) {{ :java => '/opt/java' }}
113-
114-
it_behaves_like 'server', 'selenium', 'selenium'
115-
end
116-
117-
context 'java => []' do
118-
let(:params) {{ :java => [] }}
119-
120-
it 'should fail' do
121-
expect {
122-
should contain_class('selenium::server')
123-
}.to raise_error
124-
end
125-
end
12664
end
12765

12866
end

0 commit comments

Comments
 (0)