watirgrid 1.0.1 → 1.0.3.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.email = "tim.koops@gmail.com"
10
10
  gem.homepage = "http://github.com/90kts/watirgrid"
11
11
  gem.authors = ["Tim Koopmans"]
12
- gem.version = "1.0.1"
12
+ gem.version = "1.0.3.pre"
13
13
  end
14
14
  rescue LoadError
15
15
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
data/bin/provider CHANGED
@@ -9,37 +9,41 @@ OptionParser.new do |opts|
9
9
  opts.banner = "Usage: provider [options]"
10
10
  opts.separator ""
11
11
  opts.separator "Specific options:"
12
- opts.on("-H HOST", "--drb-server-host", String,
12
+ opts.on("-H HOST", "--drb-server-host", String,
13
13
  "Specify DRb Server interface to host on") do |h|
14
14
  options[:drb_server_host] = h || nil
15
15
  end
16
- opts.on("-d PORT", "--drb-server-port", Integer,
16
+ opts.on("-d PORT", "--drb-server-port", Integer,
17
17
  "Specify DRb Server port to listen on") do |d|
18
18
  options[:drb_server_port] = d
19
19
  end
20
- opts.on("-h HOST", "--ring-server-host", String,
20
+ opts.on("-h HOST", "--ring-server-host", String,
21
21
  "Specify Ring Server host to connect to") do |h|
22
22
  options[:ring_server_host] = h || nil
23
23
  end
24
- opts.on("-r PORT", "--ring-server-port", Integer,
24
+ opts.on("-r PORT", "--ring-server-port", Integer,
25
25
  "Specify Ring Server port to broadcast on") do |r|
26
- options[:ring_server_port] = r
26
+ options[:ring_server_port] = r
27
27
  end
28
- opts.on("-b TYPE", "--browser-type", String,
28
+ opts.on("-c URI", "--controller-uri", String,
29
+ "Optional druby Controller URI e.g. druby://127.0.0.1:11235 to bypass Ring Server") do |h|
30
+ options[:controller_uri] = h || nil
31
+ end
32
+ opts.on("-b TYPE", "--browser-type", String,
29
33
  "Specify browser type to register {ie|firefox|safari}") do |b|
30
- options[:browser_type] = b
34
+ options[:browser_type] = b
31
35
  end
32
36
  opts.on("-a ACLS", "--access-control-list", Array,
33
37
  "Specify a comma separated Access Control List") do |a|
34
38
  options[:acls] = a
35
39
  end
36
- opts.on("-l LEVEL", "--log-level", String,
40
+ opts.on("-l LEVEL", "--log-level", String,
37
41
  "Specify log level {DEBUG|INFO|ERROR}") do |l|
38
42
  case l
39
43
  when 'DEBUG'
40
44
  options[:loglevel] = Logger::DEBUG
41
45
  when 'INFO'
42
- options[:loglevel] = Logger::INFO
46
+ options[:loglevel] = Logger::INFO
43
47
  when 'ERROR'
44
48
  options[:loglevel] = Logger::ERROR
45
49
  else
@@ -49,16 +53,17 @@ OptionParser.new do |opts|
49
53
  opts.on_tail("-h", "--help", "Show this message") do
50
54
  puts opts
51
55
  exit
52
- end
56
+ end
53
57
  end.parse!
54
58
 
55
59
  provider = Provider.new(
56
- :drb_server_host => options[:drb_server_host],
60
+ :drb_server_host => options[:drb_server_host],
57
61
  :drb_server_port => options[:drb_server_port] || 11236,
58
62
  :ring_server_host => options[:ring_server_host],
59
63
  :ring_server_port => options[:ring_server_port] || 12358,
60
- :browser_type => options[:browser_type] || nil,
61
- :acls => options[:acls] || %w{ allow all },
62
- :loglevel => options[:loglevel])
64
+ :browser_type => options[:browser_type] || nil,
65
+ :controller_uri => options[:controller_uri] || nil,
66
+ :acls => options[:acls] || %w{ allow all },
67
+ :loglevel => options[:loglevel])
63
68
  provider.start
64
69
  DRb.thread.join
data/lib/provider.rb CHANGED
@@ -140,6 +140,7 @@ class Provider
140
140
  @drb_server_port = params[:drb_server_port] || 0
141
141
  @ring_server_host = params[:ring_server_host] || external_interface
142
142
  @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT
143
+ @controller_uri = params[:controller_uri]
143
144
 
144
145
  @renewer = params[:renewer] || Rinda::SimpleRenewer.new
145
146
  @browser_type = params[:browser_type] || nil
@@ -183,15 +184,13 @@ class Provider
183
184
 
184
185
  # locate the Rinda Ring Server via a UDP broadcast
185
186
  @log.debug("Attempting to find ring server on : druby://#{@ring_server_host}:#{@ring_server_port}")
186
- ring_server = Rinda::RingFinger.new(@ring_server_host, @ring_server_port)
187
- ring_server = ring_server.lookup_ring_any
188
- @log.info("Ring server found on : druby://#{@ring_server_host}:#{@ring_server_port}")
187
+ find_ring_server
189
188
 
190
189
  # advertise this service on the primary remote tuple space
191
- ring_server.write(@tuple, @renewer)
190
+ @ring_server.write(@tuple, @renewer)
192
191
 
193
192
  # log DRb server uri
194
- @log.info("New tuple registered : druby://#{@ring_server_host}:#{@ring_server_port}")
193
+ @log.info("New tuple registered : #{@controller_uri}")
195
194
 
196
195
  # wait for explicit stop via ctrl-c
197
196
  DRb.thread.join if __FILE__ == $0
@@ -206,6 +205,20 @@ class Provider
206
205
 
207
206
  private
208
207
 
208
+ ##
209
+ # Locate the Rinda Ring Server via a UDP broadcast or direct URI
210
+ def find_ring_server
211
+ if @controller_uri
212
+ @ring_server = DRbObject.new(nil, @controller_uri)
213
+ else
214
+ @ring_server = Rinda::RingFinger.new(
215
+ @ring_server_host, @ring_server_port)
216
+ @ring_server = @ring_server.lookup_ring_any
217
+ @controller_uri = "druby://#{@ring_server_host}:#{@ring_server_port}"
218
+ end
219
+ @log.info("Controller found on : #{@controller_uri}")
220
+ end
221
+
209
222
  ##
210
223
  # Get the external facing interface for this server
211
224
  def external_interface
data/lib/watirgrid.rb CHANGED
@@ -47,8 +47,49 @@ module Watir
47
47
  @tuples.each { |tuple| @ring_server.write(tuple) }
48
48
  end
49
49
 
50
+ ##
51
+ # This is a helper method to control a grid.
52
+ # It involves some general block thuggery and could
53
+ # honestly benefit from some brutal refactoring...
54
+ def self.control(params = {}, &block)
55
+ log = Logger.new(STDOUT, 'daily')
56
+ log.level = params[:loglevel] || Logger::ERROR
57
+ grid = self.new(params)
58
+ grid.start(:take_all => true)
59
+ log.debug("Grid size : #{grid.size}")
60
+ log.debug("Grid rampup : #{rampup(grid.size, params)} secs")
61
+ threads = []
62
+ grid.browsers.each_with_index do |browser, index|
63
+ sleep rampup(grid.size, params)
64
+ threads << Thread.new do
65
+ start = ::Time.now
66
+ log.debug("Browser #{index+1}##{Thread.current.object_id} start : #{::Time.now}")
67
+ log.debug("Browser #{index+1}##{Thread.current.object_id} architecture : #{browser[:architecture]}")
68
+ log.debug("Browser #{index+1}##{Thread.current.object_id} type : #{browser[:browser_type]}")
69
+ log.debug("Browser #{index+1}##{Thread.current.object_id} hostname : #{browser[:hostname]}")
70
+ @browser = browser[:object].new_browser
71
+ yield @browser, "#{index+1}##{Thread.current.object_id}"
72
+ log.debug("Browser #{index+1}##{Thread.current.object_id} stop : #{::Time.now}")
73
+ log.debug("Browser #{index+1}##{Thread.current.object_id} elapsed : #{(::Time.now - start).to_i} secs")
74
+ #@browser.close
75
+ end
76
+ end
77
+ threads.each {|thread| thread.join}
78
+ grid.release_tuples
79
+ end
80
+
50
81
  private
51
82
 
83
+ ##
84
+ # Calculate rampup in seconds
85
+ def self.rampup(total_threads, params = {})
86
+ if params[:rampup]
87
+ params[:rampup] / total_threads
88
+ else
89
+ 0.5
90
+ end
91
+ end
92
+
52
93
  ##
53
94
  # Get the external facing interface for this server
54
95
  def external_interface
@@ -69,7 +110,7 @@ module Watir
69
110
  end
70
111
 
71
112
  ##
72
- # Locate the Rinda Ring Server via a UDP broadcast
113
+ # Locate the Rinda Ring Server via a UDP broadcast or direct URI
73
114
  def find_ring_server(params = {})
74
115
  if @controller_uri
75
116
  @ring_server = DRbObject.new(nil, @controller_uri)
@@ -79,7 +120,7 @@ module Watir
79
120
  @ring_server = @ring_server.lookup_ring_any
80
121
  @controller_uri = "druby://#{@ring_server_host}:#{@ring_server_port}"
81
122
  end
82
- @log.info("Controller found on :#{@controller_uri}")
123
+ @log.info("Controller found on : #{@controller_uri}")
83
124
  end
84
125
 
85
126
  ##
data/spec/grid_spec.rb CHANGED
@@ -188,32 +188,3 @@ describe 'Using the Grid' do
188
188
  grid.size.should == 0
189
189
  end
190
190
  end
191
-
192
- describe 'Using the Grid via direct Controller URI' do
193
- before(:all) do
194
- @controller = Controller.new(
195
- :ring_server_port => 12366,
196
- :ring_server_host => '127.0.0.1',
197
- :drb_server_port => '8866',
198
- :loglevel => Logger::ERROR)
199
- @controller.start
200
- 1.upto(5) do
201
- provider = Provider.new(
202
- :ring_server_port => 12366,
203
- :ring_server_host => '127.0.0.1',
204
- :loglevel => Logger::ERROR, :browser_type => 'safari')
205
- provider.start
206
- end
207
- end
208
-
209
- after(:all) do
210
- @controller.stop
211
- end
212
-
213
- it 'should take all providers' do
214
- grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:8866',
215
- :drb_server_host => '127.0.0.1')
216
- grid.start(:quantity => 5, :take_all => true, :browser_type => 'safari')
217
- grid.size.should == 5
218
- end
219
- end
@@ -0,0 +1,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe 'Using the Grid in GRIDinit style' do
4
+ before(:all) do
5
+ @controller = Controller.new(
6
+ :drb_server_port => 12357,
7
+ :ring_server_port => 12358,
8
+ :ring_server_host => '127.0.0.1',
9
+ :loglevel => Logger::ERROR)
10
+ @controller.start
11
+ 1.upto(5) do
12
+ provider = Provider.new(
13
+ :ring_server_port => 12358,
14
+ :ring_server_host => '127.0.0.1',
15
+ :drb_server_host => '127.0.0.1',
16
+ :loglevel => Logger::ERROR,
17
+ :browser_type => 'webdriver')
18
+ provider.start
19
+ end
20
+ end
21
+
22
+ after(:all) do
23
+ @controller.stop
24
+ end
25
+
26
+ it 'should take 1 provider via a direct controller_uri' do
27
+ grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
28
+ :drb_server_host => '127.0.0.1')
29
+ grid.start(:quantity => 3, :take_all => true, :browser_type => 'webdriver')
30
+ grid.size.should == 3
31
+ end
32
+
33
+ it 'should control the grid using a helper method' do
34
+ Watir::Grid.control({:controller_uri => 'druby://127.0.0.1:12357',:loglevel => Logger::DEBUG}) do |browser, id|
35
+ 3.times do |iteration|
36
+ browser.goto "http://127.0.0.1/#id=#{id}&iter=#{iteration}"
37
+ sleep 0.5
38
+ end
39
+ browser.close
40
+ end
41
+ end
42
+
43
+ it 'should take all remaining providers via a direct controller_uri' do
44
+ grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
45
+ :drb_server_host => '127.0.0.1')
46
+ grid.start(:take_all => true, :browser_type => 'webdriver')
47
+ grid.size.should == 2
48
+ end
49
+
50
+ it 'should add new providers via a direct controller_uri' do
51
+ provider = Provider.new(
52
+ :controller_uri => 'druby://127.0.0.1:12357',
53
+ :drb_server_host => '127.0.0.1',
54
+ :loglevel => Logger::ERROR,
55
+ :browser_type => 'webdriver')
56
+ provider.start
57
+ grid = Watir::Grid.new(:controller_uri => 'druby://127.0.0.1:12357',
58
+ :drb_server_host => '127.0.0.1')
59
+ grid.start(:take_all => true, :browser_type => 'webdriver')
60
+ grid.size.should == 1
61
+ end
62
+
63
+ end
data/watirgrid.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{watirgrid}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.3.pre"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Koopmans"]
12
- s.date = %q{2011-04-04}
12
+ s.date = %q{2011-04-05}
13
13
  s.description = %q{WatirGrid allows for distributed testing across a grid network using Watir.}
14
14
  s.email = %q{tim.koops@gmail.com}
15
15
  s.executables = ["controller", "provider"]
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  "lib/watirgrid.rb",
38
38
  "rdoc/logo.png",
39
39
  "spec/grid_spec.rb",
40
+ "spec/gridinit_spec.rb",
40
41
  "spec/memory_spec.rb",
41
42
  "spec/spec_helper.rb",
42
43
  "spec/utilities_spec.rb",
@@ -51,6 +52,7 @@ Gem::Specification.new do |s|
51
52
  s.summary = %q{WatirGrid: Web Application Testing in Ruby across a grid network.}
52
53
  s.test_files = [
53
54
  "spec/grid_spec.rb",
55
+ "spec/gridinit_spec.rb",
54
56
  "spec/memory_spec.rb",
55
57
  "spec/spec_helper.rb",
56
58
  "spec/utilities_spec.rb",
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirgrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
4
+ hash: 961915992
5
+ prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 3
10
+ - pre
11
+ version: 1.0.3.pre
11
12
  platform: ruby
12
13
  authors:
13
14
  - Tim Koopmans
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-04-04 00:00:00 -07:00
19
+ date: 2011-04-05 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -49,6 +50,7 @@ files:
49
50
  - lib/watirgrid.rb
50
51
  - rdoc/logo.png
51
52
  - spec/grid_spec.rb
53
+ - spec/gridinit_spec.rb
52
54
  - spec/memory_spec.rb
53
55
  - spec/spec_helper.rb
54
56
  - spec/utilities_spec.rb
@@ -76,12 +78,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
78
  required_rubygems_version: !ruby/object:Gem::Requirement
77
79
  none: false
78
80
  requirements:
79
- - - ">="
81
+ - - ">"
80
82
  - !ruby/object:Gem::Version
81
- hash: 3
83
+ hash: 25
82
84
  segments:
83
- - 0
84
- version: "0"
85
+ - 1
86
+ - 3
87
+ - 1
88
+ version: 1.3.1
85
89
  requirements: []
86
90
 
87
91
  rubyforge_project:
@@ -91,6 +95,7 @@ specification_version: 3
91
95
  summary: "WatirGrid: Web Application Testing in Ruby across a grid network."
92
96
  test_files:
93
97
  - spec/grid_spec.rb
98
+ - spec/gridinit_spec.rb
94
99
  - spec/memory_spec.rb
95
100
  - spec/spec_helper.rb
96
101
  - spec/utilities_spec.rb