Giter Site home page Giter Site logo

puppet-selenium's Introduction

Puppet selenium Module

Build Status

Table of Contents

  1. Overview
  2. Description
  3. Usage
  4. Why Another Module?
  5. Limitations
  6. Versioning
  7. Support
  8. Contributing
  9. See Also

Overview

Manages Selenium Server 2 - Standalone and Grid

Description

This is a puppet module for installation and configuration of the Selenium Server 2 browser automation package. Support is provided for configuring Selenium Server in standalone mode or as a Selenium grid with composed of the hub and node modes.

The design intent of this module is to only manage Selenium server and not any of the other packages that might be required to required to create a selenium server profile/role.

Usage

The selenium::server class is used to setup a standalone Selenium instance to allow the use of a single server as a test node. The selenium::hub class acts as a proxy in front of one or more selenium::node instances. A hub + node(s) setup is referred to as a Selenium grid. Running selenium::server is similar to creating a Selenium grid by declaring selenium::hub and selenium::node on the same host.

It is highly recommend that you read the Selenium Grid documentation to determine what the best approach for your usage case(s) is.

Simple

Stand alone server setup with display :99 (default is :0).

class { 'selenium::server': display => ':99' }

Grid in a box setup with the Selenium node talking to the hub via 127.0.0.1.

class { 'selenium::hub': }
class { 'selenium::node': }

Example "profiles"/"roles"

Here are some examples "profiles" and "roles" based on Craig Dunn's blog post on Designing Puppet โ€“ Roles and Profiles..

These examples assume the presence of these two modules in your Puppet environment.

Selenium Server Profile

class mysite::profile::seleniumserver {
  include java

  # WSXGA+ 1680x1050 -- should nicely fit on a 1920x1280 screen
  class { 'display':
    width  => 1680,
    height => 1050,
  } ->
  class { 'selenium::server': }

  Class['java'] -> Class['selenium::server']
}

Selenium Hub Profile

class mysite::profile::seleniumhub {
  include java

  class { 'selenium::hub': }

  Class['java'] -> Class['selenium::hub']
}

Selenium Node Profile

class mysite::profile::seleniumnode {
  include java

  # WSXGA+ 1680x1050 -- should nicely fit on a 1920x1280 screen
  class { 'display':
    width  => 1680,
    height => 1050,
  } ->
  class { 'selenium::node':
    # If your intending to have node(s) that don't sit on the same system as
    # the hub, you need to point the node at a hub by passing in the hub's url
    # in or using an exported resource from the hub system. Eg.
    # hub => 'http://<myseleniumhub>:4444/grid/register',
  }

  Class['java'] -> Class['selenium::node']
}

Selenium Server Role

class mysite::role::seleniumserver {
  include mysite::profile::seleniumserver
}

Selenium Hub Role

class mysite::role::seleniumhub {
  include mysite::profile::seleniumhub
  include mysite::profile::seleniumnode
}

Files

Unless class selenium has $install_root changed from the default, these files paths will be used. Note that the log files and init scripts are only created for the relevant configured service.

The log files are set to mode 0644, so that they can be inspected by users other than the selenium role account.

/opt/selenium
|-- jars
|   `-- selenium-server-standalone-x.xx.x.jar
`-- log
    |-- hub_stderr.log
    |-- hub_stdout.log
    |-- node_stderr.log
    |-- node_stdout.log
    |-- server_stderr.log
    `-- server_stdout.log
/var/log/selenium -> /opt/selenium/log
/etc/init.d/seleniumhub
/etc/init.d/seleniumnode
/etc/init.d/seleniumserver

Classes

selenium

This class controls common configuration values used by the selenium::{server,hub,node} classes. It is automatically included in the manifest by those classes and it need not be explicitly declared except to override the default values.

# defaults
class { 'selenium':
  user                => 'selenium',
  manage_user         => true,
  group               => 'selenium',
  manage_group        => true,
  install_root        => '/opt/selenium',
  java                => 'java',
  version             => '2.45.0',
  url                 => undef,
  download_timeout    => '90',
  nocheckcertificate  => false,
  manage_logrotate    => true,
  manage_installation => true,
  initsystem          => 'initd'
}
user

String defaults to: selenium

The name/uid of the system role account to execute the server process under and will have ownership of files.

manage_user

Boolean defaults to: true

Whether or not this module should manage the system role account to execute the server process under.

group

String defaults to: selenium

The group/gid of the system role account and group ownership of files.

manage_group

Boolean defaults to: true

Weather or not this module should manage the group of the system role account.

install_root

String defaults to: /opt/selenium

The dirname under which Selenium Server files (including logs) will be created.

java

String defaults to: java

The path of the java interpreter to use.

version

String defaults to: 2.45.0 (the latest release as of 2015-05-23)

The version of Selenium Server to download. Used to form the URL used to fetch the jar file.

url

String defaults to: undef

If defined, url will be used to download the Selenium Server jar file. However, the version parameter just match the version of the downloaded file as this information is needed when starting up the server (this may change to be be automatically parsed from the url in a later release).

download_timeout

String defaults to: 90

Timeout to download of the package.

nocheckcertificate

Boolean defaults to: false

Disables validation of the x509 certificate the Selenium jar file is retrieved from.

See Certificate Errors

manage_logrotate

Boolean defaults to: true

Uses the Logrotate module to rotate the log file of Selenium.

manage_installation

Boolean defaults to: true

Let the module handle the installation of the Selenium jar file.

initsystem

Defines the init system to use, based on OS Version, currently Redhat 7+ is set to systemd, all others default to initd.

Supported overrides, 'init.d' or 'systemd'. Uses templates to install service

selenium::server

# defaults
class { 'selenium::server':
  display   => ':0',
  options   => '-Dwebdriver.enable.native.events=1',
  classpath => ['/custom/lib1.jar', '/custom/lib2.jar'],
}
display

String defaults to: :0

The name of the X display to render too. This is set as an environment variable passed to Selenium Server

options

String defaults to: -Dwebdriver.enable.native.events=1

Options passed to Selenium Server at startup.

classpath

Array defaults to: []

Optional classpath to pass to Selenium Server at startup. If this array is empty Selenium will be started with '-jar /path/to/selenium.jar', if not empty Selenium will be started with '-cp /path/to/selenium.jar: org.openqa.grid.selenium.GridLauncher' See http://www.seleniumhq.org/docs/07_selenium_grid.jsp#customizing-the-grid

selenium::hub

Note that by default selenium::server and selenium::hub will try to listen on the same TCP port (4444) and only one of them will be able to function.

# defaults
class { 'selenium::hub':
  options   => '-role hub',
  classpath => ['/custom/lib1.jar', '/custom/lib2.jar'],
}
options

String defaults to: -role hub

Options passed to Selenium Server Hub at startup.

classpath

Array defaults to: []

Optional classpath to pass to Selenium Server Hub at startup. If this array is empty Selenium will be started with '-jar /path/to/selenium.jar', if not empty Selenium will be started with '-cp /path/to/selenium.jar: org.openqa.grid.selenium.GridLauncher' See http://www.seleniumhq.org/docs/07_selenium_grid.jsp#customizing-the-grid

initsystem

Defines the init system to use, based on OS Version, currently Redhat 7+ is set to systemd, all others default to initd.

Supported overrides, 'init.d' or 'systemd'. Uses templates to install service

selenium::node

# defaults
class { 'selenium::node':
  display   => ':0',
  options   => '-Dwebdriver.enable.native.events=1 -role node',
  hub       => 'http://localhost:4444/grid/register',
  classpath => ['/custom/lib1.jar', '/custom/lib2.jar'],
  initsystem => 'systemd'
}
display

String defaults to: :0

The name of the X display to render too. This is set as an environment variable passed to Selenium Server

options

String defaults to: -Dwebdriver.enable.native.events=1 -role node

Options passed to Selenium Server Node at startup.

hub

String defaults to: http://localhost:4444/grid/register

The URL of the Selenium Server Hub to connect to.

classpath

Array defaults to: []

Optional classpath to pass to Selenium Server Node at startup. If this array is empty Selenium will be started with '-jar /path/to/selenium.jar', if not empty Selenium will be started with '-cp /path/to/selenium.jar: org.openqa.grid.selenium.GridLauncher' See http://www.seleniumhq.org/docs/07_selenium_grid.jsp#customizing-the-grid

initsystem

Defines the init system to use, based on OS Version, currently Redhat 7+ is set to systemd, all others default to initd.

Supported overrides, 'init.d' or 'systemd'. Uses templates to install service

Why Another Module?

At the time work on this module was started, there were no other Selenium Server modules published on the Puppet Forge. A number of existing modules were identified on github but none of them fit the author's needs of:

  • Allowing the external setup of things like Xvfb, java, etc. and to allow the composition of site specific profiles/roles.
  • Supporting a mixed environment of Scientific, Centos, and RedHat Linux (basically $::osfamily == 'RedHat'
  • Enough rspec-puppet coverage to prevent regressions

The later is the most important issue. Attempting to add additional $::operatingsystem/$::osfamily support to a puppet module without rspec-puppet tests is a process fraught with peril.

The modules that were identified were:

Limitations

Tested Platforms

  • el6.x
  • el7.x
  • Debian 7
  • Ubuntu 12.04
  • Ubuntu 14.04

Puppet Version Compatibility

Versions Puppet 2.7 Puppet 3.x Puppet 4.x
0.x yes yes no
1.x no yes yes

Certificate Errors

A number of users have reported "certificate validation errors" when this module downloads the Selenium jar file. The most likely explanation is that the CA certificates on that node are out of date. It may also be an indication of a MITM attack on the TLS connection. Certificate validation errors do not occur on the nodesets used for acceptance tests. The nocheckcertificate param may be set to true to bypass this error but be sure the security implications of this setting are well understood before enabling it.

Versioning

This module is versioned according to the Semantic Versioning 2.0.0 specification.

Support

Please log tickets and issues at github

Contributing

  1. Fork it on github
  2. Make a local clone of your fork
  3. Create a topic branch. Eg, feature/mousetrap
  4. Make/commit changes
    • Commit messages should be in imperative tense
    • Check that linter warnings or errors are not introduced - bundle exec rake lint
    • Check that Rspec-puppet unit tests are not broken and coverage is added for new features - bundle exec rake spec
    • Documentation of API/features is updated as appropriate in the README
    • If present, beaker acceptance tests should be run and potentially updated - bundle exec rake beaker
  5. When the feature is complete, rebase / squash the branch history as necessary to remove "fix typo", "oops", "whitespace" and other trivial commits
  6. Push the topic branch to github
  7. Open a Pull Request (PR) from the topic branch onto parent repo's master branch

See Also

puppet-selenium's People

Contributors

anho avatar bionix avatar carroarmato0 avatar colferai avatar dig412 avatar enxebre avatar fraenki avatar hipska avatar jhoblitt avatar jlyheden avatar jshholland avatar klavsklavsen avatar krzysztofhajdamowicz avatar masseyc avatar peterabbott avatar sarg avatar tayzlor avatar xiankai avatar zivan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-selenium's Issues

Renewing Puppet Forge Approved Status

Hey jhoblitt,

Here at puppetlabs, we are currently going through all of our Approved modules on the Puppet Forge. We have some feedback for your module if you would be interested in retaining the approved status. If you are keen on keeping your approved status please ensure you respond as soon as you possibly can.

Many Thanks
The Puppet Approvals Committee.

SSL error with wget

I had an SSL error issue when running the module.

Maybe should add - nocheckcertificate => true

hub vs. server?

What is selenium server vs. selenium hub?

I would like to have my main server - containg whatever is necessary - so I can add extra nodes alter on (windows nodes for IE f.ex.).. the readme doesn't seem to make it clear, what I should choose :( - and explicitly says that ::hub and ::server conflicts - as they use the same port by default..

Puppet approved.

Hi @jhoblitt ,

I am reaching out to you on behalf of Puppet in regards to your Puppet Approved module jhoblitt/selenium on the Puppet Forge. The Puppet Approved criteria is based on the following tenets; quality composition, reliable operation, and active development. Your module has not been updated on the Puppet Forge for over a year, are there any plans to release a new version of the module?

There seems to be a few open pull requests that could be merged. If there has not been a new release of the module on the Puppet Forge or a response in the following 3 months, we may have to revoke your Puppet Approved status. If you are not interested in continuing maintenance of the module, you may consider contacting the open source Puppet community Vox Pupuli. They are always interested in adopting modules. There is more information here https://voxpupuli.org/docs/#migrating-a-module-to-voxpupuli.

I look forward to your response, or a new release on the Puppet Forge.

Regards,
TP Honey
Senior Software Engineer
Puppet Modules Team

PS, i apologise for not getting back on the windows support PR.

Multiple installation modes

Currently the module only installs via wget.
Should have an installation mode:

remote => wget
bundled => source from puppet:///
this way if a server doesn't have internet access you can still do the install by supplying the jar to puppet

Systemd unit file is created with executable bit

CentOS7 with Puppet 5.5.10 causes systemd to complain about:

Configuration file /usr/lib/systemd/system/seleniumserver.service is marked executable. Please remove executable permission bits. Proceeding anyway.

PR #79 fixes this issue.

Issue with --chdir daemon parameter

Hi,

I'm currently deploying this module to a customer who is using Behat with PhantomJS to test his application, and we're been running into the following issue, under Puppet 3.4, Ubuntu 14.04 and selenium-server-standalone 2.45.0:

Whenever the test suite is started, an obscure and unhelpful error arises and it is unable to continue.
After some digging around using strace, I managed to pin down the issue to the selenium-standalone daemon trying to create /phantomjsdriver.log and failing to do so because of permission issues.

We managed to workaround the issue by editing the /etc/init.d/seleniumserver initscript's DAEMON_ARGS variable: adding --chdir=/var/lib/selenium ensures that the daemon is creating all its files in a directory its has write access to.

Are you able to reproduce this issue?

puppet-selenium didn't ensure service is running

The module ensures that if the initscript is not created or have changes, it will trigger to refresh service[node,hub,server].

But the problem comes when the initscript files are already created and don't have any variation, if the service node,hub or server is down it won't be started again by this module.

So I'm going to do a PR to try to solve this.

Systemd scripts

Hi,
nice module. I have installed it on Fedora 21 and i would like to provide a patch, so you can that via parameter if you want to use sysv or systemd init system. The default would be sysv. So nothing would change on the default behavior of this script.

Shoud I provide the PR?

Issue with using both hub and node roles in the same server

Hi,

Using a simple manifest file (https://github.com/williamtsoi1/selenium-puppet/blob/master/manifests/default.pp), and I have the following error:

Error: Duplicate declaration: File[init-script] is already declared in file /home/ubuntu/selenium-puppet/modules/selenium/manifests/config.pp:40; cannot redeclare at /home/ubuntu/selenium-puppet/modules/selenium/manifests/config.pp:40 on node ip-10-70-0-193.ap-southeast-2.compute.internal

Is there some sort of conflict between the selenium::hub and selenium::node classes?

selenium includes class wget

which isn't in any module I can find - and which isn't mentioned as a dependency.

I figure you've just created a simple module, that can manage to install wget - on the OS'es you want to support.. :)

User management toggles

If you don't want the module to manage users or groups, you should have that option.

init.pp

$manage_user = true,
$manage_group = true,
) inherits selenium::params {
....
validate_bool($manage_user)
validate_bool($manage_group)

if $manage_user {
user { $user:
ensure => present,
gid => $group,
}
}
if $manage_group {
group { $group:
ensure => present,
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.