grid 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/grid +3 -16
- data/examples/testunit/basic_test.rb +2 -2
- data/grid.gemspec +2 -2
- data/lib/grid/grid.rb +52 -65
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/bin/grid
CHANGED
@@ -5,25 +5,20 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
options = {}
|
7
7
|
OptionParser.new do |opts|
|
8
|
-
opts.banner = "Usage: grid [options] command"
|
8
|
+
opts.banner = "Usage: grid [options] command [grid_id]"
|
9
9
|
opts.separator ""
|
10
10
|
opts.separator "Commands:"
|
11
11
|
opts.separator " list - List all grids"
|
12
12
|
opts.separator " show - Show specified grids"
|
13
13
|
opts.separator " create - Create a new grid"
|
14
|
-
opts.separator " add - Add intranode to specified grid ID"
|
15
|
-
opts.separator " delete - Delete intranode from specified grid ID"
|
16
14
|
opts.separator " start - Start specified grid ID"
|
17
15
|
opts.separator " stop - Stop specified grid ID"
|
18
16
|
opts.separator " restart - Restart specified grid ID"
|
19
17
|
opts.separator " status - Update status of specified grid ID"
|
20
18
|
opts.separator " token - Generate new access token"
|
19
|
+
opts.separator " credits - List available credits"
|
21
20
|
opts.separator ""
|
22
21
|
opts.separator "Options:"
|
23
|
-
opts.on("-g", "--grid ID", String,
|
24
|
-
"Specify the Grid ID to use") do |g|
|
25
|
-
options[:grid_id] = g || nil
|
26
|
-
end
|
27
22
|
opts.on("-t", "--token TOKEN", String,
|
28
23
|
"Specify the token to authenticate with") do |t|
|
29
24
|
options[:token] = t || nil
|
@@ -43,12 +38,6 @@ OptionParser.new do |opts|
|
|
43
38
|
http://gridin.it/api/v0 (default)") do |u|
|
44
39
|
options[:uri] = u || nil
|
45
40
|
end
|
46
|
-
opts.on("-a", "--api API", String,
|
47
|
-
"Specify the API to use:
|
48
|
-
watir, firewatir, webdriver (default)
|
49
|
-
webdriver_performance") do |a|
|
50
|
-
options[:api] = b || 'webdriver'
|
51
|
-
end
|
52
41
|
|
53
42
|
opts.on_tail("-h", "--help", "Show this message") do
|
54
43
|
puts opts
|
@@ -57,12 +46,10 @@ OptionParser.new do |opts|
|
|
57
46
|
end.parse!
|
58
47
|
|
59
48
|
helper = Grid::Helper.new(
|
60
|
-
:grid_id => options[:grid_id],
|
61
49
|
:token => options[:token],
|
62
50
|
:email => options[:email],
|
63
51
|
:password => options[:password],
|
64
52
|
:uri => options[:uri],
|
65
|
-
:api => options[:api],
|
66
53
|
:args => ARGV
|
67
54
|
)
|
68
|
-
helper.send
|
55
|
+
helper.send ARGV[0], ARGV[1]
|
@@ -4,7 +4,7 @@ require 'test/unit'
|
|
4
4
|
class SimpleTest < Test::Unit::TestCase
|
5
5
|
def setup
|
6
6
|
options = {}
|
7
|
-
options[:controller_uri] =
|
7
|
+
options[:controller_uri] = 'druby://10.0.1.3:11235'
|
8
8
|
options[:browser_type] = 'webdriver'
|
9
9
|
options[:browser] = 'chrome'
|
10
10
|
options[:loglevel] = Logger::DEBUG
|
@@ -18,7 +18,7 @@ class SimpleTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def test_google
|
20
20
|
@grid.iterate do |browser|
|
21
|
-
browser.goto
|
21
|
+
browser.goto 'altentee.com'
|
22
22
|
assert_match /Automation Company/, browser.title
|
23
23
|
end
|
24
24
|
end
|
data/grid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{grid}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.3"
|
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-
|
12
|
+
s.date = %q{2011-05-05}
|
13
13
|
s.default_executable = %q{grid}
|
14
14
|
s.description = %q{Gridinit command line utilities to help you use the Gridinit API}
|
15
15
|
s.email = %q{tim.koops@gmail.com}
|
data/lib/grid/grid.rb
CHANGED
@@ -93,14 +93,12 @@ class Grid
|
|
93
93
|
if params[:rampup]
|
94
94
|
params[:rampup] / @grid.size
|
95
95
|
else
|
96
|
-
0.
|
96
|
+
0.25
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
class Helper
|
101
101
|
def initialize(params = {})
|
102
|
-
@grid_id = params[:grid_id]
|
103
|
-
@api = params[:api]
|
104
102
|
@uri = params[:uri] || "http://gridin.it/api/v0"
|
105
103
|
logfile = STDOUT
|
106
104
|
@log = Logger.new(logfile, 'daily')
|
@@ -138,16 +136,16 @@ class Grid
|
|
138
136
|
homes.detect {|h| ENV[h] != nil}
|
139
137
|
end
|
140
138
|
|
141
|
-
def token
|
139
|
+
def token(args=nil)
|
142
140
|
@token = get_token
|
143
141
|
open(ENV[home]+'/.gridrc', 'w') { |f| f << "TOKEN:#{@token}" } if home and @token
|
144
142
|
@log.debug("New token : #{@token}")
|
145
143
|
end
|
146
144
|
|
147
|
-
def
|
148
|
-
@log.debug("Listing
|
145
|
+
def credits(args=nil)
|
146
|
+
@log.debug("Listing credits available ...")
|
149
147
|
begin
|
150
|
-
response = RestClient.get "#{@uri}/
|
148
|
+
response = RestClient.get "#{@uri}/credit.json" , {
|
151
149
|
:token => @token
|
152
150
|
}
|
153
151
|
ap JSON.parse(response)
|
@@ -156,11 +154,10 @@ class Grid
|
|
156
154
|
end
|
157
155
|
end
|
158
156
|
|
159
|
-
def
|
160
|
-
@
|
161
|
-
@log.debug("Listing grid ...")
|
157
|
+
def list(args=nil)
|
158
|
+
@log.debug("Listing grids ...")
|
162
159
|
begin
|
163
|
-
response = RestClient.get "#{@uri}/grid
|
160
|
+
response = RestClient.get "#{@uri}/grid.json" , {
|
164
161
|
:token => @token
|
165
162
|
}
|
166
163
|
ap JSON.parse(response)
|
@@ -169,114 +166,104 @@ class Grid
|
|
169
166
|
end
|
170
167
|
end
|
171
168
|
|
172
|
-
def
|
169
|
+
def show(grid_id=nil)
|
170
|
+
@grid_id = ( grid_id ? grid_id : ask("Grid ID: ") )
|
171
|
+
@log.debug("Listing grid ...")
|
173
172
|
begin
|
174
|
-
@
|
175
|
-
|
176
|
-
:token => @token,
|
177
|
-
:name => name,
|
178
|
-
:description => description
|
173
|
+
response = RestClient.get "#{@uri}/grid/#{@grid_id}.json" , {
|
174
|
+
:token => @token
|
179
175
|
}
|
180
|
-
|
176
|
+
ap JSON.parse(response)
|
181
177
|
rescue => e
|
182
178
|
@log.error("#{e}")
|
183
179
|
end
|
184
180
|
end
|
185
181
|
|
186
|
-
def
|
182
|
+
def create_grid(name, description, driver, location, total_nodes)
|
187
183
|
begin
|
188
|
-
@log.debug("Creating
|
189
|
-
response = RestClient.post "#{@uri}/grid
|
184
|
+
@log.debug("Creating grid ...")
|
185
|
+
response = RestClient.post "#{@uri}/grid.json" , {
|
190
186
|
:token => @token,
|
191
|
-
:
|
187
|
+
:name => name,
|
188
|
+
:description => description,
|
189
|
+
:driver => driver,
|
192
190
|
:location => location,
|
193
|
-
:
|
194
|
-
}
|
195
|
-
rescue => e
|
196
|
-
@log.error("#{e}")
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def delete_intranode
|
201
|
-
begin
|
202
|
-
@log.debug("Deleting intranode ...")
|
203
|
-
response = RestClient.delete "#{@uri}/grid/intranode/#{@intranode_id}.json", {
|
204
|
-
:token => @token
|
191
|
+
:total_nodes => total_nodes
|
205
192
|
}
|
193
|
+
(JSON.parse(response)).first[1]["id"]
|
206
194
|
rescue => e
|
207
195
|
@log.error("#{e}")
|
208
196
|
end
|
209
197
|
end
|
210
198
|
|
211
|
-
def create
|
199
|
+
def create(args=nil)
|
212
200
|
name = ask("Grid name: ") { |q| q.default = "Grid" }
|
213
201
|
description = ask("Grid description: ") { |q| q.default = "Grid created #{Time.now}" }
|
214
|
-
|
202
|
+
total_nodes = ask("Number of nodes: ") { |q| q.default = 5 }
|
215
203
|
location = ask("Location of nodes: ") { |q| q.default = "us-east" }
|
216
|
-
|
217
|
-
@grid_id = create_grid(name, description)
|
218
|
-
|
219
|
-
show
|
204
|
+
driver = ask("Driver: ") { |q| q.default = "webdriver" } unless @api
|
205
|
+
@grid_id = create_grid(name, description, driver, location, total_nodes)
|
206
|
+
show(@grid_id)
|
220
207
|
end
|
221
208
|
|
222
|
-
def
|
223
|
-
|
224
|
-
|
209
|
+
def launch(args=nil)
|
210
|
+
name = ask("Grid name: ") { |q| q.default = "Grid" }
|
211
|
+
description = ask("Grid description: ") { |q| q.default = "Grid created #{Time.now}" }
|
212
|
+
total_nodes = ask("Number of nodes: ") { |q| q.default = 5 }
|
225
213
|
location = ask("Location of nodes: ") { |q| q.default = "us-east" }
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
show
|
214
|
+
driver = ask("Driver: ") { |q| q.default = "webdriver" } unless @api
|
215
|
+
@grid_id = create_grid(name, description, driver, location, total_nodes)
|
216
|
+
@log.debug("Starting grid ...")
|
217
|
+
begin
|
218
|
+
response = RestClient.put "#{@uri}/grid/#{@grid_id.to_s}/start.json", {:token => @token}
|
219
|
+
rescue => e
|
220
|
+
@log.error("#{e}")
|
221
|
+
end
|
222
|
+
show(@grid_id)
|
236
223
|
end
|
237
224
|
|
238
|
-
def start
|
239
|
-
@grid_id = ask("Grid ID: ")
|
225
|
+
def start(grid_id=nil)
|
226
|
+
@grid_id = ( grid_id ? grid_id : ask("Grid ID: ") )
|
240
227
|
@log.debug("Starting grid ...")
|
241
228
|
begin
|
242
229
|
response = RestClient.put "#{@uri}/grid/#{@grid_id.to_s}/start.json", {:token => @token}
|
243
230
|
rescue => e
|
244
231
|
@log.error("#{e}")
|
245
232
|
end
|
246
|
-
show
|
233
|
+
show(@grid_id)
|
247
234
|
end
|
248
235
|
|
249
|
-
def stop
|
250
|
-
@grid_id = ask("Grid ID: ")
|
236
|
+
def stop(grid_id=nil)
|
237
|
+
@grid_id = ( grid_id ? grid_id : ask("Grid ID: ") )
|
251
238
|
@log.debug("Stopping grid ...")
|
252
239
|
begin
|
253
240
|
response = RestClient.put "#{@uri}/grid/#{@grid_id.to_s}/stop.json", {:token => @token}
|
254
241
|
rescue => e
|
255
242
|
@log.error("#{e}")
|
256
243
|
end
|
257
|
-
show
|
244
|
+
show(@grid_id)
|
258
245
|
end
|
259
246
|
|
260
|
-
def restart
|
261
|
-
@grid_id = ask("Grid ID: ")
|
247
|
+
def restart(grid_id=nil)
|
248
|
+
@grid_id = ( grid_id ? grid_id : ask("Grid ID: ") )
|
262
249
|
@log.debug("Restarting grid ...")
|
263
250
|
begin
|
264
251
|
response = RestClient.put "#{@uri}/grid/#{@grid_id.to_s}/restart.json", {:token => @token}
|
265
252
|
rescue => e
|
266
253
|
@log.error("#{e}")
|
267
254
|
end
|
268
|
-
show
|
255
|
+
show(@grid_id)
|
269
256
|
end
|
270
257
|
|
271
|
-
def status
|
272
|
-
@grid_id = ask("Grid ID: ")
|
258
|
+
def status(grid_id=nil)
|
259
|
+
@grid_id = ( grid_id ? grid_id : ask("Grid ID: ") )
|
273
260
|
@log.debug("Updating status of grid ...")
|
274
261
|
begin
|
275
262
|
response = RestClient.put "#{@uri}/grid/#{@grid_id.to_s}/status.json", {:token => @token}
|
276
263
|
rescue => e
|
277
264
|
@log.error("#{e}")
|
278
265
|
end
|
279
|
-
show
|
266
|
+
show(@grid_id)
|
280
267
|
end
|
281
268
|
|
282
269
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
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-
|
18
|
+
date: 2011-05-05 00:00:00 +10:00
|
19
19
|
default_executable: grid
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|