Skip to content

Commit

Permalink
Merge pull request #32 from dhoer/4.0
Browse files Browse the repository at this point in the history
4.0
  • Loading branch information
dhoer authored Feb 5, 2017
2 parents ff84243 + 39a3f3d commit 68dddc6
Show file tree
Hide file tree
Showing 24 changed files with 328 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MethodLength:
Max: 40

AbcSize:
Max: 25
Max: 40

BlockLength:
Enabled: false
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: ruby

sudo: required

# install the pre-release chef-dk. Use chef-stable-precise to install the stable release
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 4.0.0 2017-

- Support Selenium 3.0
- Log defaults to STDOUT when log attribute is nil
- Drop support for Chef 11

## 3.7.4 2016-10-29
Expand Down
196 changes: 131 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ browsers, drivers, and screenresolution cookbooks into one comprehensive cookboo
## Requirements

- Java (not installed by this cookbook)
- Chef 11.16+
- Chef 12.6+

### Platforms

Expand All @@ -41,9 +41,10 @@ browsers, drivers, and screenresolution cookbooks into one comprehensive cookboo

### Cookbooks

- windows
- nssm - Required by Windows services only (e.g. Hub and HtmlUnit running in background)
- macosx_autologin - Required by Mac OS X GUI services
- windows
- windows_autologin - Required by Windows GUI service

## Recipes

Expand All @@ -66,57 +67,30 @@ Installs and configures a Selenium Hub as a service.

### Attributes

- `node['selenium']['hub']['servicename']` - The name of the service. Default `selenium_hub`.
- `node['selenium']['hub']['host']` - Default `null`.
- `node['selenium']['hub']['port']` - Default `4444`.
- `node['selenium']['hub']['jvm_args']` - Default `nil`.
- `node['selenium']['hub']['newSessionWaitTimeout']` - Default `-1`.
- `node['selenium']['hub']['servlets']` - Default `[]`.
- `node['selenium']['hub']['prioritizer']` - Default `null`.
- `node['selenium']['hub']['capabilityMatcher']` - Default `org.openqa.grid.internal.utils.DefaultCapabilityMatcher`.
- `node['selenium']['hub']['throwOnCapabilityNotPresent']` - Default `true`.
- `node['selenium']['hub']['nodePolling']` - Default `5000`.
- `node['selenium']['hub']['cleanUpCycle']` - Default `5000`.
- `node['selenium']['hub']['timeout']` - Default `30_000`.
- `node['selenium']['hub']['browserTimeout']` - Default `0`.
- `node['selenium']['hub']['maxSession']` - Default `5`.
- `node['selenium']['hub']['jettyMaxThreads']` - Default `-1`.

See [selenium_hub](https://github.com/dhoer/chef-selenium#attributes-3)
resource attributes for description.

## node

Installs and configures a Selenium Node as service on Linux and a GUI service on Mac OS X and Windows.
Installs and configures a Selenium Node as service on Linux and a GUI
service on Mac OS X and Windows.

- Firefox browser must be installed outside of this cookbook.
- Linux nodes without a physical monitor require a headless display
(e.g., [xvfb](https://supermarket.chef.io/cookbooks/xvfb), [x11vnc](https://supermarket.chef.io/cookbooks/x11vnc),
(e.g., [xvfb](https://supermarket.chef.io/cookbooks/xvfb),
[x11vnc](https://supermarket.chef.io/cookbooks/x11vnc),
etc...) and must be installed and configured outside this cookbook.
- Mac OS X/Windows nodes must run as a GUI service and that requires a username
and password for automatic login. Note that Windows password is stored unencrypted under windows registry
`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon` and Mac OS X password is stored encrypted under
`/etc/kcpassword` but it can be easily decrypted.
- Mac OS X/Windows nodes must run as a GUI service and that requires a
username and password for automatic login. Note that Windows password
is stored unencrypted under windows registry
`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon` and
Mac OS X password is stored encrypted under `/etc/kcpassword` but it
can be easily decrypted.

### Attributes

- `node['selenium']['node']['servicename']` - The name of the service. Default `selenium_node`.
- `node['selenium']['node']['host']` - Default `ip`.
- `node['selenium']['node']['port']` - Default `5555`.
- `node['selenium']['node']['jvm_args']` - Default `nil`.
- `node['selenium']['node']['proxy']` - Default `org.openqa.grid.selenium.proxy.DefaultRemoteProxy`.
- `node['selenium']['node']['maxSession']` - Default `5`.
- `node['selenium']['node']['register']` - Default `true`.
- `node['selenium']['node']['registerCycle']` - Default `5000`.
- `node['selenium']['node']['hubPort']` - Selenium-grid hub hostname. Default `4444`.
- `node['selenium']['node']['hubHost']` - Selenium-grid hub port. Default `ip`.
- `node['selenium']['node']['capabilities']` - Based on
[capabilities](https://code.google.com/p/selenium/wiki/DesiredCapabilities). Default `[]`.
- `node['selenium']['node']['additional_args']` - Default `[]`.
- `node['selenium']['node']['display']` - Default `:0`.
- Mac OS X/Windows only - Set both username and password to run as a GUI service:
- `username` - Default `nil`.
- `password` - Default `nil`. Note that Windows password is stored unencrypted under windows registry
`HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon` and Mac OS X password is stored encrypted under
`/etc/kcpassword` but it can be easily decrypted.
- `domain` - Optional for Windows only. Default `nil`.
See [selenium_hub](https://github.com/dhoer/chef-selenium#attributes-4)
resource attributes for description.

### Example

Expand Down Expand Up @@ -151,29 +125,116 @@ Installs and configures a Selenium Hub as a service.

### Attributes

This is a partial list of attributes available. See
[hub](https://github.com/dhoer/chef-selenium/blob/master/resources/hub.rb)
resource for the complete listing of attributes.

- `name` - Name attribute. The name of the service.
- `host` - Hostname. Default `null`.
- `port` - Port. Default `4444`.
- `servicename` - Name attribute. The name of the service.
- `host` - IP or hostname. Usually determined automatically. Most
commonly useful in exotic network configurations (e.g. network with
VPN). Default `nil`.
- `port` - The port number the server will use. Default: `4444`.
- `jvm_args` - JVM options, e.g., -Xms2G -Xmx2G. Default: `nil`.
- `newSessionWaitTimeout` - The time (in ms) after which a new test
waiting for a node to become available will time out. When that happens,
the test will throw an exception before attempting to start a browser.
An unspecified, zero, or negative value means wait indefinitely.
Default: `-1`.
- `prioritizer` - A class implementing the Prioritizer interface.
Specify a custom Prioritizer if you want to sort the order in which new
session requests are processed when there is a queue.
Default to null ( no priority = FIFO ).
- `servlets` - List of extra servlets the grid (hub or node) will make
available. The servlet must exist in the path, e.g.,
/grid/admin/Servlet. Default: `[]`.
- `withoutServlets` - List of default (hub or node) servlets to disable.
Advanced use cases only. Not all default servlets can be disabled.
Default: `[]`.
- `capabilityMatcher` - A class implementing the CapabilityMatcher
interface. Specifies the logic the hub will follow to define whether a
request can be assigned to a node. For example, if you want to have the
matching process use regular expressions instead of exact match when
specifying browser version. ALL nodes of a grid ecosystem would then
use the same capabilityMatcher, as defined here.
Default: `org.openqa.grid.internal.utils.DefaultCapabilityMatcher`
- `throwOnCapabilityNotPresent` - If true, the hub will reject all test
requests if no compatible proxy is currently registered. If set to
false, the request will queue until a node supporting the capability is
registered with the grid. Default: `true`.
- `cleanUpCycle` - Specifies how often the hub will poll (in ms)
running proxies for timed-out (i.e. hung) threads. Must also specify
"timeout" option. Default: `5000`.
- `debug` - Enables LogLevel.FINE. Default: `false`.
- `timeout` - Specifies the timeout before the server automatically
kills a session that hasn't had any activity in the last X seconds.
The test slot will then be released for another test to use. This is
typically used to take care of client crashes. For grid hub/node roles,
cleanUpCycle must also be set. Default: `1800`.
- `browserTimeout` - Number of seconds a browser session is allowed to
hang while a WebDriver command is running (example: driver.get(url)).
If the timeout is reached while a WebDriver command is still processing,
the session will quit. Minimum value is `60`. An unspecified, zero,
or negative value means wait indefinitely. Default: `0`.
- `maxSession` - Max number of tests that can run at the same time on
the node, irrespective of the browser used. Default: `5`.
- `jettyMaxThreads` - Max number of threads for Jetty. An unspecified,
zero, or negative value means the Jetty default value (200) will be
used. Default: `-1`.
- `log` - The filename to use for logging. If omitted, will log to
STDOUT. Default: `nil`.

## selenium_node

Installs and configures a Selenium Node as a service.

### Attributes

This is a partial list of attributes available. See
[node](https://github.com/dhoer/chef-selenium/blob/master/resources/node.rb)
resource for the complete listing of attributes.

- `name` - Name attribute. The name of the service.
- `host` - Hostname. Default `null`.
- `port` - Port. Default `5555`.
- `hubHost` - Selenium-grid hub hostname. Default `ip`.
- `hubPort` - Selenium-grid hub port. Default `4444`.
- `servicename` - Name attribute. The name of the service.
- `host` - IP or hostname. Usually determined automatically. Most
commonly useful in exotic network configurations (e.g. network with
VPN). Default `nil`.
- `port` - The port number the server will use. Default: `5555`.
- `hub` - The url that will be used to post the registration request.
Default: `http://localhost:4444`.
- `jvm_args` - JVM options, e.g., -Xms2G -Xmx2G. Default: `nil`.
- `proxy` - The class used to represent the node proxy.
Default: `org.openqa.grid.selenium.proxy.DefaultRemoteProxy`.
- `maxSession` - Max number of tests that can run at the same time on
the node, irrespective of the browser used. Default: `5`.
- `register` - Node will attempt to re-register itself automatically
with its known grid hub if the hub becomes unavailable. Default: `true`.
- `registerCycle` - Specifies (in ms) how often the node will try to
register itself again. Allows administrator to restart the hub without
restarting (or risk orphaning) registered nodes. Must be specified with
the "register" option. Default: `5000`.
- `nodeStatusCheckTimeout` - When to time out a node status check.
Default: `5000`.
- `nodePolling` - Specifies (in ms) how often the hub will
poll to see if the node is still responding. Default: `5000`.
- `unregisterIfStillDownAfter` - If the node remains down for more
than specified (in ms), it will stop attempting to re-register from the
hub. Default: `60000`.
- `downPollingLimit` - Node is marked as "down" if the node hasn't
responded after the number of checks specified. Default: `2`.
- `debug` - [TrueClass, FalseClass], default: false
- `servlets` - List of extra servlets the grid (hub or node) will make
available. The servlet must exist in the path, e.g.,
/grid/admin/Servlet. Default: `[]`.
- `withoutServlets` - List of default (hub or node) servlets to disable.
Advanced use cases only. Not all default servlets can be disabled.
Default: `[]`.
- `debug` - Enables LogLevel.FINE. Default: `false`.
- `timeout` - Specifies the timeout before the server automatically
kills a session that hasn't had any activity in the last X seconds.
The test slot will then be released for another test to use. This is
typically used to take care of client crashes. For grid hub/node roles,
cleanUpCycle must also be set. Default: `1800`.
- `browserTimeout` - Number of seconds a browser session is allowed to
hang while a WebDriver command is running (example: driver.get(url)).
If the timeout is reached while a WebDriver command is still processing,
the session will quit. Minimum value is `60`. An unspecified, zero,
or negative value means wait indefinitely. Default: `0`.
- `jettyMaxThreads` - Max number of threads for Jetty. An unspecified,
zero, or negative value means the Jetty default value (200) will be
used. Default: `-1`.
- `log` - The filename to use for logging. If omitted, will log to
STDOUT. Default: `nil`.
- `capabilities` - Based on
[capabilities](https://code.google.com/p/selenium/wiki/DesiredCapabilities). Default `[]`.
- Mac OS X/Windows only - Set both username and password to run as a GUI service:
Expand Down Expand Up @@ -210,8 +271,9 @@ end

## ChefSpec Matchers

The Selenium cookbook includes custom [ChefSpec](https://github.com/sethvargo/chefspec) matchers you can use to test
your own cookbooks.
This cookbook includes custom
[ChefSpec](https://github.com/sethvargo/chefspec) matchers you can use
to test your own cookbooks.

Example Matcher Usage

Expand All @@ -228,13 +290,17 @@ Selenium Cookbook Matchers

## Getting Help

- Ask specific questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/selenium).
- Report bugs and discuss potential features in [Github issues](https://github.com/dhoer/chef-selenium/issues).
- Ask specific questions on
[Stack Overflow](http://stackoverflow.com/questions/tagged/selenium).
- Report bugs and discuss potential features in
[Github issues](https://github.com/dhoer/chef-selenium/issues).

## Contributing

Please refer to [CONTRIBUTING](https://github.com/dhoer/chef-selenium/blob/master/CONTRIBUTING.md).

## License

MIT - see the accompanying [LICENSE](https://github.com/dhoer/chef-selenium/blob/master/LICENSE.md) file for details.
MIT - see the accompanying
[LICENSE](https://github.com/dhoer/chef-selenium/blob/master/LICENSE.md)
file for details.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "master-{build}"
version: "build-{build}"

os: Windows Server 2012 R2
platform:
Expand Down
10 changes: 9 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
default['selenium']['url'] =
'https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar'
'https://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar'

default['selenium']['windows']['home'] = "#{ENV['SYSTEMDRIVE']}/selenium"
default['selenium']['windows']['java'] = "#{ENV['SYSTEMDRIVE']}\\java\\bin\\java.exe"

# used by both macosx and linux platforms
default['selenium']['unix']['home'] = '/opt/selenium'
default['selenium']['unix']['java'] = '/usr/bin/java'

if platform?('windows')
default['selenium']['home'] = node['selenium']['windows']['home']
default['selenium']['java'] = node['selenium']['windows']['java']
else
default['selenium']['home'] = node['selenium']['unix']['home']
default['selenium']['java'] = node['selenium']['unix']['java']
end
12 changes: 7 additions & 5 deletions attributes/hub.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
default['selenium']['hub']['servicename'] = 'selenium_hub' # used by hub recipe only
default['selenium']['hub']['host'] = 'null'
default['selenium']['hub']['host'] = nil
default['selenium']['hub']['port'] = 4444
default['selenium']['hub']['jvm_args'] = nil
default['selenium']['hub']['newSessionWaitTimeout'] = -1
default['selenium']['hub']['prioritizer'] = nil
default['selenium']['hub']['servlets'] = []
default['selenium']['hub']['prioritizer'] = 'null'
default['selenium']['hub']['withoutServlets'] = []
default['selenium']['hub']['capabilityMatcher'] = 'org.openqa.grid.internal.utils.DefaultCapabilityMatcher'
default['selenium']['hub']['throwOnCapabilityNotPresent'] = true
default['selenium']['hub']['nodePolling'] = 5000
default['selenium']['hub']['cleanUpCycle'] = 5000
default['selenium']['hub']['timeout'] = 30_000
default['selenium']['hub']['debug'] = true
default['selenium']['hub']['timeout'] = 1800
default['selenium']['hub']['browserTimeout'] = 0
default['selenium']['hub']['maxSession'] = 5
default['selenium']['hub']['jettyMaxThreads'] = -1
default['selenium']['hub']['jettyMaxThreads'] = 0
default['selenium']['hub']['log'] = nil
18 changes: 13 additions & 5 deletions attributes/node.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
default['selenium']['node']['servicename'] = 'selenium_node' # used by node recipe only
default['selenium']['node']['host'] = 'ip'
default['selenium']['node']['host'] = nil
default['selenium']['node']['port'] = 5555
default['selenium']['node']['jvm_args'] = nil
default['selenium']['node']['proxy'] = 'org.openqa.grid.selenium.proxy.DefaultRemoteProxy'
default['selenium']['node']['maxSession'] = 5
default['selenium']['node']['register'] = true
default['selenium']['node']['registerCycle'] = 5000
default['selenium']['node']['hubPort'] = 4444
default['selenium']['node']['hubHost'] = 'ip'
default['selenium']['node']['hub'] = 'http://localhost:4444'
default['selenium']['node']['capabilities'] = []
default['selenium']['node']['additional_args'] = []
default['selenium']['node']['servlets'] = []
default['selenium']['node']['withoutServlets'] = []
default['selenium']['node']['nodeStatusCheckTimeout'] = 5000
default['selenium']['node']['nodePolling'] = 5000
default['selenium']['node']['unregisterIfStillDownAfter'] = 60_000
default['selenium']['node']['downPollingLimit'] = 2
default['selenium']['node']['debug'] = true
default['selenium']['node']['timeout'] = 1800
default['selenium']['node']['browserTimeout'] = 0
default['selenium']['node']['jettyMaxThreads'] = 0
default['selenium']['node']['log'] = nil
default['selenium']['node']['display'] = ':0'
default['selenium']['node']['username'] = nil
default['selenium']['node']['password'] = nil
default['selenium']['node']['domain'] = nil
Loading

0 comments on commit 68dddc6

Please sign in to comment.