ruby-jmeter 2.1.4 → 2.1.5
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/examples/basic_http_request_defaults.rb +4 -5
- data/examples/basic_testdata.rb +30 -0
- data/lib/ruby-jmeter/dsl.rb +29 -0
- data/lib/ruby-jmeter/version.rb +1 -1
- data/spec/dsl_spec.rb +43 -3
- metadata +3 -2
@@ -3,9 +3,8 @@ require 'ruby-jmeter'
|
|
3
3
|
|
4
4
|
test do
|
5
5
|
defaults domain: 'example.com',
|
6
|
-
protocol: 'https',
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
concurrentPool: 4
|
6
|
+
protocol: 'https',
|
7
|
+
download_resources: true,
|
8
|
+
use_concurrent_pool: 5,
|
9
|
+
urls_must_match: 'http.+?example.com'
|
11
10
|
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'ruby-jmeter'
|
3
|
+
|
4
|
+
test do
|
5
|
+
threads 1 do
|
6
|
+
|
7
|
+
# populate ${testdata} array with all results from shared data url
|
8
|
+
test_data 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text'
|
9
|
+
|
10
|
+
# populate named ${postcodes} array with all results from shared data url
|
11
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
12
|
+
name: 'postcodes'
|
13
|
+
|
14
|
+
# populate named ${postcode} with random result from shared data url
|
15
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
16
|
+
name: 'postcode_random', match_num: 0
|
17
|
+
|
18
|
+
|
19
|
+
# populate named ${postcode} with exact match from shared data url
|
20
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
21
|
+
name: 'postcode_exact', regex: '^(\d+)', match_num: 1
|
22
|
+
|
23
|
+
# populate named ${postcode} with exact match from a stubbed data url
|
24
|
+
test_data url: 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text',
|
25
|
+
name: 'postcode_stub', regex: '^(\d+)', match_num: 1, default: '2010', stub: true
|
26
|
+
|
27
|
+
debug_sampler
|
28
|
+
view_results
|
29
|
+
end
|
30
|
+
end.run(path: '/usr/share/jmeter/bin/', gui: true)
|
data/lib/ruby-jmeter/dsl.rb
CHANGED
@@ -29,6 +29,14 @@ module RubyJmeter
|
|
29
29
|
|
30
30
|
alias_method :variables, :user_defined_variables
|
31
31
|
|
32
|
+
def http_request_defaults(params={}, &block)
|
33
|
+
params[:image_parser] = true if params.keys.include? :download_resources
|
34
|
+
params[:concurrentDwn] = true if params.keys.include? :use_concurrent_pool
|
35
|
+
params[:concurrentPool] = params[:use_concurrent_pool] if params.keys.include? :use_concurrent_pool
|
36
|
+
params[:embedded_url_re] = params[:urls_must_match] if params.keys.include? :urls_must_match
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
32
40
|
alias_method :defaults, :http_request_defaults
|
33
41
|
|
34
42
|
def http_cookie_manager(params={}, &block)
|
@@ -129,6 +137,27 @@ module RubyJmeter
|
|
129
137
|
value: 'XMLHttpRequest'
|
130
138
|
end
|
131
139
|
|
140
|
+
def with_gzip
|
141
|
+
http_header_manager name: 'Accept-Encoding',
|
142
|
+
value: 'gzip, deflate'
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_data(*args, &block)
|
146
|
+
params = args.shift || {}
|
147
|
+
params = { url: params }.merge(args.shift || {}) if params.class == String
|
148
|
+
params[:name] ||= 'testdata'
|
149
|
+
params[:regex] ||= '"(.+?)"'
|
150
|
+
params[:match_num] ||= -1
|
151
|
+
params[:default] ||= ''
|
152
|
+
params[:url] = 'http://54.252.206.143:8080/' if params[:stub]
|
153
|
+
get name: '__testdata', url: params[:url] do
|
154
|
+
extract name: params[:name],
|
155
|
+
regex: params[:regex],
|
156
|
+
match_num: params[:match_num],
|
157
|
+
default: params[:default]
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
132
161
|
##
|
133
162
|
# Other Samplers
|
134
163
|
|
data/lib/ruby-jmeter/version.rb
CHANGED
data/spec/dsl_spec.rb
CHANGED
@@ -55,10 +55,10 @@ describe "DSL" do
|
|
55
55
|
test do
|
56
56
|
defaults domain: 'example.com',
|
57
57
|
protocol: 'https',
|
58
|
-
image_parser: true,
|
59
58
|
implementation: 'HttpClient3.1',
|
60
|
-
|
61
|
-
|
59
|
+
download_resources: true,
|
60
|
+
use_concurrent_pool: 5,
|
61
|
+
urls_must_match: 'http.+?example.com'
|
62
62
|
threads do
|
63
63
|
visit url: "/"
|
64
64
|
end
|
@@ -76,6 +76,10 @@ describe "DSL" do
|
|
76
76
|
fragment.search(".//stringProp[@name='HTTPSampler.domain']").text.should == 'example.com'
|
77
77
|
fragment.search(".//stringProp[@name='HTTPSampler.protocol']").text.should == 'https'
|
78
78
|
fragment.search(".//stringProp[@name='HTTPSampler.implementation']").text.should == 'HttpClient3.1'
|
79
|
+
fragment.search(".//boolProp[@name='HTTPSampler.image_parser']").text.should == 'true'
|
80
|
+
fragment.search(".//boolProp[@name='HTTPSampler.concurrentDwn']").text.should == 'true'
|
81
|
+
fragment.search(".//stringProp[@name='HTTPSampler.concurrentPool']").text.should == '5'
|
82
|
+
fragment.search(".//stringProp[@name='HTTPSampler.embedded_url_re']").text.should == 'http.+?example.com'
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
@@ -331,6 +335,27 @@ describe "DSL" do
|
|
331
335
|
end
|
332
336
|
|
333
337
|
|
338
|
+
describe 'gzip' do
|
339
|
+
let(:doc) do
|
340
|
+
test do
|
341
|
+
threads do
|
342
|
+
transaction name: "TC_02", parent: true, include_timers: true do
|
343
|
+
visit url: "/" do
|
344
|
+
with_gzip
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end.to_doc
|
349
|
+
end
|
350
|
+
|
351
|
+
let(:fragment) { doc.search("//HeaderManager").first }
|
352
|
+
|
353
|
+
it 'should match on Acept Encoding' do
|
354
|
+
fragment.search(".//stringProp[@name='Header.value']").text.should == 'gzip, deflate'
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
|
334
359
|
describe 'submit' do
|
335
360
|
let(:doc) do
|
336
361
|
test do
|
@@ -493,6 +518,21 @@ describe "DSL" do
|
|
493
518
|
end
|
494
519
|
|
495
520
|
|
521
|
+
describe 'testdata extract' do
|
522
|
+
let(:doc) do
|
523
|
+
test do
|
524
|
+
test_data 'http://54.252.206.143:8080/SRANDMEMBER/postcodes?type=text'
|
525
|
+
end.to_doc
|
526
|
+
end
|
527
|
+
|
528
|
+
let(:fragment) { doc.search("//RegexExtractor").first }
|
529
|
+
|
530
|
+
it 'should match on refname' do
|
531
|
+
fragment.search(".//stringProp[@name='RegexExtractor.refname']").text.should == 'testdata'
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
|
496
536
|
describe 'assertions' do
|
497
537
|
|
498
538
|
describe 'scope all' do
|
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.5
|
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-10-
|
12
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- examples/basic_query_params.rb
|
81
81
|
- examples/basic_run.rb
|
82
82
|
- examples/basic_simple_data_writer.rb
|
83
|
+
- examples/basic_testdata.rb
|
83
84
|
- examples/basic_think_time.rb
|
84
85
|
- examples/basic_throughput_controller.rb
|
85
86
|
- examples/basic_throughput_shaping_timer.rb
|