Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
Major overhaul and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
timkoopmans committed May 26, 2011
1 parent e7b2c66 commit 1bbc8cb
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 370 deletions.
8 changes: 4 additions & 4 deletions EXAMPLES.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This will bind the controller to your external facing interface and register the
e.g.
DRb server started on : druby://143.238.105.61:11235
Ring server started on: druby://143.238.105.61:12358

=== Start on specific interface or ports
To start a controller on specific interfaces or ports:
$ controller -H 127.0.0.1 -h 127.0.0.1 -d 12345 -r 54321
Expand All @@ -30,7 +30,7 @@ This will bind the controller to the localhost (127.0.0.1) with the DRb server l
e.g.
DRb server started on : druby://127.0.0.1:12345
Ring server started on: druby://127.0.0.1:54321


=== Start with access control list
To start a controller with an access control list:
Expand Down Expand Up @@ -80,7 +80,7 @@ This will deny all access by default and allow access to this provider on localh

=== Start with a specific browser supported
By default, the provider will try to instantiate a browser object based on availability with your operating system e.g. Internet Explorer, Firefox or Safari. You can force provision of a set browser type as follows:
$ provider -b safari
$ provider -d webdriver

This will provide a Safari browser object. Other options are:
$ provider -b ie
Expand Down Expand Up @@ -129,4 +129,4 @@ Other attributes include:
Will determine which providers identified by a hash of hostnames that should be accessed. Useful if trying to limit the test to run from specific hostnames or IP addresses.

:browser_type => 'firefox'
Will determine which providers identified by a browser type should be accessed. Useful if trying to to test with specific browser types.
Will determine which providers identified by a browser type should be accessed. Useful if trying to to test with specific browser types.
7 changes: 4 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ To install WatirGrid:
gem install watirgrid

=== The Basics
WatirGrid is built on Rinda which implements the Linda distributed computing paradigm in Ruby. According to Wikipedia: “Linda is a model of coordination and communication among several parallel processes operating upon objects stored in and retrieved from shared, virtual, associative memory.”

In other words, WatirGrid allows multiple parallel processes to *_provide_* remote Watir objects in the form of tuple spaces across a grid network. This grid network is *_controlled_* by a ring server.
WatirGrid allows a local client to control remote Watir objects in parallel, hosted by *providers* on a grid network, via a central *controller*.

==== Key Terminology
The *controller* implements a repository of tuples (tuple space) that can be accessed concurrently. The controller also hosts a *ring* *server* which advertises these tuples across a grid network making it loosely coupled. Typically you will host one controller on a central machine. You will normally connect to this controller via a direct URI. You can also find this controller by its ring server, using a UDP broadcast for the ring server port.
The *controller* implements a repository of tuples (tuple space) that can be accessed concurrently. The controller also hosts a *ring* *server* which advertises these tuples across a grid network making it loosely coupled.

Typically you will host one controller on a central machine. You will normally connect to this controller via a contoller_uri. You can also find this controller by its ring server, using a UDP broadcast for the ring server port.

The *providers* make remote Watir objects available to the tuple space hosted by the *controller*. Typically you will host one or many providers on your grid network, for example, each PC may become a single provider of a Watir tuple in the form of an Internet Explorer, Firefox, Safari or WebDriver browser object.

Expand Down
53 changes: 28 additions & 25 deletions bin/controller
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,42 @@ options = {}
OptionParser.new do |opts|
opts.banner = "Usage: controller [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on("-H", "--drb-server-host [HOST]", String,
"Specify DRb Server interface to host on") do |h|
opts.separator "Advanced Options:"
opts.on("-h", "--drb HOST",
"Specify the DRb host for this controller to bind to.") do |h|
options[:drb_server_host] = h || nil
end
opts.on("-d", "--drb-server-port [PORT]", Integer,
"Specify DRb Server port to listen on") do |d|
options[:drb_server_port] = d
opts.on("-p", "--drb-port PORT",
"Specify the DRb port for this controller to listen on.") do |p|
options[:drb_server_port] = p
end
opts.on("-h", "--ring-server-host [HOST]", String,
"Specify Ring Server interface to host on") do |h|
opts.on("-H", "--ring-server HOST",
"Specify the ring server host for this controller to bind to.") do |h|
options[:ring_server_host] = h || nil
end
opts.on("-r", "--ring-server-port [PORT]", Integer,
"Specify Ring Server port to listen on") do |r|
options[:ring_server_port] = r
opts.on("-P", "--ring-server-port PORT",
"Specify the ring server port for this controller to listen on.") do |p|
options[:ring_server_port] = p
end
opts.on("-a", "--access-control-list [ACLS]", Array,
"Specify a comma separated Access Control List") do |a|
opts.on("-a", "--access-control-list ACL", Array,
"Specify a comma separated Access Control List.") do |a|
options[:acls] = a
end
opts.on("-l", "--log-level [LEVEL]", String,
"Specify log level {DEBUG|INFO|ERROR}") do |l|
case l
when 'DEBUG'
options[:loglevel] = Logger::DEBUG
when 'INFO'
options[:loglevel] = Logger::INFO
when 'ERROR'
options[:loglevel] = Logger::ERROR
else
options[:loglevel] = Logger::ERROR
end
opts.on("-l", "--log LEVEL",
"Specify the logging level:",
" - DEBUG",
" - INFO",
" - ERROR") do |l|
case l
when 'DEBUG'
options[:loglevel] = Logger::DEBUG
when 'INFO'
options[:loglevel] = Logger::INFO
when 'ERROR'
options[:loglevel] = Logger::ERROR
else
options[:loglevel] = Logger::ERROR
end
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
Expand Down
66 changes: 42 additions & 24 deletions bin/provider
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,57 @@ require 'optparse'

options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: provider -b BROWSER_TYPE [options]"
opts.banner = "Usage: provider -d DRIVER [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on("-b", "--browser-type TYPE",
"Specify driver for browser type to register {watir|firewatir|safariwatir|webdriver|zombie}") do |b|
options[:browser_type] = b
opts.separator "Basic Options:"
opts.on("-d", "--driver TYPE",
"Specify driver type to use on this provider:",
" - watir",
" - webdriver",
" - selenium",
" - firewatir",
" - safariwatir") do |d|
options[:driver] = d
end
opts.on("-c", "--controller-uri [URI]",
"Specify Controller URI e.g. druby://127.0.0.1:11235") do |h|
options[:controller_uri] = h || nil
opts.on("-c", "--controller URI",
"Specify the controller URI to register this provider on e.g.:",
" - druby://127.0.0.1:11235") do |c|
options[:controller_uri] = c || nil
end
opts.on("-H", "--drb-server-host [HOST]",
"Specify DRb Server interface to host on") do |h|
opts.on("-b", "--browser TYPE",
"Specify the browser type to start when using webdriver or selenium:",
" - firefox",
" - chrome",
" - ie") do |b|
options[:browser_type] = b || nil
end
opts.separator ""
opts.separator "Advanced Options:"
opts.on("-h", "--drb HOST",
"Specify the DRb host for this provider to bind to.") do |h|
options[:drb_server_host] = h || nil
end
opts.on("-d", "--drb-server-port [PORT]",
"Specify DRb Server port to listen on") do |d|
options[:drb_server_port] = d
opts.on("-p", "--drb-port PORT",
"Specify the DRb port for this provider to listen on.") do |p|
options[:drb_server_port] = p
end
opts.on("-h", "--ring-server-host [HOST]",
"Specify Ring Server host to connect to") do |h|
opts.on("-H", "--ring-server HOST",
"Optionally specify the ring server host if not using controller URI.") do |h|
options[:ring_server_host] = h || nil
end
opts.on("-r", "--ring-server-port [PORT]",
"Specify Ring Server port to broadcast on") do |r|
options[:ring_server_port] = r
opts.on("-P", "--ring-server-port PORT",
"Optionally specify the ring server port if not using controller URI.") do |p|
options[:ring_server_port] = p
end
opts.on("-a", "--access-control-list [ACL]", Array,
"Specify a comma separated Access Control List") do |a|
opts.on("-a", "--access-control-list ACL", Array,
"Specify a comma separated Access Control List.") do |a|
options[:acls] = a
end
opts.on("-l", "--log-level [LEVEL]",
"Specify log level {DEBUG|INFO|ERROR}") do |l|
opts.on("-l", "--log LEVEL",
"Specify the logging level:",
" - DEBUG",
" - INFO",
" - ERROR") do |l|
case l
when 'DEBUG'
options[:loglevel] = Logger::DEBUG
Expand All @@ -58,7 +76,7 @@ end

begin
optparse.parse!
mandatory = [:browser_type]
mandatory = [:driver]
missing = mandatory.select{ |param| options[param].nil? }
if not missing.empty?
puts "Missing options: #{missing.join(', ')}"
Expand All @@ -76,7 +94,7 @@ provider = Provider.new(
:drb_server_port => options[:drb_server_port] || 11236,
:ring_server_host => options[:ring_server_host],
:ring_server_port => options[:ring_server_port] || 12358,
:browser_type => options[:browser_type] || nil,
:driver => options[:driver] || nil,
:controller_uri => options[:controller_uri] || nil,
:acls => options[:acls] || %w{ allow all },
:loglevel => options[:loglevel])
Expand Down
Loading

0 comments on commit 1bbc8cb

Please sign in to comment.