-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert class selenium::config into a define
This is to allow selenium::config to create multiple init.d scripts in the future for selenium hub and grid nodes.
- Loading branch information
Joshua Hoblitt
committed
Oct 2, 2013
1 parent
d742263
commit 50e63e6
Showing
8 changed files
with
158 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# == Class: selenium::config | ||
# == Define: selenium::config | ||
# | ||
# This class should be considered private. | ||
# This define should be considered private. | ||
# | ||
# Note that selenium::params && selnenium::install must be included in the | ||
# manifest before this define may be used. | ||
# | ||
# === Parameters | ||
# | ||
|
@@ -10,20 +12,34 @@ | |
# | ||
# === Examples | ||
# | ||
# class{ 'selenium::config': } | ||
# selenium::config{ 'seleniumstandalone': } | ||
# | ||
# | ||
# === Authors | ||
# | ||
# Joshua Hoblitt <[email protected]> | ||
# | ||
# | ||
class selenium::config { | ||
define selenium::config( | ||
$display = $selenium::params::display, | ||
$user = $selenium::params::user, | ||
$group = $selenium::params::group, | ||
$install_root = $selenium::params::install_root, | ||
$options = $selenium::params::default_options, | ||
$java = $selenium::params::java, | ||
$jar_name = $selenium::install::jar_name, | ||
) { | ||
validate_string($display) | ||
validate_string($user) | ||
validate_string($group) | ||
validate_string($install_root) | ||
validate_string($options) | ||
validate_string($java) | ||
|
||
$options = '-Dwebdriver.enable.native.events=1' | ||
$prog = 'selenium' | ||
# prog is the 'name' of the init.d script. | ||
$prog = $name | ||
|
||
file { '/etc/init.d/selenium': | ||
file { "/etc/init.d/${prog}": | ||
ensure => 'file', | ||
owner => 'root', | ||
group => 'root', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require 'spec_helper' | ||
|
||
describe 'selenium::config', :type => :define do | ||
let(:title) { 'seleniumstandalone' } | ||
|
||
shared_examples 'config' do |params| | ||
let :pre_condition do | ||
"include selenium::params, selenium::install" | ||
end | ||
|
||
p = { | ||
:display => ':0', | ||
:user => 'selenium', | ||
:install_root => '/opt/selenium', | ||
:jar_name => 'selenium-server-standalone-2.35.0.jar', | ||
:options => '-Dwebdriver.enable.native.events=1', | ||
:java => 'java', | ||
} | ||
|
||
if params | ||
p.merge!(params) | ||
end | ||
|
||
it do | ||
should contain_file("/etc/init.d/#{title}").with({ | ||
'ensure' => 'file', | ||
'owner' => 'root', | ||
'group' => 'root', | ||
'mode' => '0755', | ||
}). | ||
with_content(/# #{title} Selenium server init script/). | ||
with_content(/SLNM_DISPLAY='#{p[:display]}'/). | ||
with_content(/SLNM_USER='#{p[:user]}'/). | ||
with_content(/SLNM_INSTALL_ROOT='#{p[:install_root]}'/). | ||
with_content(/SLNM_JAR_NAME='#{p[:jar_name]}'/). | ||
with_content(/SLNM_OPTIONS='#{p[:options]}'/). | ||
with_content(/SLNM_JAVA='#{p[:java]}'/). | ||
with_content(/prog='#{title}'/) | ||
end | ||
end | ||
|
||
context 'for osfamily RedHat' do | ||
let(:facts) {{ :osfamily => 'RedHat' }} | ||
|
||
context 'no params' do | ||
it_behaves_like 'config', {} | ||
end | ||
|
||
context 'all params' do | ||
params = { | ||
:display => 'X:0', | ||
:user => 'Xselenium', | ||
:install_root => 'X/opt/selenium', | ||
:jar_name => 'Xselenium-server-standalone-2.35.0.jar', | ||
:options => 'X-Dwebdriver.enable.native.events=1', | ||
:java => 'Xjava', | ||
} | ||
|
||
let(:params) { params } | ||
|
||
it_behaves_like 'config', params | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters