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
@@ -524,6 +524,10 @@ class HTTPClient
|
|
524
524
|
# Send a request to the server
|
525
525
|
def query(req)
|
526
526
|
connect if @state == :INIT
|
527
|
+
send_request(req)
|
528
|
+
end
|
529
|
+
|
530
|
+
def send_request(req)
|
527
531
|
req.header.request_via_proxy = !@proxy.nil?
|
528
532
|
begin
|
529
533
|
timeout(@send_timeout, SendTimeoutError) do
|
@@ -550,7 +554,7 @@ class HTTPClient
|
|
550
554
|
@next_connection = nil
|
551
555
|
@requests.push(req)
|
552
556
|
end
|
553
|
-
|
557
|
+
|
554
558
|
def close
|
555
559
|
if !@socket.nil? and !@socket.closed?
|
556
560
|
# @socket.flush may block when it the socket is already closed by
|
@@ -596,7 +600,6 @@ class HTTPClient
|
|
596
600
|
else
|
597
601
|
ret = read_body_rest(&block)
|
598
602
|
end
|
599
|
-
p [:ret, ret.encoding.name] if ret
|
600
603
|
rescue
|
601
604
|
close
|
602
605
|
raise
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: stella
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 2.0.1.001
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Delano Mandelbaum
|
@@ -10,55 +10,55 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-08 00:00:00 -04:00
|
14
14
|
default_executable: stella
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: familia
|
18
18
|
prerelease: false
|
19
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.
|
24
|
+
version: 0.7.1
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: gibbler
|
29
29
|
prerelease: false
|
30
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.8.9
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
|
-
name:
|
39
|
+
name: drydock
|
40
40
|
prerelease: false
|
41
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.6.9
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: benelux
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.6.1
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
|
-
name:
|
61
|
+
name: sysinfo
|
62
62
|
prerelease: false
|
63
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
@@ -69,17 +69,50 @@ dependencies:
|
|
69
69
|
type: :runtime
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: storable
|
73
73
|
prerelease: false
|
74
74
|
requirement: &id006 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
79
|
+
version: 0.8.8
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id006
|
82
|
-
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: nokogiri
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.4.4
|
91
|
+
type: :runtime
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: public_suffix_service
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.8.1
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: whois
|
106
|
+
prerelease: false
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.6.6
|
113
|
+
type: :runtime
|
114
|
+
version_requirements: *id009
|
115
|
+
description: Define realistic testplans and run them against your webapps
|
83
116
|
email: delano@solutious.com
|
84
117
|
executables:
|
85
118
|
- stella
|
@@ -88,53 +121,55 @@ extensions: []
|
|
88
121
|
extra_rdoc_files:
|
89
122
|
- LICENSE.txt
|
90
123
|
- README.md
|
124
|
+
- TODO
|
91
125
|
files:
|
92
126
|
- .gitignore
|
93
127
|
- .gitmodules
|
94
128
|
- CHANGES.txt
|
129
|
+
- Gemfile
|
130
|
+
- Gemfile.lock
|
95
131
|
- LICENSE.txt
|
96
132
|
- README.md
|
97
133
|
- Rakefile
|
98
134
|
- Rudyfile
|
135
|
+
- TODO
|
99
136
|
- VERSION.yml
|
100
137
|
- bin/stella
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
109
|
-
- examples/httpauth/plan.rb
|
110
|
-
- examples/timeout/plan.rb
|
111
|
-
- examples/variables/plan.rb
|
138
|
+
- certs/README.txt
|
139
|
+
- certs/cacerts.pem
|
140
|
+
- certs/gd-class2-root.crt
|
141
|
+
- certs/gd_bundle.crt
|
142
|
+
- certs/gd_intermediate.crt
|
143
|
+
- certs/startssl-ca.pem
|
144
|
+
- certs/startssl-sub.class1.server.ca.pem
|
145
|
+
- certs/stella-master.crt
|
112
146
|
- lib/stella.rb
|
113
147
|
- lib/stella/cli.rb
|
114
148
|
- lib/stella/client.rb
|
115
|
-
- lib/stella/
|
116
|
-
- lib/stella/common.rb
|
117
|
-
- lib/stella/data.rb
|
118
|
-
- lib/stella/data/http.rb
|
149
|
+
- lib/stella/core_ext.rb
|
119
150
|
- lib/stella/engine.rb
|
120
|
-
- lib/stella/
|
121
|
-
- lib/stella/engine/load.rb
|
122
|
-
- lib/stella/guidelines.rb
|
123
|
-
- lib/stella/logger.rb
|
151
|
+
- lib/stella/report.rb
|
124
152
|
- lib/stella/testplan.rb
|
125
153
|
- lib/stella/utils.rb
|
126
|
-
- lib/stella/utils/httputil.rb
|
127
154
|
- stella.gemspec
|
128
155
|
- support/sample_webapp/app.rb
|
129
156
|
- support/sample_webapp/config.ru
|
130
157
|
- support/useragents.txt
|
131
|
-
- try/
|
132
|
-
- try/
|
133
|
-
- try/
|
134
|
-
- try/
|
135
|
-
- try/
|
136
|
-
- try/
|
137
|
-
- try/
|
158
|
+
- try/00_basics_try.rb
|
159
|
+
- try/01_selectable_try.rb
|
160
|
+
- try/09_utils_try.rb
|
161
|
+
- try/10_stella_object_try.rb
|
162
|
+
- try/40_report_try.rb
|
163
|
+
- try/90_class_syntax_try.rb
|
164
|
+
- try/emhttp.rb
|
165
|
+
- try/rubyroute.rb
|
166
|
+
- try/support/file.bmp
|
167
|
+
- try/support/file.gif
|
168
|
+
- try/support/file.ico
|
169
|
+
- try/support/file.jpeg
|
170
|
+
- try/support/file.jpg
|
171
|
+
- try/support/file.png
|
172
|
+
- try/traceviz.rb
|
138
173
|
- vendor/httpclient-2.1.5.2/httpclient.rb
|
139
174
|
- vendor/httpclient-2.1.5.2/httpclient/auth.rb
|
140
175
|
- vendor/httpclient-2.1.5.2/httpclient/cacert.p7s
|
@@ -147,7 +182,7 @@ files:
|
|
147
182
|
- vendor/httpclient-2.1.5.2/httpclient/timeout.rb
|
148
183
|
- vendor/httpclient-2.1.5.2/httpclient/util.rb
|
149
184
|
has_rdoc: true
|
150
|
-
homepage: http://
|
185
|
+
homepage: http://github.com/solutious/stella
|
151
186
|
licenses: []
|
152
187
|
|
153
188
|
post_install_message:
|
@@ -173,13 +208,6 @@ rubyforge_project: stella
|
|
173
208
|
rubygems_version: 1.5.2
|
174
209
|
signing_key:
|
175
210
|
specification_version: 3
|
176
|
-
summary:
|
177
|
-
test_files:
|
178
|
-
|
179
|
-
- examples/csvdata/plan.rb
|
180
|
-
- examples/dynamic/plan.rb
|
181
|
-
- examples/essentials/plan.rb
|
182
|
-
- examples/exceptions/plan.rb
|
183
|
-
- examples/httpauth/plan.rb
|
184
|
-
- examples/timeout/plan.rb
|
185
|
-
- examples/variables/plan.rb
|
211
|
+
summary: Define realistic testplans and run them against your webapps
|
212
|
+
test_files: []
|
213
|
+
|
data/examples/cookies/plan.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Cookies (2009-10-08)
|
2
|
-
#
|
3
|
-
# 1. START THE EXAMPLE APPLICATION
|
4
|
-
#
|
5
|
-
# This test plan is written to work with the
|
6
|
-
# example application that ships with Stella.
|
7
|
-
# See:
|
8
|
-
#
|
9
|
-
# $ stella example
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# 2. RUN THE TEST PLAN
|
13
|
-
#
|
14
|
-
# $ stella verify -p examples/cookies/plan.rb http://127.0.0.1:3114/
|
15
|
-
#
|
16
|
-
desc "Cookies Examples"
|
17
|
-
|
18
|
-
usecase "Temporary Cookies" do
|
19
|
-
|
20
|
-
# By default, Stella keeps temporary cookies available within
|
21
|
-
# a single usecase. The example application creates a cookie
|
22
|
-
# called "bff-history" that contains the most recent search
|
23
|
-
# terms. Before we run a search request, the cookie is empty.
|
24
|
-
get "/", "Homepage" do
|
25
|
-
response do
|
26
|
-
puts "COOKIE: " << headers['Set-Cookie'].first
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Here the cookie will contain the search term
|
31
|
-
get "/search", "Search" do
|
32
|
-
param :what => random(['Big', 'Beads', 'Joe'])
|
33
|
-
response do
|
34
|
-
puts "COOKIE: " << headers['Set-Cookie'].first
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# And if we check the homepage again, the homepage now contains
|
39
|
-
# a list of the most recent search terms. This shows how Stella
|
40
|
-
# automatically sends the temporary cookie within a usecase.
|
41
|
-
get "/", "Homepage" do
|
42
|
-
response 200 do
|
43
|
-
puts "You searched for: " << doc.css('ul#history a').first.content
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
# 2440c77ed4382b97fcbb3b1cfbc3be5d7ef3653f
|
data/examples/csvdata/plan.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Reading CSV Data (2010-01-16)
|
2
|
-
#
|
3
|
-
# TO BE DOCUMENTED.
|
4
|
-
#
|
5
|
-
# If you're reading this, remind me!
|
6
|
-
#
|
7
|
-
|
8
|
-
usecase "Reading CSV Data" do
|
9
|
-
resource :search_terms, csv('search_terms.csv')
|
10
|
-
|
11
|
-
get "/search", "Search (random)" do
|
12
|
-
param :what => random(:search_terms, 0)
|
13
|
-
param :where => random(:search_terms, 1)
|
14
|
-
end
|
15
|
-
|
16
|
-
get "/search", "Search (sequential #1)" do
|
17
|
-
param :what => sequential(:search_terms, 0)
|
18
|
-
param :where => sequential(:search_terms, 1)
|
19
|
-
end
|
20
|
-
|
21
|
-
get "/search", "Search (sequential #2)" do
|
22
|
-
param :what => sequential(:search_terms, 0)
|
23
|
-
param :where => sequential(:search_terms, 1)
|
24
|
-
end
|
25
|
-
|
26
|
-
get "/search", "Search (sequential #3)" do
|
27
|
-
param :what => sequential(:search_terms, 0)
|
28
|
-
param :where => sequential(:search_terms, 1)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# d93df136283f3867f462266a98675ce0b2f51b08
|
data/examples/dynamic/plan.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Dynamic Data (2009-11-28)
|
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
|
-
#
|
13
|
-
# 2. RUN THE TEST PLAN
|
14
|
-
#
|
15
|
-
# $ stella verify -p examples/dynamic/plan.rb http://127.0.0.1:3114/
|
16
|
-
#
|
17
|
-
# $ stella generate -c 2 -r 2 -p examples/dynamic/plan.rb http://127.0.0.1:3114/
|
18
|
-
#
|
19
|
-
usecase "Dynamic Data" do
|
20
|
-
|
21
|
-
# Specify HTTP Authentication (Basic or Digest).
|
22
|
-
# Specify a username, password, and optional value
|
23
|
-
# to use for the authentication domain. If no domain
|
24
|
-
# is specifed, the root URI will be used.
|
25
|
-
#http_auth :user, :password, 'http://domain/'
|
26
|
-
|
27
|
-
# Retrieve a list of listings and store
|
28
|
-
# them in a resource called listing_ids.
|
29
|
-
get '/listings.yaml', "Get Listings" do
|
30
|
-
response 200 do
|
31
|
-
listings = doc.collect! { |l|; l[:id]; }
|
32
|
-
set :listing_ids, listings[0..2]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Access each listing page in the order
|
37
|
-
get "/listing/:lid.yaml", "Sequential" do
|
38
|
-
param :lid => sequential(:listing_ids)
|
39
|
-
response 200 do
|
40
|
-
repeat 5
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Access each listing page in reverse order
|
45
|
-
get "/listing/:lid.yaml", "Reverse Sequential" do
|
46
|
-
param :lid => rsequential(:listing_ids)
|
47
|
-
response 200 do
|
48
|
-
repeat 5
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Access listing pages in random order
|
53
|
-
get "/listing/:lid.yaml", "Random" do
|
54
|
-
param :lid => random(:listing_ids)
|
55
|
-
response 200 do
|
56
|
-
repeat 5
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
File without changes
|
data/examples/essentials/plan.rb
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
# Stella Test Plan - Essentials (2009-10-08)
|
2
|
-
#
|
3
|
-
#
|
4
|
-
# 1. INTRODUCTION
|
5
|
-
#
|
6
|
-
# A test plan is a group of one or more user
|
7
|
-
# scenarios. This allows you to simulate the
|
8
|
-
# kind of traffic your application is exposed
|
9
|
-
# to in the wild. Realistic tests are really
|
10
|
-
# important because they give you a much more
|
11
|
-
# accurate view of how your application is
|
12
|
-
# performing.
|
13
|
-
#
|
14
|
-
# A scenario (or "usecase") is a group a
|
15
|
-
# requests that represents a typical path
|
16
|
-
# that a real person would take through
|
17
|
-
# your site.
|
18
|
-
#
|
19
|
-
# This plan contains 3 scenarios:
|
20
|
-
#
|
21
|
-
# - Simple Search (65%)
|
22
|
-
# - YAML API (25%)
|
23
|
-
# - Self-serve API (10%)
|
24
|
-
#
|
25
|
-
# The percentages represent the relative amount
|
26
|
-
# of traffic to be generated for each scenario.
|
27
|
-
# In a test with 100 virtual users, 65 would
|
28
|
-
# follow the Simple Search usecase, 25 the YAML
|
29
|
-
# API, and 10 would following the Self-Serve API.
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# 2. THE CONFIGURATION LANGUAGE
|
33
|
-
#
|
34
|
-
# Test plans are defined in a streamlined version
|
35
|
-
# of the Ruby programming language. Using a "real"
|
36
|
-
# languages gives you a lot of power to specify
|
37
|
-
# complex operations.
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# 3. START THE EXAMPLE APPLICATION
|
41
|
-
#
|
42
|
-
# You need to start the example web application before
|
43
|
-
# running this testplan. You can generate the commands
|
44
|
-
# for your local machine with this command:
|
45
|
-
#
|
46
|
-
# $ stella example
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# 4. RUNNING THE TEST PLAN
|
50
|
-
#
|
51
|
-
# You run this test plan from the command line.
|
52
|
-
# First you verify that the plan and application
|
53
|
-
# are running correctly:
|
54
|
-
#
|
55
|
-
# $ stella verify -p examples/essentials/plan.rb http://127.0.0.1:3114/
|
56
|
-
#
|
57
|
-
# The "verify" command executes the plan with a
|
58
|
-
# single user and provides more detailed output.
|
59
|
-
#
|
60
|
-
# And this is how you generate load:
|
61
|
-
#
|
62
|
-
# $ stella generate -c 50 -r 10 -p examples/essentials/plan.rb http://127.0.0.1:3114/
|
63
|
-
#
|
64
|
-
# where "c" is the number of concurrent clients,
|
65
|
-
# "r" is the number of times to repeat the plan.
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# 5. WRITING A TEST PLAN
|
69
|
-
#
|
70
|
-
# The following is an example of a working test plan.
|
71
|
-
# I put a lot of effort into keeping the syntax simple
|
72
|
-
# but feel free to contact me if you have any questions
|
73
|
-
# or problems.
|
74
|
-
#
|
75
|
-
# Happy Testing!
|
76
|
-
#
|
77
|
-
# Delano (@solutious.com)
|
78
|
-
#
|
79
|
-
|
80
|
-
desc "Product Finder"
|
81
|
-
|
82
|
-
usecase 65, "Simple search" do
|
83
|
-
auth :user, :password, 'http://domain/'
|
84
|
-
|
85
|
-
# An important factor in simulating traffic
|
86
|
-
# is using real, dynamic data. You can load
|
87
|
-
# data from a file using the resource method.
|
88
|
-
# Here is an example which reads a list of
|
89
|
-
# search terms ("restaurant", "hotel", ...)
|
90
|
-
# into an array called :search_terms. The
|
91
|
-
# colon is Ruby's way of defining a symbol.
|
92
|
-
#
|
93
|
-
resource :search_terms, list('search_terms.txt')
|
94
|
-
|
95
|
-
# Requests are defined with one of the
|
96
|
-
# following methods: get, post, head, delete.
|
97
|
-
# Here we define a simple get request for the
|
98
|
-
# homepage ("/").
|
99
|
-
#
|
100
|
-
get "/", "Homepage" do
|
101
|
-
# This tells Stella to wait between 1 and 3
|
102
|
-
# seconds before moving to the next request.
|
103
|
-
wait 1..3
|
104
|
-
end
|
105
|
-
|
106
|
-
# In this request, the user has entered a simple
|
107
|
-
# what and where search. You'll notice that we
|
108
|
-
# aren't specifying a hostname or port number for
|
109
|
-
# these requests. We do that so you use the same
|
110
|
-
# test plan to run tests on machines with different
|
111
|
-
# hostnames. However, this is optional. You can
|
112
|
-
# also specify absolute URIs like this:
|
113
|
-
#
|
114
|
-
# get "http://example.com:8000/search"
|
115
|
-
#
|
116
|
-
get "/search", "Search Results" do
|
117
|
-
wait 2..3
|
118
|
-
|
119
|
-
# Two URI parameters will be included with this
|
120
|
-
# request. Notice that the values for the what
|
121
|
-
# and where parameters come from the resources
|
122
|
-
# we defined. We've specified for random values
|
123
|
-
# to be used, but we could also specify sequential
|
124
|
-
# or reverse sequential values (see XML API).
|
125
|
-
#
|
126
|
-
param :what => random(:search_terms)
|
127
|
-
param :where => random(['Toronto', 'Vancouver', 'Montreal'])
|
128
|
-
|
129
|
-
# Each request can also include one or more
|
130
|
-
# optional response blocks. These blocks determine
|
131
|
-
# what should happen when the specified HTTP
|
132
|
-
# status code is returned by the web server.
|
133
|
-
#
|
134
|
-
# For successful responses, we want to parse out
|
135
|
-
# some data from the page. For 404 (Not Found)
|
136
|
-
# responses, we simply want the virtual user to
|
137
|
-
# quit the usecase altogether.
|
138
|
-
#
|
139
|
-
response 200 do
|
140
|
-
|
141
|
-
# If the response contains HTML, it will
|
142
|
-
# automatically be parsed using the Ruby
|
143
|
-
# library Nokogiri. See the following link
|
144
|
-
# for more information:
|
145
|
-
# http://nokogiri.rubyforge.org/nokogiri/
|
146
|
-
#
|
147
|
-
# The important thing to note is that you
|
148
|
-
# don't need to write complex regular
|
149
|
-
# expressions to grab data from the page.
|
150
|
-
#
|
151
|
-
listing = doc.css('div.listing').first
|
152
|
-
|
153
|
-
# Here we grab the first listing ID on the
|
154
|
-
# page and store it in a variable called
|
155
|
-
# :lid. This is similar to a resource.
|
156
|
-
#
|
157
|
-
set :lid, listing['id'].match(/(\d+)/)[0]
|
158
|
-
end
|
159
|
-
response 404 do
|
160
|
-
quit "No results"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# Notice the special variable in this URI path.
|
165
|
-
# Since we have defined a variable with the same
|
166
|
-
# name in the previous request, the variable in
|
167
|
-
# the request will automatically be replaced with
|
168
|
-
# that value. This value is unique for each virtual
|
169
|
-
# user.
|
170
|
-
#
|
171
|
-
get "/listing/:lid" do
|
172
|
-
desc "Selected listing"
|
173
|
-
wait 1..4
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
usecase 25, "YAML API" do
|
179
|
-
|
180
|
-
get '/listings.yaml', "View All" do
|
181
|
-
response 200 do
|
182
|
-
|
183
|
-
# We showed above how HTML is parsed automatically.
|
184
|
-
# Stella can do the same with XML, YAML, and JSON.
|
185
|
-
#
|
186
|
-
# A variable called "doc" contains the parsed YAML.
|
187
|
-
# "collect" is a Ruby method that iterates through
|
188
|
-
# all items in an Array and returns a new Array
|
189
|
-
# containing the return values from each iteration.
|
190
|
-
# Each item item is available in the variable
|
191
|
-
# called 'l'.
|
192
|
-
#
|
193
|
-
# The variable called "listings" will contain all
|
194
|
-
# listing ids in the YAML document.
|
195
|
-
#
|
196
|
-
listings = doc.collect! { |l|; l[:id]; }
|
197
|
-
|
198
|
-
# And here we store that list of ids.
|
199
|
-
#
|
200
|
-
set :listing_ids, listings
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
# In the Simple Search usecase we stored a listing
|
205
|
-
# id in a variable called :lid. This time we have
|
206
|
-
# an Array of listing ids but we only want to use
|
207
|
-
# one for each request so we override the automatic
|
208
|
-
# variable replacement by using the param method.
|
209
|
-
#
|
210
|
-
get "/listing/:lid.yaml", "Select Listing" do
|
211
|
-
|
212
|
-
# Each request will use a new value from the
|
213
|
-
# Array and these will be selected sequentially.
|
214
|
-
# Note that this is _per virtual user_. Each
|
215
|
-
# vuser will have its own copy of the Array and
|
216
|
-
# iterate through it independently.
|
217
|
-
#
|
218
|
-
param :lid => sequential(:listing_ids)
|
219
|
-
|
220
|
-
# We can use response blocks to affect behaviour
|
221
|
-
# the user. Here we specify that every virtual
|
222
|
-
# user should repeat this request 7 times.
|
223
|
-
#
|
224
|
-
response 200 do
|
225
|
-
repeat 3
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
230
|
-
|
231
|
-
usecase 10, "Self-serve API" do
|
232
|
-
|
233
|
-
# Here is an example of using a POST request.
|
234
|
-
# Notice that the definition is otherwise
|
235
|
-
# identical to the ones you've seen above.
|
236
|
-
#
|
237
|
-
post "/listing/add", "Add a listing" do
|
238
|
-
param :name => random(8)
|
239
|
-
param :city => random(['Toronto', 'Vancouver', 'Montreal'])
|
240
|
-
param :logo => file('logo.png')
|
241
|
-
response 302 do
|
242
|
-
repeat 2
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
end
|
247
|
-
|
248
|
-
# 80661e5f4c731ed905b01fdcdb52896629c7dd1e
|