Best Practice For UX Deliverables - Eventhandler, London, 05 March 2014
WatirGrid
-
Upload
90kts -
Category
Technology
-
view
2.046 -
download
0
description
Transcript of WatirGrid
WatirGridParallel testing with Watir
About
In 2007, WatirGrid was created by Dane Avilla (brilliant!)
In 2009, I packaged it as a gem , gave it a domain
watirgid.com and have since maintained it …
Tim Koopmans
@90kts
taking the FUD out of performance and test automation...
If Watir is …
WatirGrid is …
WatirGrid
Takes all the advantages of Watir …
And multiplies its use in a distributed,
parallel and coordinated fashion…
In other words “1 test case, many browsers”
//todo
WatirGrid is Distributed
Built with standard DRb packages.
Completely written in Ruby using core
libraries.
Lets you control Watir objects remotely with
transmission passed by reference.
I, [2011-03-24 13:45:06 #1057] INFO -- :
DRb server started on : druby://192.168.1.6:50600
I, [2011-03-24 13:45:06 #1057] INFO -- :
Ring server started on: druby://192.168.1.6:7647
WatirGrid is Parallel
WatirGrid uses Threads to execute Watir test
cases in parallel (sort of). Threads execute on
remote Watir objects, offloading any
processing overheads …
threads = []
grid.browsers.each_with_index do |browser, index|
threads << Thread.new do
...
end
end
threads.each {|thread| thread.join}
WatirGrid is Coordinated
Based on Rinda, the Ruby version of Linda
…
Linda is a model of coordination and communication
among several parallel processes operating upon objects
stored in and retrieved from shared, virtual, associative
memory. [1]
[1] Markoff, John (January 19, 1992). "David Gelernter's Romance With Linda". The New York Times.
WatirGrid is Free
Uses the BSD license[1]
[1] https://github.com/90kts/watirgrid/raw/master/LICENSE
Key Terminology
Controllers implements a repository of tuples (tuple
space) that can be accessed concurrently. The controller
hosts the ring server which advertises these tuples across
a grid network. Typically you will host one controller on a
central machine.
Providers make remote Watir objects available to the
tuple space hosted by the ring server. 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 or
Safari browser object.
Controller + Providers
= the Grid
A loosely coupled, distributed workforce …
A Canned Example # 1
If you haven‟t already …
Something simple …
gem install watirgrid
require 'watirgrid'
# Start a Controller
controller = Controller.new
controller.start
# Start a Provider with SafariWatir
provider = Provider.new(:browser_type => 'safari')
provider.start
# Create a Grid
grid = Watir::Grid.new
grid.start(:take_all => true)
What Just Happened?
Started a Controller
DRb server was started on a random port
A Rinda Ring Server was started on port 7647
Started 1 Provider (using SafariWatir)
DRb server started on a random port
The Ring Server was found on port 7647
A browser “tuple” was registed on the Ring Server
INFO -- : DRb server started on : druby://192.168.1.6:51163
INFO -- : Ring server started on: druby://192.168.1.6:7647
INFO -- : DRb server started on : druby://192.168.1.6:51164
INFO -- : Ring server found on : druby://192.168.1.6:7647
INFO -- : New tuple registered : druby://192.168.1.6:7647
What Just Happened?
Created a Grid
We can see the previously registered tuple
represented as a hash. We‟ll be using the „front
object‟ provided …
>> pp grid.browsers.first
{:uuid=>"235fa1f0-37fd-012e-5bac-78ca394083a0",
:browser_type=>"safari",
:class=>:WatirProvider,
:hostname=>"air.local",
:object=>#<Watir::Provider:0x10166a240 @browser=Watir::Safari>,
:name=>:WatirGrid,
:architecture=>"universal-darwin10.0",
:description=>"A watir provider"}
Let‟s Use the Grid!
Take the first (and only) browser on the grid
and execute some Watir …# Take the first browser on the grid and execute some Watir
b = grid.browsers.first[:object].new_browser
b.goto "http://altentee.com"
b.close
A Canned Example # 2
Let‟s try with 2 providers …
require 'watirgrid'
# Start a Controller using defaults
controller = Controller.new
controller.start
# Start 2 Providers with WebDriver
2.times do
provider = Provider.new(:browser_type => 'webdriver')
provider.start
End
# Start another Grid
grid = Watir::Grid.new
grid.start(:take_all => true)
Let‟s Use the Grid!
Take all browsers on the grid in parallel using
Threads …browser_types = [:firefox, :chrome]
threads = []
grid.browsers.each_with_index do |browser, index|
threads << Thread.new do
b = browser[:object].new_browser(browser_types[index])
b.goto "http://altentee.com"
sleep 5
b.close
end
end
threads.each {|thread| thread.join}
Let‟s all Try .. 1
I‟ll start a new Controller on port 12358
require 'watirgrid'
# Start a Controller on port 12358
controller = Controller.new(:ring_server_port => 12358)
controller.start
Let‟s all Try .. 2
You start a Provider and register on my
Controllerrequire 'watirgrid'
provider = Provider.new(
browser_type => ‟firefox', # or ie, safari ...
:ring_server_port => 12358)
provider.start
Let‟s all Try .. 3!
See if I can control the grid …
require 'watirgrid'
# Start another Grid
grid = Watir::Grid.new
grid.start(:take_all => true)
threads = []
grid.browsers.each do |browser|
threads << Thread.new do
b = browser[:object].new_browser
b.goto("http://www.google.com")
b.text_field(:name, 'q').set("watirgrid")
b.button(:name, "btnI").click
b.close
end
end
threads.each {|thread| thread.join}
Security Considerations
$SAFE = 1
- poor man‟s paranoia
- on latest branch
ACLs
HTTPS
- not yet implemented
# Start a Controller with Access Control Lists
controller -a deny,all,allow,127.0.0.1 -H 127.0.0.1 -h 127.0.0.1
Performance
Considerations
Yes, but does it scale? 50..n
Ruby threads 1.8 vs. native threads 1.9, truly parallel?
Garbage collection cleaning up referenced objects!
Memory footprint of Controller? 100 Providers = 20MB
What‟$ Next?
GRIDinit.com => a commercial
implementation of WatirGrid on
different cloud providers.
Private alpha April – May,
Public beta June
to participate …
Questions?About WatirGrid that is …