watirgrid 0.0.9 → 1.0.0

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/LICENSE CHANGED
@@ -1,20 +1,25 @@
1
- Copyright (c) 2009-2011 Tim Koopmans
1
+ Copyright (c) 2009-2011 Altentee. All rights reserved.
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Redistribution and use in source and binary forms, with or without modification, are
4
+ permitted provided that the following conditions are met:
10
5
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of
7
+ conditions and the following disclaimer.
13
8
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list
10
+ of conditions and the following disclaimer in the documentation and/or other materials
11
+ provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
14
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
16
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ The views and conclusions contained in the software and documentation are those of the
24
+ authors and should not be interpreted as representing official policies, either expressed
25
+ or implied, of Altentee.
data/Rakefile CHANGED
@@ -9,14 +9,14 @@ 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 = "0.0.9"
12
+ gem.version = "1.0.0"
13
13
  end
14
14
  rescue LoadError
15
15
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
16
  end
17
17
 
18
18
  require 'spec/rake/spectask'
19
- desc "Run unit tests"
19
+ desc "Run unit tests for Watir, FireWatir and SafariWatir"
20
20
  Spec::Rake::SpecTask.new('unit_tests_watir') do |t|
21
21
  t.spec_files = FileList['spec/**/grid_spec.rb']
22
22
  t.spec_opts = ["--format", "nested", "-c"]
@@ -30,7 +30,6 @@ Spec::Rake::SpecTask.new('unit_tests_webdriver') do |t|
30
30
  t.fail_on_error = false
31
31
  end
32
32
 
33
-
34
33
  require 'rake/rdoctask'
35
34
  Rake::RDocTask.new do |rdoc|
36
35
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
data/lib/controller.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  # controller.rb
3
3
  # Rinda Ring Server Controlller
4
4
 
@@ -26,7 +26,9 @@ module Rinda
26
26
  @w_service = write_service
27
27
  @r_service = reply_service
28
28
  end
29
+
29
30
  end
31
+
30
32
  end
31
33
 
32
34
  class Controller
@@ -34,7 +36,7 @@ class Controller
34
36
  attr_accessor :drb_server_uri, :ring_server_uri
35
37
 
36
38
  def initialize(params = {})
37
- @drb_server_host = params[:drb_server_host] || external_interface
39
+ @drb_server_host = params[:drb_server_host] || external_interface
38
40
  @drb_server_port = params[:drb_server_port] || 0
39
41
  @ring_server_host = params[:ring_server_host] || external_interface
40
42
  @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT
@@ -43,14 +45,14 @@ class Controller
43
45
  logfile = params[:logfile] || STDOUT
44
46
  @log = Logger.new(logfile, 'daily')
45
47
  @log.level = params[:loglevel] || Logger::INFO
46
- @log.datetime_format = "%Y-%m-%d %H:%M:%S "
48
+ @log.datetime_format = "%Y-%m-%d %H:%M:%S "
47
49
 
48
50
  @log.debug("DRB Server Port #{@drb_server_port}\nRing Server Port #{@ring_server_port}")
49
51
  end
50
52
 
51
53
  ##
52
54
  # Start a new tuplespace on the ring server
53
- def start
55
+ def start
54
56
  # create a parent Tuple Space
55
57
  tuple_space = Rinda::TupleSpace.new
56
58
 
@@ -59,41 +61,41 @@ class Controller
59
61
 
60
62
  # start the DRb Server
61
63
  drb_server = DRb.start_service(
62
- "druby://#{@drb_server_host}:#{@drb_server_port}", tuple_space)
64
+ "druby://#{@drb_server_host}:#{@drb_server_port}", tuple_space)
63
65
 
64
66
  # obtain DRb Server uri
65
67
  @drb_server_uri = drb_server.uri
66
68
  @log.info("DRb server started on : #{@drb_server_uri}")
67
69
 
68
70
  # start the Ring Server
69
- ring_server = Rinda::RingServer.new(tuple_space,
71
+ ring_server = Rinda::RingServer.new(tuple_space,
70
72
  @ring_server_host, @ring_server_port)
71
73
 
72
74
  # obtain Ring Server uri
73
- @ring_server_uri = ring_server.uri
75
+ @ring_server_uri = ring_server.uri
74
76
  @log.info("Ring server started on: #{@ring_server_uri}")
75
77
 
76
78
  # abort all threads on an exception
77
79
  Thread.abort_on_exception = true
78
80
 
79
81
  # wait for explicit stop via ctrl-c
80
- DRb.thread.join if __FILE__ == $0
82
+ DRb.thread.join if __FILE__ == $0
81
83
  end
82
84
 
83
85
  ##
84
86
  # Stop the controller by shutting down the DRb service
85
- def stop
87
+ def stop
86
88
  DRb.stop_service
87
- @log.info("DRb server stopped on: #{@drb_server_uri}")
89
+ @log.info("DRb server stopped on: #{@drb_server_uri}")
88
90
  end
89
91
 
90
92
  private
91
93
 
92
94
  ##
93
- # Get the external facing interface for this server
94
- def external_interface
95
+ # Get the external facing interface for this server
96
+ def external_interface
95
97
  begin
96
- UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
98
+ UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
97
99
  rescue
98
100
  '127.0.0.1'
99
101
  end
data/lib/provider.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  # provider.rb
3
3
  # Rinda Ring Provider
4
4
 
@@ -6,46 +6,44 @@ require 'rinda/ring'
6
6
  require 'rinda/tuplespace'
7
7
  require 'logger'
8
8
  require 'drb/acl'
9
- require 'uuid'
10
9
 
11
10
  module Watir
12
-
11
+
13
12
  ##
14
13
  # Extend Watir with a Provider class
15
- # to determine which browser type is supported by the
14
+ # to determine which browser type is supported by the
16
15
  # remote DRb process. This returns the DRb front object.
17
16
  class Provider
18
17
 
19
18
  include DRbUndumped # all objects will be proxied, not copied
20
-
21
19
  attr_reader :browser
22
20
 
23
21
  def initialize(browser = nil)
24
- browser = (browser || 'tmp').downcase.to_sym
22
+ browser = (browser || 'tmp').downcase.to_sym
25
23
  case browser
26
24
  when :safari, :safariwatir
27
- require 'safariwatir'
25
+ require 'safariwatir'
28
26
  @browser = Watir::Safari
29
27
  when :firefox, :firewatir
30
- require 'firewatir'
31
- @browser = FireWatir::Firefox
28
+ require 'firewatir'
29
+ @browser = FireWatir::Firefox
32
30
  when :ie, :watir
33
- require 'watir'
31
+ require 'watir'
34
32
  @browser = Watir::IE
35
- when :webdriver
36
- require 'watir-webdriver'
33
+ when :webdriver
34
+ require 'watir-webdriver'
37
35
  @browser = Watir::Browser
38
- end
36
+ end
39
37
  end
40
38
 
41
- def new_browser(webdriver_browser_type = nil)
42
- if webdriver_browser_type
39
+ def new_browser(webdriver_browser_type = nil)
40
+ if webdriver_browser_type
43
41
  @browser.new(webdriver_browser_type)
44
42
  else
45
43
  @browser.new
46
44
  end
47
45
  end
48
-
46
+
49
47
  ##
50
48
  # Get a list of running browsers (optionally specified by browser)
51
49
  # 'iexplore','firefox','firefox-bin','chrome','safari','opera'
@@ -61,27 +59,27 @@ module Watir
61
59
  & browsers
62
60
  end
63
61
  end
64
-
62
+
65
63
  def get_running_processes
66
64
  %x[ps -A | grep -v ruby].split(/\/|\s+/).collect.uniq
67
65
  end
68
-
66
+
69
67
  ##
70
68
  # Kill any browser running
71
69
  def kill_all_browsers
72
70
  case Config::CONFIG['arch']
73
71
  when /mswin/
74
72
  browsers = ['iexplore.exe', 'firefox.exe', 'chrome.exe']
75
- browsers.each { |browser| %x[taskkill /F /IM #{browser}] }
73
+ browsers.each { |browser| %x[taskkill /F /IM #{browser}] }
76
74
  when /linux/
77
75
  browsers = ['firefox', 'chrome', 'opera']
78
- browsers.each { |browser| %x[killall -r #{browser}] }
76
+ browsers.each { |browser| %x[killall -r #{browser}] }
79
77
  when /darwin/
80
78
  browsers = ['firefox-bin', 'Chrome', 'Safari']
81
79
  browsers.each { |browser| %x[pkill -9 #{browser}] }
82
80
  end
83
81
  end
84
-
82
+
85
83
  ##
86
84
  # Kill all browsers specified by browser name
87
85
  # Windows: 'iexplore.exe', 'firefox.exe', 'chrome.exe'
@@ -97,7 +95,7 @@ module Watir
97
95
  %x[killall -m #{browser}]
98
96
  end
99
97
  end
100
-
98
+
101
99
  ##
102
100
  # Start firefox (with an optional bin path) using the -jssh extension
103
101
  def start_firefox_jssh(path=nil)
@@ -107,28 +105,28 @@ module Watir
107
105
  when /linux/
108
106
  bin = path || "/usr/bin/firefox"
109
107
  when /darwin/
110
- bin = path || "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
111
- end
108
+ bin = path || "/Applications/Firefox.app/Contents/MacOS/firefox-bin"
109
+ end
112
110
  # fork off and die!
113
111
  Thread.new {system(bin, "about:blank", "-jssh")}
114
112
  end
115
-
113
+
116
114
  ##
117
115
  # Get the logged-in user
118
116
  def get_logged_in_user
119
117
  %x[whoami].chomp
120
118
  end
121
-
119
+
122
120
  ##
123
121
  # Grep for a process (Linux/OSX-with-port only)
124
122
  def process_grep(pattern)
125
123
  %x[pgrep -l #{pattern}].split(/\n/)
126
124
  end
127
-
125
+
128
126
  def renew_provider
129
127
  self.class.superclass
130
128
  end
131
-
129
+
132
130
  end
133
131
 
134
132
  end
@@ -137,7 +135,7 @@ class Provider
137
135
 
138
136
  attr_accessor :drb_server_uri, :ring_server_uri
139
137
 
140
- def initialize(params = {})
138
+ def initialize(params = {})
141
139
  @drb_server_host = params[:drb_server_host] || external_interface
142
140
  @drb_server_port = params[:drb_server_port] || 0
143
141
  @ring_server_host = params[:ring_server_host] || external_interface
@@ -149,12 +147,12 @@ class Provider
149
147
  logfile = params[:logfile] || STDOUT
150
148
  @log = Logger.new(logfile, 'daily')
151
149
  @log.level = params[:loglevel] || Logger::INFO
152
- @log.datetime_format = "%Y-%m-%d %H:%M:%S "
150
+ @log.datetime_format = "%Y-%m-%d %H:%M:%S "
153
151
 
154
- end
152
+ end
155
153
 
156
154
  ##
157
- # Start providing watir objects on the ring server
155
+ # Start providing watir objects on the ring server
158
156
  def start
159
157
  # create a DRb 'front' object
160
158
  watir_provider = Watir::Provider.new(@browser_type)
@@ -166,7 +164,7 @@ class Provider
166
164
 
167
165
  # start the DRb Server
168
166
  drb_server = DRb.start_service(
169
- "druby://#{@drb_server_host}:#{@drb_server_port}")
167
+ "druby://#{@drb_server_host}:#{@drb_server_port}")
170
168
 
171
169
  # obtain DRb Server uri
172
170
  @drb_server_uri = drb_server.uri
@@ -174,15 +172,14 @@ class Provider
174
172
 
175
173
  # create a service tuple
176
174
  @tuple = [
177
- :WatirGrid,
178
- :WatirProvider,
179
- watir_provider,
180
- 'A watir provider',
175
+ :WatirGrid,
176
+ :WatirProvider,
177
+ watir_provider,
178
+ 'A watir provider',
181
179
  hostname,
182
180
  architecture,
183
- @browser_type,
184
- UUID.new.generate
185
- ]
181
+ @browser_type
182
+ ]
186
183
 
187
184
  # locate the Rinda Ring Server via a UDP broadcast
188
185
  @log.debug("Attempting to find ring server on : druby://#{@ring_server_host}:#{@ring_server_port}")
@@ -197,23 +194,23 @@ class Provider
197
194
  @log.info("New tuple registered : druby://#{@ring_server_host}:#{@ring_server_port}")
198
195
 
199
196
  # wait for explicit stop via ctrl-c
200
- DRb.thread.join if __FILE__ == $0
197
+ DRb.thread.join if __FILE__ == $0
201
198
  end
202
199
 
203
200
  ##
204
201
  # Stop the provider by shutting down the DRb service
205
- def stop
202
+ def stop
206
203
  DRb.stop_service
207
- @log.info("DRb server stopped on : #{@drb_server_uri}")
204
+ @log.info("DRb server stopped on : #{@drb_server_uri}")
208
205
  end
209
206
 
210
207
  private
211
208
 
212
209
  ##
213
- # Get the external facing interface for this server
214
- def external_interface
210
+ # Get the external facing interface for this server
211
+ def external_interface
215
212
  begin
216
- UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
213
+ UDPSocket.open {|s| s.connect('ping.watirgrid.com', 1); s.addr.last }
217
214
  rescue
218
215
  '127.0.0.1'
219
216
  end
data/lib/watirgrid.rb CHANGED
@@ -4,14 +4,14 @@ require 'provider'
4
4
  module Watir
5
5
 
6
6
  ##
7
- # Extend Watir with a Grid class which
7
+ # Extend Watir with a Grid class which
8
8
  # implements a grid of browsers by connecting to a tuplespace
9
9
  # and instatiating remote browser objects on nominated providers.
10
10
  class Grid
11
11
 
12
12
  attr_accessor :drb_server_uri, :ring_server, :browsers, :tuples
13
13
 
14
- def initialize(params = {})
14
+ def initialize(params = {})
15
15
  @drb_server_host = params[:drb_server_host] || external_interface
16
16
  @drb_server_port = params[:drb_server_port] || 0
17
17
  @ring_server_host = params[:ring_server_host] || external_interface
@@ -21,15 +21,15 @@ module Watir
21
21
  logfile = params[:logfile] || STDOUT
22
22
  @log = Logger.new(logfile, 'daily')
23
23
  @log.level = params[:loglevel] || Logger::ERROR
24
- @log.datetime_format = "%Y-%m-%d %H:%M:%S "
25
-
24
+ @log.datetime_format = "%Y-%m-%d %H:%M:%S "
25
+
26
26
  @browsers = []
27
27
  @tuples = []
28
28
  end
29
29
 
30
30
  ##
31
31
  # Start required services
32
- def start(params = {})
32
+ def start(params = {})
33
33
  start_drb_server
34
34
  find_ring_server
35
35
  get_tuples(params)
@@ -40,7 +40,7 @@ module Watir
40
40
  def size
41
41
  @browsers.size
42
42
  end
43
-
43
+
44
44
  ##
45
45
  # Write tuple back to tuplespace when finished using it
46
46
  def release_tuples
@@ -50,10 +50,10 @@ module Watir
50
50
  private
51
51
 
52
52
  ##
53
- # Get the external facing interface for this server
54
- def external_interface
53
+ # Get the external facing interface for this server
54
+ def external_interface
55
55
  begin
56
- UDPSocket.open {|s| s.connect('watir.com', 1); s.addr.last }
56
+ UDPSocket.open {|s| s.connect('watir.com', 1); s.addr.last }
57
57
  rescue
58
58
  '127.0.0.1'
59
59
  end
@@ -63,7 +63,7 @@ module Watir
63
63
  # Start the DRb Server
64
64
  def start_drb_server
65
65
  drb_server = DRb.start_service(
66
- "druby://#{@drb_server_host}:#{@drb_server_port}")
66
+ "druby://#{@drb_server_host}:#{@drb_server_port}")
67
67
  @drb_server_uri = drb_server.uri
68
68
  @log.info("DRb server started on : #{@drb_server_uri}")
69
69
  end
@@ -80,7 +80,7 @@ module Watir
80
80
  ##
81
81
  # Get all tuple spaces on ringserver
82
82
  def get_tuples(params = {})
83
- quantity = calculate_quantity(params[:quantity])
83
+ quantity = calculate_quantity(params[:quantity])
84
84
  read_tuples(params)
85
85
  @log.info("Found #{@tuples.size} tuples.")
86
86
  if @tuples.size > -1 then
@@ -90,7 +90,7 @@ module Watir
90
90
  else
91
91
  add_tuple_to_browsers(tuple)
92
92
  take_tuple(tuple) if params[:take_all] == true
93
- end
93
+ end
94
94
  end
95
95
  end
96
96
  end
@@ -101,7 +101,7 @@ module Watir
101
101
  # index when asking for n browsers
102
102
  def calculate_quantity(quantity)
103
103
  if (quantity.nil? or quantity == 0) then
104
- quantity = -1
104
+ quantity = -1
105
105
  else
106
106
  quantity -= 1
107
107
  end
@@ -118,8 +118,7 @@ module Watir
118
118
  nil, # provider description
119
119
  nil, # hostname
120
120
  params[:architecture],
121
- params[:browser_type],
122
- params[:uuid]
121
+ params[:browser_type]
123
122
  ])
124
123
  end
125
124
 
@@ -156,10 +155,9 @@ module Watir
156
155
  tuple_hash[:hostname] = tuple[4]
157
156
  tuple_hash[:architecture] = tuple[5]
158
157
  tuple_hash[:browser_type] = tuple[6]
159
- tuple_hash[:uuid] = tuple[7]
160
158
  tuple_hash
161
159
  end
162
-
160
+
163
161
  end
164
162
 
165
163
  end
data/spec/grid_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe 'Starting and Stopping Controllers on the Grid' do
10
10
 
11
11
  it 'should start a DRb and Ring Server on a specified interface' do
12
12
  controller = Controller.new(
13
- :drb_server_host => '127.0.0.1',
13
+ :drb_server_host => '127.0.0.1',
14
14
  :ring_server_host => '127.0.0.1',
15
15
  :loglevel => Logger::ERROR)
16
16
  controller.start
@@ -20,7 +20,7 @@ describe 'Starting and Stopping Controllers on the Grid' do
20
20
 
21
21
  it 'should start a DRb and Ring Server on specified ports' do
22
22
  controller = Controller.new(
23
- :drb_server_port => 11235,
23
+ :drb_server_port => 11235,
24
24
  :ring_server_port => 12358,
25
25
  :loglevel => Logger::ERROR)
26
26
  controller.start
@@ -32,7 +32,7 @@ end
32
32
  describe 'Starting and Stopping Providers on the Grid' do
33
33
  before(:all) do
34
34
  @controller = Controller.new(
35
- :drb_server_host => '127.0.0.1',
35
+ :drb_server_host => '127.0.0.1',
36
36
  :ring_server_host => '127.0.0.1',
37
37
  :ring_server_port => 12350,
38
38
  :loglevel => Logger::ERROR)
@@ -41,7 +41,7 @@ describe 'Starting and Stopping Providers on the Grid' do
41
41
 
42
42
  it 'should register a new provider on a specified port' do
43
43
  provider = Provider.new(
44
- :drb_server_host => '127.0.0.1',
44
+ :drb_server_host => '127.0.0.1',
45
45
  :ring_server_host => '127.0.0.1',
46
46
  :ring_server_port => 12350,
47
47
  :loglevel => Logger::ERROR)
@@ -59,9 +59,9 @@ describe 'Using the Grid' do
59
59
  :ring_server_port => 12357,
60
60
  :loglevel => Logger::ERROR)
61
61
  @controller.start
62
- 1.upto(5) do
62
+ 1.upto(5) do
63
63
  provider = Provider.new(
64
- :ring_server_port => 12357,
64
+ :ring_server_port => 12357,
65
65
  :loglevel => Logger::ERROR, :browser_type => 'safari')
66
66
  provider.start
67
67
  end
@@ -86,7 +86,7 @@ describe 'Using the Grid' do
86
86
  it 'should take any 1 provider on the grid' do
87
87
  grid = Watir::Grid.new(:ring_server_port => 12357)
88
88
  grid.start(:quantity => 1, :take_all => true)
89
- grid.size.should == 1
89
+ grid.size.should == 1
90
90
  end
91
91
 
92
92
  it 'should take all providers remaining on the grid' do
@@ -102,8 +102,8 @@ describe 'Using the Grid' do
102
102
  end
103
103
 
104
104
  it 'should register 4 new providers on the grid' do
105
- 1.upto(4) do
106
- provider = Provider.new(:ring_server_port => 12357,
105
+ 1.upto(4) do
106
+ provider = Provider.new(:ring_server_port => 12357,
107
107
  :loglevel => Logger::ERROR, :browser_type => 'safari')
108
108
  provider.start
109
109
  end
@@ -132,14 +132,14 @@ describe 'Using the Grid' do
132
132
 
133
133
  it 'should take any 1 provider on the grid based on specific :architecture' do
134
134
  grid = Watir::Grid.new(:ring_server_port => 12357)
135
- grid.start(:quantity => 1,
135
+ grid.start(:quantity => 1,
136
136
  :take_all => true, :architecture => Config::CONFIG['arch'])
137
137
  grid.size.should == 1
138
138
  end
139
139
 
140
140
  it 'should fail to find any providers on the grid based on an unknown :architecture' do
141
141
  grid = Watir::Grid.new(:ring_server_port => 12357)
142
- grid.start(:quantity => 1,
142
+ grid.start(:quantity => 1,
143
143
  :take_all => true, :architecture => 'geos-2000')
144
144
  grid.size.should == 0
145
145
  end
@@ -148,7 +148,7 @@ describe 'Using the Grid' do
148
148
  hostname = `hostname`.strip
149
149
  grid = Watir::Grid.new(:ring_server_port => 12357)
150
150
  grid.start(:quantity => 1,
151
- :take_all => true,
151
+ :take_all => true,
152
152
  :hostnames => { hostname => '127.0.0.1'}
153
153
  )
154
154
  grid.size.should == 1
@@ -157,31 +157,17 @@ describe 'Using the Grid' do
157
157
  it 'should fail to find any providers on the grid based on unknown :hostnames' do
158
158
  grid = Watir::Grid.new(:ring_server_port => 12357)
159
159
  grid.start(:quantity => 1,
160
- :take_all => true, :hostnames => {
160
+ :take_all => true, :hostnames => {
161
161
  "tokyo" => "127.0.0.1"})
162
162
  grid.size.should == 0
163
163
  end
164
164
 
165
- it 'should get the UUID of the last provider on the grid' do
166
- grid = Watir::Grid.new(:ring_server_port => 12357)
167
- grid.start(:read_all => true)
168
- grid.browsers.each do |browser|
169
- @uuid = browser[:uuid]
170
- end
171
- end
172
-
173
- it 'should be able to find a provider by its UUID on the grid' do
174
- grid = Watir::Grid.new(:ring_server_port => 12357)
175
- grid.start(:read_all => true, :uuid => @uuid)
176
- grid.size.should == 1
177
- end
178
-
179
- it 'should take the last provider on the grid and execute some Watir code in Safari' do
165
+ it 'should take the last provider on the grid and execute some Watir code in Safari' do
180
166
  grid = Watir::Grid.new(:ring_server_port => 12357)
181
167
  grid.start(:quantity => 1, :take_all => true)
182
168
  threads = []
183
169
  grid.browsers.each do |browser|
184
- threads << Thread.new do
170
+ threads << Thread.new do
185
171
  browser[:hostname].should == `hostname`.strip
186
172
  browser[:architecture].should == Config::CONFIG['arch']
187
173
  browser[:browser_type].should == 'safari'
@@ -200,5 +186,5 @@ describe 'Using the Grid' do
200
186
  grid = Watir::Grid.new(:ring_server_port => 12357)
201
187
  grid.start(:read_all => true)
202
188
  grid.size.should == 0
203
- end
189
+ end
204
190
  end
@@ -0,0 +1,94 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'ruby-prof'
3
+ RubyProf.measure_mode = RubyProf::MEMORY
4
+ # requires a GC patch to rubies http://patshaughnessy.net/2010/9/28/ruby187gc-patch
5
+
6
+ def total_memory_kilobytes(result)
7
+ total = 0
8
+ result.threads.each do |thread_id, methods|
9
+ total += methods.sort.last.total_time if methods.sort.last.total_time < 2*1024*1024
10
+ end
11
+ p total
12
+ #printer = RubyProf::FlatPrinter.new(result)
13
+ #printer.print(STDOUT, 0)
14
+ total
15
+ end
16
+
17
+ describe 'Profile memory of grid elements' do
18
+
19
+ it 'Footprint of single controller should be less than 100KB' do
20
+ result = RubyProf.profile do
21
+ controller = Controller.new(:loglevel => Logger::ERROR)
22
+ controller.start
23
+ controller.drb_server_uri.should =~ /druby/
24
+ end
25
+ total_memory_kilobytes(result).should < 100
26
+ end
27
+
28
+ it 'Footprint of single provider with controller should be less than 400KB' do
29
+ result = RubyProf.profile do
30
+ provider = Provider.new(:loglevel => Logger::ERROR)
31
+ provider.start
32
+ end
33
+ total_memory_kilobytes(result).should < 400
34
+ end
35
+
36
+ it 'Footprint of 10 providers with controller should be less than 2MB' do
37
+ result = RubyProf.profile do
38
+ 1.upto(10) do
39
+ provider = Provider.new(:loglevel => Logger::ERROR)
40
+ provider.start
41
+ end
42
+ end
43
+ total_memory_kilobytes(result).should < 2*1024
44
+ end
45
+
46
+ it 'Footprint of 100 providers with controller should be less than 20MB' do
47
+ result = RubyProf.profile do
48
+ 1.upto(100) do
49
+ provider = Provider.new(:loglevel => Logger::ERROR)
50
+ provider.start
51
+ end
52
+ end
53
+ total_memory_kilobytes(result).should < 20*1024
54
+ end
55
+ end
56
+
57
+ describe 'Memory profile of 1024byte string' do
58
+ it 'Should evaluate to 1KB of memory' do
59
+ result = RubyProf.profile do
60
+ x = "x"*1024
61
+ end
62
+ total_memory_kilobytes(result).should < 1024
63
+ end
64
+ end
65
+
66
+ describe 'Memory profile when instantiating a grid' do
67
+ it 'Footprint of 1 controller + 1 provder when grid is started' do
68
+ result = RubyProf.profile do
69
+ controller = Controller.new(:loglevel => Logger::ERROR)
70
+ controller.start
71
+ provider = Provider.new(:loglevel => Logger::ERROR, :browser_type => 'webdriver')
72
+ provider.start
73
+ grid = Watir::Grid.new
74
+ grid.start
75
+ end
76
+ total_memory_kilobytes(result)
77
+ end
78
+ end
79
+
80
+ describe 'Memory profile when instantiating a grid and driving a browser' do
81
+ it 'Footprint of 1 controller + 1 provder when grid is started, with firefox' do
82
+ result = RubyProf.profile do
83
+ controller = Controller.new(:loglevel => Logger::ERROR)
84
+ controller.start
85
+ provider = Provider.new(:loglevel => Logger::ERROR, :browser_type => 'webdriver')
86
+ provider.start
87
+ grid = Watir::Grid.new
88
+ grid.start
89
+ b = grid.browsers[0][:object].new_browser(:firefox)
90
+ b.goto 'http://google.com'
91
+ end
92
+ total_memory_kilobytes(result)
93
+ end
94
+ end
@@ -6,9 +6,9 @@ describe 'Utility Functions for the Grid' do
6
6
  :ring_server_port => 12353,
7
7
  :loglevel => Logger::ERROR)
8
8
  @controller.start
9
- 1.upto(1) do
9
+ 1.upto(1) do
10
10
  provider = Provider.new(
11
- :ring_server_port => 12353,
11
+ :ring_server_port => 12353,
12
12
  :loglevel => Logger::ERROR, :browser_type => 'safari')
13
13
  provider.start
14
14
  end
@@ -16,7 +16,7 @@ describe 'Utility Functions for the Grid' do
16
16
  grid.start(:read_all => true)
17
17
  @browser = grid.browsers[0]
18
18
  end
19
-
19
+
20
20
  after(:all) do
21
21
  @controller.stop
22
22
  end
@@ -34,19 +34,19 @@ describe 'Utility Functions for the Grid' do
34
34
  sleep 5
35
35
  @browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
36
36
  end
37
-
37
+
38
38
  it 'should be able to kill all firefox browsers' do
39
39
  @browser[:object].kill_browser('firefox-bin')
40
40
  @browser[:object].get_running_browsers(['firefox-bin']).size.should == 0
41
41
  end
42
-
42
+
43
43
  it 'should be able to start a new firefox browser specified by path' do
44
44
  @browser[:object].start_firefox_jssh
45
45
  ("/Applications/Firefox.app/Contents/MacOS/firefox-bin")
46
46
  sleep 5
47
47
  @browser[:object].get_running_browsers(['firefox-bin']).size.should == 1
48
48
  end
49
-
49
+
50
50
  it 'should be able to kill all browsers' do
51
51
  @browser[:object].kill_all_browsers
52
52
  @browser[:object].get_running_browsers.size.should == 0
@@ -5,9 +5,9 @@ describe 'Using the Grid with WebDriver' do
5
5
  :ring_server_port => 12356,
6
6
  :loglevel => Logger::ERROR)
7
7
  @controller.start
8
- 1.upto(1) do
8
+ 1.upto(1) do
9
9
  provider = Provider.new(
10
- :ring_server_port => 12356,
10
+ :ring_server_port => 12356,
11
11
  :loglevel => Logger::ERROR, :browser_type => 'webdriver')
12
12
  provider.start
13
13
  end
@@ -22,7 +22,7 @@ describe 'Using the Grid with WebDriver' do
22
22
  grid.start(:quantity => 1, :take_all => true)
23
23
  threads = []
24
24
  grid.browsers.each do |browser|
25
- threads << Thread.new do
25
+ threads << Thread.new do
26
26
  browser[:hostname].should == `hostname`.strip
27
27
  browser[:architecture].should == Config::CONFIG['arch']
28
28
  browser[:browser_type].should == 'webdriver'
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 = "0.0.9"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tim Koopmans"]
12
- s.date = %q{2011-02-16}
12
+ s.date = %q{2011-04-04}
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"]
@@ -33,11 +33,11 @@ Gem::Specification.new do |s|
33
33
  "examples/cucumber/step_definitions/example_steps.rb",
34
34
  "lib/controller.rb",
35
35
  "lib/extensions/remote.rb",
36
- "lib/extensions/selenium-server-standalone-2.0b1.jar",
37
36
  "lib/provider.rb",
38
37
  "lib/watirgrid.rb",
39
- "logo.png",
38
+ "rdoc/logo.png",
40
39
  "spec/grid_spec.rb",
40
+ "spec/memory_spec.rb",
41
41
  "spec/spec_helper.rb",
42
42
  "spec/utilities_spec.rb",
43
43
  "spec/webdriver_remote_spec.rb",
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
51
51
  s.summary = %q{WatirGrid: Web Application Testing in Ruby across a grid network.}
52
52
  s.test_files = [
53
53
  "spec/grid_spec.rb",
54
+ "spec/memory_spec.rb",
54
55
  "spec/spec_helper.rb",
55
56
  "spec/utilities_spec.rb",
56
57
  "spec/webdriver_remote_spec.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watirgrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
9
  - 0
9
- - 9
10
- version: 0.0.9
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Koopmans
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-16 00:00:00 +11:00
18
+ date: 2011-04-04 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -45,11 +45,11 @@ files:
45
45
  - examples/cucumber/step_definitions/example_steps.rb
46
46
  - lib/controller.rb
47
47
  - lib/extensions/remote.rb
48
- - lib/extensions/selenium-server-standalone-2.0b1.jar
49
48
  - lib/provider.rb
50
49
  - lib/watirgrid.rb
51
- - logo.png
50
+ - rdoc/logo.png
52
51
  - spec/grid_spec.rb
52
+ - spec/memory_spec.rb
53
53
  - spec/spec_helper.rb
54
54
  - spec/utilities_spec.rb
55
55
  - spec/webdriver_remote_spec.rb
@@ -91,6 +91,7 @@ specification_version: 3
91
91
  summary: "WatirGrid: Web Application Testing in Ruby across a grid network."
92
92
  test_files:
93
93
  - spec/grid_spec.rb
94
+ - spec/memory_spec.rb
94
95
  - spec/spec_helper.rb
95
96
  - spec/utilities_spec.rb
96
97
  - spec/webdriver_remote_spec.rb
File without changes