stella 0.8.8.001 → 2.0.1.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +9 -1
- data/Gemfile +19 -0
- data/Gemfile.lock +50 -0
- data/README.md +5 -79
- data/Rakefile +10 -7
- data/Rudyfile +1 -1
- data/TODO +31 -0
- data/VERSION.yml +3 -4
- data/bin/stella +23 -81
- data/certs/README.txt +17 -0
- data/certs/cacerts.pem +1529 -0
- data/certs/gd-class2-root.crt +24 -0
- data/certs/gd_bundle.crt +76 -0
- data/certs/gd_intermediate.crt +29 -0
- data/certs/startssl-ca.pem +44 -0
- data/certs/startssl-sub.class1.server.ca.pem +36 -0
- data/certs/stella-master.crt +1738 -0
- data/lib/stella.rb +191 -123
- data/lib/stella/cli.rb +47 -67
- data/lib/stella/client.rb +424 -360
- data/lib/stella/core_ext.rb +527 -0
- data/lib/stella/engine.rb +126 -419
- data/lib/stella/report.rb +391 -0
- data/lib/stella/testplan.rb +432 -306
- data/lib/stella/utils.rb +227 -2
- data/stella.gemspec +56 -55
- data/try/00_basics_try.rb +29 -0
- data/try/01_selectable_try.rb +25 -0
- data/try/09_utils_try.rb +67 -0
- data/try/10_stella_object_try.rb +49 -0
- data/try/40_report_try.rb +133 -0
- data/try/90_class_syntax_try.rb +13 -0
- data/try/emhttp.rb +62 -0
- data/try/rubyroute.rb +70 -0
- data/try/support/file.bmp +0 -0
- data/try/support/file.gif +0 -0
- data/try/support/file.ico +0 -0
- data/try/support/file.jpeg +0 -0
- data/try/support/file.jpg +0 -0
- data/try/support/file.png +0 -0
- data/try/traceviz.rb +60 -0
- data/vendor/httpclient-2.1.5.2/httpclient/session.rb +5 -2
- metadata +81 -53
- data/examples/cookies/plan.rb +0 -49
- data/examples/csvdata/plan.rb +0 -32
- data/examples/csvdata/search_terms.csv +0 -14
- data/examples/dynamic/plan.rb +0 -60
- data/examples/essentials/logo.png +0 -0
- data/examples/essentials/plan.rb +0 -248
- data/examples/essentials/search_terms.txt +0 -19
- data/examples/exceptions/plan.rb +0 -20
- data/examples/httpauth/plan.rb +0 -33
- data/examples/timeout/plan.rb +0 -18
- data/examples/variables/plan.rb +0 -41
- data/lib/stella/client/container.rb +0 -378
- data/lib/stella/common.rb +0 -363
- data/lib/stella/data.rb +0 -59
- data/lib/stella/data/http.rb +0 -189
- data/lib/stella/engine/functional.rb +0 -156
- data/lib/stella/engine/load.rb +0 -516
- data/lib/stella/guidelines.rb +0 -18
- data/lib/stella/logger.rb +0 -150
- data/lib/stella/utils/httputil.rb +0 -266
- data/try/01_numeric_mixins_tryouts.rb +0 -40
- data/try/12_digest_tryouts.rb +0 -42
- data/try/70_module_usage.rb +0 -21
- data/try/api/10_functional.rb +0 -20
- data/try/configs/failed_requests.rb +0 -31
- data/try/configs/global_sequential.rb +0 -18
- data/try/proofs/thread_queue.rb +0 -21
data/examples/exceptions/plan.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Exception Handling (2009-10-08)
|
2
|
-
#
|
3
|
-
# TO BE DOCUMENTED.
|
4
|
-
#
|
5
|
-
# If you're reading this, remind me!
|
6
|
-
#
|
7
|
-
|
8
|
-
usecase "Exception Handling" do
|
9
|
-
|
10
|
-
get "/search", "Search Results" do
|
11
|
-
param :what => 'No Such Listing'
|
12
|
-
param :where => random(['Toronto', 'Montreal', 'Vancouver'])
|
13
|
-
response 404 do
|
14
|
-
fail "No results"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
# 0f354b3579e6c5b5b3f303aabb2ac3aa5b11096a
|
data/examples/httpauth/plan.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Stella Test Plan - HTTP Authentication (2011-02-26)
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# 1. START THE EXAMPLE APPLICATION
|
5
|
-
#
|
6
|
-
# This test plan is written to work with the
|
7
|
-
# example application at bff.heroku.com.
|
8
|
-
#
|
9
|
-
#
|
10
|
-
# 2. RUN THE TEST PLAN
|
11
|
-
#
|
12
|
-
# $ stella verify -p examples/httpauth/plan.rb http://bff.heroku.com/
|
13
|
-
#
|
14
|
-
usecase "Use basic HTTP authentication" do
|
15
|
-
|
16
|
-
auth 'stella', 'why??'
|
17
|
-
|
18
|
-
get '/admin' do
|
19
|
-
response 401 do
|
20
|
-
# Called if authentication fails
|
21
|
-
end
|
22
|
-
response 200 do
|
23
|
-
# Called if authentication succeeds
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# You can also set the HTTP auth per request.
|
28
|
-
# Note that here we give an incorrect password.
|
29
|
-
get '/admin' do
|
30
|
-
auth 'stella', 'badpassword'
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/examples/timeout/plan.rb
DELETED
data/examples/variables/plan.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Using Variables (2009-12-04)
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# 1. START THE EXAMPLE APPLICATION
|
5
|
-
#
|
6
|
-
# This test plan is written to work with the
|
7
|
-
# example application that ships with Stella.
|
8
|
-
# See:
|
9
|
-
#
|
10
|
-
# $ stella example
|
11
|
-
#
|
12
|
-
# 2. RUN THE TESTPLAN
|
13
|
-
#
|
14
|
-
# $ stella --var globalvar=smoked verify -p examples/variables/plan.rb
|
15
|
-
#
|
16
|
-
#
|
17
|
-
usecase "Form Example" do
|
18
|
-
set :uri => 'http://localhost:3114'
|
19
|
-
set :apple => resource(:globalvar)
|
20
|
-
|
21
|
-
# Variables can be used in the request URIs. Stella looks
|
22
|
-
# for a replacement value in the usecase resources, then
|
23
|
-
# in the params, and then in global variables.
|
24
|
-
get ":uri" do
|
25
|
-
end
|
26
|
-
|
27
|
-
# URI variables can also be specified with a dollar sign.
|
28
|
-
get "$uri/search" do
|
29
|
-
param :what => resource(:globalvar)
|
30
|
-
response do
|
31
|
-
if resource(:globalvar).nil?
|
32
|
-
abort "Usage: stella --var globalvar=smoked verify -p examples/variables/plan.rb"
|
33
|
-
end
|
34
|
-
puts " Global variable: " << resource(:globalvar)
|
35
|
-
puts " Usecase variable: " << resource(:uri)
|
36
|
-
puts " Usecase copy of global: " << resource(:apple)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
@@ -1,378 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Stella::Client
|
4
|
-
|
5
|
-
class Container
|
6
|
-
MUTEX = Mutex.new
|
7
|
-
|
8
|
-
@sequential_offset = {}
|
9
|
-
@rsequential_offset = {}
|
10
|
-
class << self
|
11
|
-
def sequential_offset(resid, max)
|
12
|
-
MUTEX.synchronize do
|
13
|
-
@sequential_offset[resid] ||= -1
|
14
|
-
if @sequential_offset[resid] >= max
|
15
|
-
@sequential_offset[resid] = 0
|
16
|
-
else
|
17
|
-
@sequential_offset[resid] += 1
|
18
|
-
end
|
19
|
-
@sequential_offset[resid]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def rsequential_offset(resid, max)
|
24
|
-
MUTEX.synchronize do
|
25
|
-
@rsequential_offset[resid] ||= max+1
|
26
|
-
if @rsequential_offset[resid] <= 0
|
27
|
-
@rsequential_offset[resid] = max
|
28
|
-
else
|
29
|
-
@rsequential_offset[resid] -= 1
|
30
|
-
end
|
31
|
-
@rsequential_offset[resid]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# This is used to handle custom exception in usecases.
|
37
|
-
# See examples/exceptions/plan.rb
|
38
|
-
#
|
39
|
-
def self.const_missing(custom_error)
|
40
|
-
ResponseError.new custom_error
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
attr_accessor :usecase
|
45
|
-
attr_accessor :params
|
46
|
-
attr_accessor :headers
|
47
|
-
attr_accessor :response
|
48
|
-
attr_accessor :unique_id
|
49
|
-
attr_reader :resources
|
50
|
-
attr_reader :client_id
|
51
|
-
attr_reader :assets
|
52
|
-
|
53
|
-
def initialize(client_id, usecase)
|
54
|
-
@client_id = client_id
|
55
|
-
@usecase, @resources = usecase, {}
|
56
|
-
@base_path = usecase.base_path
|
57
|
-
@assets = []
|
58
|
-
@random_value = {}
|
59
|
-
end
|
60
|
-
|
61
|
-
def params(key=nil)
|
62
|
-
key.nil? ? @params : @params[key]
|
63
|
-
end
|
64
|
-
alias_method :param, :params
|
65
|
-
|
66
|
-
def headers(key=nil)
|
67
|
-
key.nil? ? @headers : @headers[key]
|
68
|
-
end
|
69
|
-
alias_method :header, :headers
|
70
|
-
|
71
|
-
# This is intended to be called in between requests.
|
72
|
-
def reset_temp_vars
|
73
|
-
@random_value = {}
|
74
|
-
@sequential_value = {}
|
75
|
-
@rsequential_value = {}
|
76
|
-
@doc, @forms, @assets = nil, nil, []
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
def fetch(*args)
|
82
|
-
@assets.push *args.flatten
|
83
|
-
end
|
84
|
-
|
85
|
-
def parse_template(t)
|
86
|
-
# ERB BUG?: Under heavy threading, some calls
|
87
|
-
# produce the error:
|
88
|
-
# wrong number of arguments(1 for 0)
|
89
|
-
v = t.result(binding)
|
90
|
-
rescue => ex
|
91
|
-
Stella.ld ex.message, ex.backtrace
|
92
|
-
t.to_s
|
93
|
-
end
|
94
|
-
|
95
|
-
def doc
|
96
|
-
return @doc unless @doc.nil?
|
97
|
-
return nil if body.nil? || body.empty?
|
98
|
-
str = RUBY_VERSION >= "1.9.0" ? body.force_encoding("UTF-8") : body
|
99
|
-
# NOTE: It's important to parse the document on every
|
100
|
-
# request because this container is available for the
|
101
|
-
# entire life of a usecase.
|
102
|
-
@doc = case (@response.header['Content-Type'] || []).first
|
103
|
-
when /text\/html/
|
104
|
-
Nokogiri::HTML(str)
|
105
|
-
when /text\/xml/
|
106
|
-
Nokogiri::XML(str)
|
107
|
-
when /text\/yaml/
|
108
|
-
YAML.load(str)
|
109
|
-
when /application\/json/
|
110
|
-
JSON.load(str)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class Form < Hash
|
115
|
-
def fields(key)
|
116
|
-
self['input'] ||= {}
|
117
|
-
self['input'][key]
|
118
|
-
end
|
119
|
-
alias_method :field, :fields
|
120
|
-
class << self
|
121
|
-
# Create an instance from a Nokogiri::HTML::Document
|
122
|
-
def from_doc(doc)
|
123
|
-
f = new
|
124
|
-
doc.each { |n,v| f[n] = v }
|
125
|
-
f['input'] = {}
|
126
|
-
(doc.css('input') || []).each do |input|
|
127
|
-
f['input'][input['name']] = input['value']
|
128
|
-
end
|
129
|
-
f
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
def forms(fid=nil)
|
136
|
-
if @forms.nil? && Nokogiri::HTML::Document === doc
|
137
|
-
@forms, index = {}, 0
|
138
|
-
(doc.css('form') || []).each do |html|
|
139
|
-
name = html['id'] || html['name'] || html['class']
|
140
|
-
Stella.ld [:form, name, index].inspect
|
141
|
-
# Store the form by the name and index in the document
|
142
|
-
@forms[name] = @forms[index] = Form.from_doc(html)
|
143
|
-
index += 1
|
144
|
-
end
|
145
|
-
end
|
146
|
-
(fid.nil? ? @forms : @forms[fid])
|
147
|
-
end
|
148
|
-
alias_method :form, :forms
|
149
|
-
|
150
|
-
# Return a resource from this container or from
|
151
|
-
# the usecase (in that order). Otherwise, nil.
|
152
|
-
def resource(n)
|
153
|
-
n &&= n.to_sym
|
154
|
-
v = @resources.has_key?(n) ? @resources[n] : @usecase.resource(n)
|
155
|
-
v = Stella::Testplan.global(n) if Stella::Testplan.global?(n)
|
156
|
-
v
|
157
|
-
end
|
158
|
-
|
159
|
-
def resource?(n)
|
160
|
-
!resource(n).nil?
|
161
|
-
end
|
162
|
-
|
163
|
-
def body; @response.body.content; end
|
164
|
-
def headers; @response.header; end
|
165
|
-
alias_method :header, :headers
|
166
|
-
def status; @response.status; end
|
167
|
-
def set(name, *args)
|
168
|
-
if Hash === name
|
169
|
-
Stella.ld "ARGS IGNORED: #{args.inspect} (#{caller[0]})" if !args.empty?
|
170
|
-
@resources.merge! name
|
171
|
-
elsif !name.nil? && !args.empty?
|
172
|
-
@resources.merge!({name => args[0]})
|
173
|
-
end
|
174
|
-
end
|
175
|
-
def wait(t); sleep t; end
|
176
|
-
def quit(msg=nil); Quit.new(msg); end
|
177
|
-
def fail(msg=nil); Fail.new(msg); end
|
178
|
-
def error(msg=nil); Error.new(msg); end
|
179
|
-
def repeat(t=1); Repeat.new(t); end
|
180
|
-
def follow(uri=nil,&blk); Follow.new(uri,&blk); end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
#
|
185
|
-
# QUICK HACK ALERT:
|
186
|
-
# Copied from Stella::Data::Helpers, removed Proc.new, just return the value
|
187
|
-
#
|
188
|
-
|
189
|
-
|
190
|
-
# Can include glob
|
191
|
-
#
|
192
|
-
# e.g.
|
193
|
-
# random_file('avatar*')
|
194
|
-
def random_file(*args)
|
195
|
-
input = args.size > 1 ? args : args.first
|
196
|
-
|
197
|
-
value = case input.class.to_s
|
198
|
-
when "String"
|
199
|
-
Stella.ld "FILE: #{input}"
|
200
|
-
path = File.exists?(input) ? input : File.join(@base_path, input)
|
201
|
-
files = Dir.glob(path)
|
202
|
-
path = files[ rand(files.size) ]
|
203
|
-
Stella.ld "Creating file object: #{path}"
|
204
|
-
File.new(path)
|
205
|
-
when "Proc"
|
206
|
-
input.call
|
207
|
-
else
|
208
|
-
input
|
209
|
-
end
|
210
|
-
raise Stella::Testplan::Usecase::UnknownResource, input if value.nil?
|
211
|
-
Stella.ld "FILE: #{value}"
|
212
|
-
value
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
def file(*args)
|
217
|
-
input = args.size > 1 ? args : args.first
|
218
|
-
value = case input.class.to_s
|
219
|
-
when "String"
|
220
|
-
Stella.ld "FILE: #{input}"
|
221
|
-
path = File.exists?(input) ? input : File.join(@base_path, input)
|
222
|
-
Stella.ld "Creating file object: #{path}"
|
223
|
-
File.new(path)
|
224
|
-
when "Proc"
|
225
|
-
input.call
|
226
|
-
else
|
227
|
-
input
|
228
|
-
end
|
229
|
-
raise Stella::Testplan::Usecase::UnknownResource, input if value.nil?
|
230
|
-
Stella.ld "FILE: #{value}"
|
231
|
-
value
|
232
|
-
|
233
|
-
end
|
234
|
-
|
235
|
-
def path(*args)
|
236
|
-
input = File.join *args
|
237
|
-
File.exists?(input) ? input : File.join(@base_path, input)
|
238
|
-
end
|
239
|
-
|
240
|
-
def read_file(*args)
|
241
|
-
f = file *args
|
242
|
-
f.read
|
243
|
-
end
|
244
|
-
|
245
|
-
def random(*args)
|
246
|
-
input, idxcol = *std_arg_processor(*args)
|
247
|
-
input.digest
|
248
|
-
if @random_value[input.digest_cache]
|
249
|
-
value = @random_value[input.digest_cache]
|
250
|
-
else
|
251
|
-
value = case input.class.to_s
|
252
|
-
when "Symbol"
|
253
|
-
resource(input)
|
254
|
-
when "Array"
|
255
|
-
input
|
256
|
-
when "Range"
|
257
|
-
input.to_a
|
258
|
-
when "Proc"
|
259
|
-
input.call
|
260
|
-
when "Fixnum"
|
261
|
-
Stella::Utils.strand( input )
|
262
|
-
when "NilClass"
|
263
|
-
Stella::Utils.strand( rand(100) )
|
264
|
-
end
|
265
|
-
raise Stella::Testplan::Usecase::UnknownResource, input if value.nil?
|
266
|
-
Stella.ld "RANDVALUES: #{input} #{value.class} #{value.inspect}"
|
267
|
-
value = value[ rand(value.size) ] if value.is_a?(Array)
|
268
|
-
Stella.ld "SELECTED: #{value.class} #{value} "
|
269
|
-
@random_value[input.digest_cache] = value
|
270
|
-
end
|
271
|
-
|
272
|
-
# The resource may be an Array of Arrays (e.g. a CSV file)
|
273
|
-
if value.is_a?(Array) && !idxcol.nil?
|
274
|
-
value = value[ idxcol ]
|
275
|
-
Stella.ld "SELECTED INDEX: #{idxcol} #{value.inspect} "
|
276
|
-
end
|
277
|
-
|
278
|
-
value
|
279
|
-
|
280
|
-
end
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
# NOTE: This is global across all users
|
285
|
-
def sequential(*args)
|
286
|
-
input, idxcol = *std_arg_processor(*args)
|
287
|
-
input.digest # prime the cache
|
288
|
-
if @sequential_value[input.digest_cache]
|
289
|
-
value = @sequential_value[input.digest_cache]
|
290
|
-
else
|
291
|
-
value = case input.class.to_s
|
292
|
-
when "Symbol"
|
293
|
-
ret = resource(input)
|
294
|
-
ret
|
295
|
-
when "Array"
|
296
|
-
input
|
297
|
-
when "Range"
|
298
|
-
input.to_a
|
299
|
-
when "Proc"
|
300
|
-
input.call
|
301
|
-
end
|
302
|
-
digest = value.digest
|
303
|
-
if value.is_a?(Array)
|
304
|
-
vsize = value.size
|
305
|
-
idxrow = Stella::Client::Container.sequential_offset(digest, value.size-1)
|
306
|
-
value = value[ idxrow ]
|
307
|
-
Stella.ld "SELECTED(SEQ): #{value} #{idxrow} (of #{vsize-1}) #{input} #{digest}"
|
308
|
-
end
|
309
|
-
# I think this needs to be updated for global_sequential:
|
310
|
-
@sequential_value[input.digest_cache] = value
|
311
|
-
end
|
312
|
-
# The resource may be an Array of Arrays (e.g. a CSV file)
|
313
|
-
if value.is_a?(Array) && !idxcol.nil?
|
314
|
-
value = value[ idxcol ]
|
315
|
-
Stella.ld "SELECTED INDEX: #{idxcol} #{value.inspect} "
|
316
|
-
end
|
317
|
-
|
318
|
-
value
|
319
|
-
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
# NOTE: This is global across all users
|
324
|
-
def rsequential(*args)
|
325
|
-
input, idxcol = *std_arg_processor(*args)
|
326
|
-
input.digest
|
327
|
-
if @rsequential_value[input.digest_cache]
|
328
|
-
value = @rsequential_value[input.digest_cache]
|
329
|
-
else
|
330
|
-
value = case input.class.to_s
|
331
|
-
when "Symbol"
|
332
|
-
ret = resource(input)
|
333
|
-
ret
|
334
|
-
when "Array"
|
335
|
-
input
|
336
|
-
when "Range"
|
337
|
-
input.to_a
|
338
|
-
when "Proc"
|
339
|
-
input.call
|
340
|
-
end
|
341
|
-
digest = value.digest
|
342
|
-
if value.is_a?(Array)
|
343
|
-
idxrow = Stella::Client::Container.rsequential_offset(digest, value.size-1)
|
344
|
-
value = value[ idxrow ]
|
345
|
-
Stella.ld "SELECTED(RSEQ): #{value} #{idxrow} #{input} #{digest}"
|
346
|
-
end
|
347
|
-
|
348
|
-
# I think this needs to be updated for global_sequential:
|
349
|
-
@rsequential_value[input.digest_cache] = value
|
350
|
-
end
|
351
|
-
# The resource may be an Array of Arrays (e.g. a CSV file)
|
352
|
-
if value.is_a?(Array) && !idxcol.nil?
|
353
|
-
value = value[ idxcol ]
|
354
|
-
Stella.ld "SELECTED INDEX: #{idxcol} #{value.inspect} "
|
355
|
-
end
|
356
|
-
value
|
357
|
-
|
358
|
-
end
|
359
|
-
|
360
|
-
|
361
|
-
private
|
362
|
-
|
363
|
-
def std_arg_processor(*args)
|
364
|
-
input, idxcol = nil, nil
|
365
|
-
if Symbol === args.first
|
366
|
-
input, idxcol = *args
|
367
|
-
elsif Array === args.first || args.size == 1
|
368
|
-
input = args.first
|
369
|
-
else
|
370
|
-
input = args
|
371
|
-
end
|
372
|
-
[input, idxcol]
|
373
|
-
end
|
374
|
-
|
375
|
-
|
376
|
-
end
|
377
|
-
|
378
|
-
end
|