Skip to content

Commit

Permalink
add $display param to class selenium::server
Browse files Browse the repository at this point in the history
Selects the X display to use
  • Loading branch information
Joshua Hoblitt committed Oct 1, 2013
1 parent 68d1861 commit 45e77c2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 15 deletions.
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
#
class selenium::params {
$display = ':0'
$user = 'selenium'
$group = $user
$install_path = '/opt/selenium'
Expand Down
2 changes: 2 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# include selenium::server
#
class selenium::server(
$display = $selenium::params::display,
$user = $selenium::params::user,
$group = $selenium::params::group,
$install_path = $selenium::params::install_path,
) inherits selenium::params {
validate_string($display)
validate_string($user)
validate_string($group)
validate_string($install_path)
Expand Down
26 changes: 18 additions & 8 deletions spec/classes/selenium_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
require 'spec_helper'

describe 'selenium::config' do
describe 'selenium::config', :type => :class do
let(:title) { 'redhat' }
let(:facts) {{ :osfamily=> 'RedHat' }}
let :pre_condition do
"class { 'selenium::server': display => 'foo' }"
end

it do
should contain_file('/etc/init.d/selenium').with({
'ensure' => 'file',
'owner' => 'root',
'group' => 'root',
'mode' => '0755',
}).with_content(/selenium-server-standalone/)
context 'no params' do
it do
should contain_class('selenium::config')
should contain_file('/etc/init.d/selenium').with({
'ensure' => 'file',
'owner' => 'root',
'group' => 'root',
'mode' => '0755',
}).
with_content(/selenium-server-standalone/).
with_content(/SLNM_INSTALL_PATH=\/opt\/selenium/)
with_content(/SLNM_DISPLAY=:0/)
with_content(/SLNM_USER=selenium/)
end
end

end
16 changes: 16 additions & 0 deletions spec/classes/selenium_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@
it_behaves_like 'server', 'selenium', 'selenium'
end

context 'display => :42' do
let(:params) {{ :display => ':42' }}

it_behaves_like 'server', 'selenium', 'selenium'
end

context 'display => :42' do
let(:params) {{ :display => [] }}

it 'should fail' do
expect {
should contain_class('selenium::server')
}.to raise_error
end
end

context 'user => foo' do
let(:params) {{ :user => 'foo' }}

Expand Down
13 changes: 6 additions & 7 deletions templates/init.d/selenium.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
# Source function library.
. /etc/rc.d/init.d/functions

#SLNM_DISPLAY=:<%= scope.lookupvar('display::display') %>
SLNM_DISPLAY=:0
#SLNM_USER=<%= @user %>
SLNM_USER='selenium'
SLNM_LOG='/opt/selenium/log/server.log'
SLNM_ERROR_LOG='/opt/selenium/log/error.log'
SLNM_JAR='/opt/selenium/jars/selenium-server-standalone-2.35.0.jar'
SLNM_INSTALL_PATH=<% scope.lookupvar('selenium::server::install_path') %>
SLNM_DISPLAY=<% scope.lookupvar('selenium::server::display') %>
SLNM_USER=<%= scope.lookupvar('selenium::server::user') %>
SLNM_LOG="${SLNM_INSTALL_PATH}/log/server.log"
SLNM_ERROR_LOG="${SLNM_INSTALL_PATH}/log/error.log"
SLNM_JAR="${SLNM_INSTALL_PATH}/opt/selenium/jars/selenium-server-standalone-2.35.0.jar"
SLNM_OPTIONS='-Dwebdriver.enable.native.events=1'

prog="selenium"
Expand Down

0 comments on commit 45e77c2

Please sign in to comment.