ruby-jmeter 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +59 -0
- data/examples/basic_testdata.rb +47 -17
- data/lib/ruby-jmeter/dsl.rb +12 -1
- data/lib/ruby-jmeter/version.rb +1 -1
- metadata +4 -6
data/CHANGES.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
## v2.1.5
|
4
|
+
|
5
|
+
- HTTP Request Defaults now have more intuitive key names:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
defaults domain: 'example.com',
|
9
|
+
protocol: 'https',
|
10
|
+
download_resources: true,
|
11
|
+
use_concurrent_pool: 5,
|
12
|
+
urls_must_match: 'http.+?example.com'
|
13
|
+
```
|
14
|
+
|
15
|
+
- There's a new `with_gzip` header manager alias:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
test do
|
19
|
+
threads do
|
20
|
+
transaction name: "TC_02", parent: true, include_timers: true do
|
21
|
+
visit url: "/" do
|
22
|
+
with_gzip
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
- There's a new `test_data` helper method to simplify getting test data from the flood.io shared data URL. Including ability to stub, set defaults, get all values or explicit values :
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
test do
|
33
|
+
threads 1 do
|
34
|
+
|
35
|
+
# populate ${testdata} array with all results from shared data url
|
36
|
+
test_data 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text'
|
37
|
+
|
38
|
+
# populate named ${postcodes} array with all results from shared data url
|
39
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
40
|
+
name: 'postcodes'
|
41
|
+
|
42
|
+
# populate named ${postcode} with random result from shared data url
|
43
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
44
|
+
name: 'postcode_random', match_num: 0
|
45
|
+
|
46
|
+
|
47
|
+
# populate named ${postcode} with exact match from shared data url
|
48
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
49
|
+
name: 'postcode_exact', regex: '^(\d+)', match_num: 1
|
50
|
+
|
51
|
+
# populate named ${postcode} with exact match from a stubbed data url
|
52
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
53
|
+
name: 'postcode_stub', regex: '^(\d+)', match_num: 1, default: '2010', stub: true
|
54
|
+
|
55
|
+
debug_sampler
|
56
|
+
view_results
|
57
|
+
end
|
58
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
59
|
+
```
|
data/examples/basic_testdata.rb
CHANGED
@@ -4,25 +4,55 @@ require 'ruby-jmeter'
|
|
4
4
|
test do
|
5
5
|
threads 1 do
|
6
6
|
|
7
|
-
# populate ${testdata} array with all results from shared data url
|
8
|
-
|
7
|
+
# populate ${testdata} array with *all* results from shared data url
|
8
|
+
# using default match number -1
|
9
|
+
test_data :postcodes
|
10
|
+
|
11
|
+
# testdata now populated with:
|
12
|
+
#testdata_1=NSW
|
13
|
+
#testdata_1_g=1
|
14
|
+
#testdata_1_g0="NSW"
|
15
|
+
#testdata_1_g1=NSW
|
16
|
+
#testdata_2=nsw-sydney-2000
|
17
|
+
#testdata_2_g=1
|
18
|
+
#testdata_2_g0="nsw-sydney-2000"
|
19
|
+
#testdata_2_g1=nsw-sydney-2000
|
20
|
+
#testdata_matchNr=2
|
21
|
+
|
22
|
+
# visit first column match
|
23
|
+
visit 'http://example.com/?${testdata_1}'
|
24
|
+
|
25
|
+
# visit second column match
|
26
|
+
visit 'http://example.com/?${testdata_2}'
|
9
27
|
|
10
28
|
# populate named ${postcodes} array with all results from shared data url
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# populate named ${postcode}
|
24
|
-
|
25
|
-
|
29
|
+
# using specific key, command and host
|
30
|
+
test_data key: 'postcodes',
|
31
|
+
command: 'SRANDMEMBER',
|
32
|
+
host: '54.252.206.143'
|
33
|
+
|
34
|
+
# populate named ${postcode_random} from shared data url
|
35
|
+
# using random result, match number 0 and override name
|
36
|
+
test_data :postcodes,
|
37
|
+
name: 'postcode_random',
|
38
|
+
match_num: 0
|
39
|
+
|
40
|
+
|
41
|
+
# populate named ${postcode} from shared data url
|
42
|
+
# using exact result, match number 1 and override name
|
43
|
+
test_data 'postcodes',
|
44
|
+
name: 'postcode_exact',
|
45
|
+
regex: '^(\d+)',
|
46
|
+
match_num: 1
|
47
|
+
|
48
|
+
# populate named ${postcode} from a stubbed data url
|
49
|
+
# with stub = true and default value 2010
|
50
|
+
test_data 'postcodes',
|
51
|
+
name: 'postcode_stub',
|
52
|
+
regex: '^(\d+)',
|
53
|
+
match_num: 1,
|
54
|
+
default: '2010',
|
55
|
+
stub: true
|
26
56
|
|
27
57
|
debug_sampler
|
28
58
|
view_results
|
data/lib/ruby-jmeter/dsl.rb
CHANGED
@@ -144,12 +144,23 @@ module RubyJmeter
|
|
144
144
|
|
145
145
|
def test_data(*args, &block)
|
146
146
|
params = args.shift || {}
|
147
|
-
params = {
|
147
|
+
params = { key: params.to_s }.merge(args.shift || {}) if(params.class == String || params.class == Symbol)
|
148
|
+
params[:command] ||= 'SRANDMEMBER'
|
148
149
|
params[:name] ||= 'testdata'
|
149
150
|
params[:regex] ||= '"(.+?)"'
|
150
151
|
params[:match_num] ||= -1
|
151
152
|
params[:default] ||= ''
|
153
|
+
|
154
|
+
params[:host] ||= '54.252.206.143'
|
155
|
+
|
156
|
+
params[:url] = params[:key] if URI.parse(URI::encode(params[:key])).scheme
|
157
|
+
|
158
|
+
params[:url] = if params[:host]
|
159
|
+
"http://#{params[:host]}:8080/#{params[:command]}/#{params[:key]}?type=text"
|
160
|
+
end
|
161
|
+
|
152
162
|
params[:url] = 'http://54.252.206.143:8080/' if params[:stub]
|
163
|
+
|
153
164
|
get name: '__testdata', url: params[:url] do
|
154
165
|
extract name: params[:name],
|
155
166
|
regex: params[:regex],
|
data/lib/ruby-jmeter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jmeter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- .gitignore
|
56
56
|
- .rspec
|
57
57
|
- .ruby-version
|
58
|
+
- CHANGES.md
|
58
59
|
- Gemfile
|
59
60
|
- LICENSE.txt
|
60
61
|
- README.md
|
@@ -254,7 +255,4 @@ rubygems_version: 1.8.23
|
|
254
255
|
signing_key:
|
255
256
|
specification_version: 3
|
256
257
|
summary: This is a Ruby based DSL for writing JMeter test plans
|
257
|
-
test_files:
|
258
|
-
- spec/dsl_spec.rb
|
259
|
-
- spec/spec_helper.rb
|
260
|
-
- spec/stub.rb
|
258
|
+
test_files: []
|