Class: RubyJmeter::ExtendedDSL
- Inherits:
-
DSL
- Object
- DSL
- RubyJmeter::ExtendedDSL
show all
- Includes:
- Parser
- Defined in:
- lib/ruby-jmeter/dsl.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#active_threads_over_time(params = {}, &block) ⇒ Object
(also: #active_threads)
-
#composite_graph(name, params = {}, &block) ⇒ Object
(also: #composite)
-
#console_status_logger(name = "Console Status Logger", params = {}, &block) ⇒ Object
(also: #console)
-
#constant_throughput_timer(params, &block) ⇒ Object
(also: #ConstantThroughputTimer)
-
#delete(*args, &block) ⇒ Object
-
#dummy_sampler(name = "Dummy Sampler", params = {}, &block) ⇒ Object
(also: #dummy)
-
#exists(variable, &block) ⇒ Object
-
#extract(params, &block) ⇒ Object
(also: #web_reg_save_param)
-
#flood(token, params = {}) ⇒ Object
(also: #grid)
-
#get(*args, &block) ⇒ Object
(also: #visit)
-
#head(*args, &block) ⇒ Object
-
#http_cache_manager(params = {}, &block) ⇒ Object
(also: #cache)
-
#http_cookie_manager(params = {}, &block) ⇒ Object
(also: #cookies)
-
#http_header_manager(params, &block) ⇒ Object
(also: #header)
-
#http_request_defaults(params = {}, &block) ⇒ Object
(also: #defaults)
-
#initialize(params = {}) ⇒ ExtendedDSL
constructor
A new instance of ExtendedDSL.
-
#jmx(params = {}) ⇒ Object
-
#latencies_over_time(name = "Response Latencies Over Time", params = {}, &block) ⇒ Object
-
#loop_controller(params, &block) ⇒ Object
(also: #Loop)
-
#module_controller(params, &block) ⇒ Object
-
#out(params = {}) ⇒ Object
-
#patch(*args, &block) ⇒ Object
-
#perfmon_collector(name, params = {}, &block) ⇒ Object
(also: #perfmon)
-
#post(*args, &block) ⇒ Object
(also: #submit)
-
#put(*args, &block) ⇒ Object
-
#random_timer(delay = 0, range = 0, &block) ⇒ Object
(also: #think_time)
-
#response_assertion(params = {}, &block) ⇒ Object
(also: #assert, #web_reg_find)
-
#response_codes_per_second(name = "Response Codes per Second", params = {}, &block) ⇒ Object
-
#response_times_distribution(name = "Response Times Distribution", params = {}, &block) ⇒ Object
-
#response_times_over_time(name = "Response Times Over Time", params = {}, &block) ⇒ Object
-
#response_times_percentiles(name = "Response Times Percentiles", params = {}, &block) ⇒ Object
-
#run(params = {}) ⇒ Object
-
#soapxmlrpc_request(params, &block) ⇒ Object
(also: #soap)
-
#stepping_thread_group(params = {}, &block) ⇒ Object
(also: #step)
-
#test_data(*args, &block) ⇒ Object
-
#thread_group(*args, &block) ⇒ Object
(also: #threads)
-
#throughput_controller(params, &block) ⇒ Object
(also: #Throughput)
-
#throughput_shaper(name = "Throughput Shaping Timer", steps = [], params = {}, &block) ⇒ Object
(also: #shaper)
-
#to_doc ⇒ Object
-
#to_xml ⇒ Object
-
#transaction_controller(*args, &block) ⇒ Object
(also: #transaction)
-
#transactions_per_second(name = "Transactions per Second", params = {}, &block) ⇒ Object
-
#user_defined_variables(params, &block) ⇒ Object
(also: #variables)
-
#user_parameters(params, &block) ⇒ Object
-
#with_browser(device) ⇒ Object
-
#with_gzip ⇒ Object
-
#with_json ⇒ Object
-
#with_user_agent(device) ⇒ Object
-
#with_xhr ⇒ Object
Methods included from Parser
#files, #fill_in, #parse_http_request, #parse_test_type, #parse_uri, #parse_url, #raw_body
Methods inherited from DSL
#access_log_sampler, #aggregate_graph, #aggregate_report, #ajp13_sampler, #assertion_results, #beanshell_assertion, #beanshell_listener, #beanshell_postprocessor, #beanshell_preprocessor, #beanshell_sampler, #beanshell_timer, #bsf_assertion, #bsf_listener, #bsf_postprocessor, #bsf_preprocessor, #bsf_sampler, #bsf_timer, #compare_assertion, #comparison_assertion_visualizer, #constant_timer, #counter, #cssjquery_extractor, #csv_data_set_config, #debug_postprocessor, #debug_sampler, #distribution_graphalpha, #duration_assertion, #foreach_controller, #ftp_request, #ftp_request_defaults, #gaussian_random_timer, #generate_summary_results, #graph_results, #html_assertion, #html_link_parser, #html_parameter_mask, #http_authorization_manager, #http_request, #http_url_rewriting_modifier, #if_controller, #include_controller, #java_request, #java_request_defaults, #jdbc_connection_configuration, #jdbc_postprocessor, #jdbc_preprocessor, #jdbc_request, #jms_pointtopoint, #jms_publisher, #jms_subscriber, #jsr223_assertion, #jsr223_listener, #jsr223_postprocessor, #jsr223_preprocessor, #jsr223_sampler, #jsr223_timer, #junit_request, #keystore_configuration, #ldap_extended_request, #ldap_extended_request_defaults, #ldap_request, #ldap_request_defaults, #login_config_element, #mail_reader_sampler, #mailer_visualizer, #md5hex_assertion, #monitor_results, #once_only_controller, #os_process_sampler, #poisson_random_timer, #random_controller, #random_order_controller, #random_variable, #recording_controller, #regex_user_parameters, #regular_expression_extractor, #response_time_graph, #result_status_action_handler, #runtime_controller, #save_responses_to_a_file, #simple_config_element, #simple_controller, #simple_data_writer, #smime_assertion, #smtp_sampler, #spline_visualizer, #summary_report, #switch_controller, #synchronizing_timer, #tcp_sampler, #tcp_sampler_config, #test_action, #test_fragment, #test_plan, #uniform_random_timer, #view_results_in_table, #view_results_tree, #while_controller, #xml_assertion, #xml_schema_assertion, #xpath_assertion, #xpath_extractor
Constructor Details
#initialize(params = {}) ⇒ ExtendedDSL
Returns a new instance of ExtendedDSL.
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ruby-jmeter/dsl.rb', line 6
def initialize(params = {})
@root = Nokogiri::XML(<<-EOF.strip_heredoc)
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.7" jmeter="2.12 r1636949">
<hashTree>
</hashTree>
</jmeterTestPlan>
EOF
node = RubyJmeter::TestPlan.new(params)
@current_node = @root.at_xpath("//jmeterTestPlan/hashTree")
@current_node = attach_to_last(node)
end
|
Instance Attribute Details
#root ⇒ Object
Returns the value of attribute root.
4
5
6
|
# File 'lib/ruby-jmeter/dsl.rb', line 4
def root
@root
end
|
Instance Method Details
#active_threads_over_time(params = {}, &block) ⇒ Object
Also known as:
active_threads
#composite_graph(name, params = {}, &block) ⇒ Object
Also known as:
composite
458
459
460
461
|
# File 'lib/ruby-jmeter/dsl.rb', line 458
def composite_graph(name, params={}, &block)
node = RubyJmeter::Plugins::CompositeGraph.new(name, params)
attach_node(node, &block)
end
|
#console_status_logger(name = "Console Status Logger", params = {}, &block) ⇒ Object
Also known as:
console
430
431
432
433
|
# File 'lib/ruby-jmeter/dsl.rb', line 430
def console_status_logger(name="Console Status Logger", params={}, &block)
node = RubyJmeter::Plugins::ConsoleStatusLogger.new(name, params)
attach_node(node, &block)
end
|
#constant_throughput_timer(params, &block) ⇒ Object
Also known as:
ConstantThroughputTimer
373
374
375
376
377
378
379
380
|
# File 'lib/ruby-jmeter/dsl.rb', line 373
def constant_throughput_timer(params, &block)
params[:value] ||= params[:throughput] || 0.0
node = RubyJmeter::ConstantThroughputTimer.new(params)
node.doc.xpath(".//value").first.content = params[:value].to_f
attach_node(node, &block)
end
|
#delete(*args, &block) ⇒ Object
124
125
126
127
128
129
130
131
132
|
# File 'lib/ruby-jmeter/dsl.rb', line 124
def delete(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'DELETE'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#dummy_sampler(name = "Dummy Sampler", params = {}, &block) ⇒ Object
Also known as:
dummy
444
445
446
447
|
# File 'lib/ruby-jmeter/dsl.rb', line 444
def dummy_sampler(name="Dummy Sampler", params={}, &block)
node = RubyJmeter::Plugins::DummySampler.new(name, params)
attach_node(node, &block)
end
|
#exists(variable, &block) ⇒ Object
237
238
239
240
241
242
243
244
|
# File 'lib/ruby-jmeter/dsl.rb', line 237
def exists(variable, &block)
params ||= {}
params[:condition] = "\"${#{variable}}\" != \"\\${#{variable}}\""
params[:useExpression] = false
params[:name] = "if ${#{variable}}"
node = RubyJmeter::IfController.new(params)
attach_node(node, &block)
end
|
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'lib/ruby-jmeter/dsl.rb', line 343
def (params, &block)
node = if params[:regex]
params[:refname] = params[:name]
params[:regex] = params[:regex] params[:template] = params[:template] || "$1$"
RubyJmeter::RegularExpressionExtractor.new(params)
elsif params[:xpath]
params[:refname] = params[:name]
params[:xpathQuery] = params[:xpath]
RubyJmeter::XpathExtractor.new(params)
elsif params[:json]
params[:VAR] = params[:name]
params[:JSONPATH] = params[:json]
RubyJmeter::Plugins::JsonPathExtractor.new(params)
end
attach_node(node, &block)
end
|
#flood(token, params = {}) ⇒ Object
Also known as:
grid
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
|
# File 'lib/ruby-jmeter/dsl.rb', line 525
def flood(token, params={})
if params[:region] == 'local'
logger.info "Starting test ..."
params[:started] = Time.now
run params
params[:stopped] = Time.now
logger.info "Completed test ..."
logger.debug "Uploading results ..." if params[:debug]
end
RestClient.proxy = params[:proxy] if params[:proxy]
begin
file = Tempfile.new(['jmeter', '.jmx'])
file.write(doc.to_xml(:indent => 2))
file.rewind
flood_files = {
file: File.new("#{file.path}", 'rb')
}
if params[:files]
flood_files.merge!(Hash[params[:files].map.with_index { |value, index| [index, File.new(value, 'rb')] }])
params.delete(:files)
end
response = RestClient.post "#{params[:endpoint] ? params[:endpoint] : 'https://api.flood.io'}/floods?auth_token=#{token}",
{
:flood => {
:tool => 'jmeter-2.12',
:url => params[:url],
:name => params[:name],
:notes => params[:notes],
:tag_list => params[:tag_list],
:threads => params[:threads],
:rampup => params[:rampup],
:duration => params[:duration],
:override_hosts => params[:override_hosts],
:override_parameters => params[:override_parameters],
:started => params[:started],
:stopped => params[:stopped]
},
:flood_files => flood_files,
:results => (File.new("#{params[:jtl] ? params[:jtl] : 'jmeter.jtl'}", 'rb') if params[:region] == 'local'),
:region => params[:region],
:multipart => true,
:content_type => 'application/octet-stream'
}.merge(params)
if response.code == 200
logger.info "Flood results at: #{JSON.parse(response)["response"]["results"]["link"]}"
else
logger.fatal "Sorry there was an error: #{JSON.parse(response)["error_description"]}"
end
rescue => e
logger.fatal "Sorry there was an error: #{JSON.parse(e.response)["error_description"]}"
end
end
|
#get(*args, &block) ⇒ Object
Also known as:
visit
100
101
102
103
104
105
106
107
108
|
# File 'lib/ruby-jmeter/dsl.rb', line 100
def get(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'GET'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#head(*args, &block) ⇒ Object
154
155
156
157
158
159
160
161
162
|
# File 'lib/ruby-jmeter/dsl.rb', line 154
def head(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'HEAD'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#http_cache_manager(params = {}, &block) ⇒ Object
Also known as:
cache
49
50
51
52
|
# File 'lib/ruby-jmeter/dsl.rb', line 49
def http_cache_manager(params={}, &block)
params[:clearEachIteration] = true if params.keys.include? :clear_each_iteration
super
end
|
#http_cookie_manager(params = {}, &block) ⇒ Object
Also known as:
cookies
42
43
44
45
|
# File 'lib/ruby-jmeter/dsl.rb', line 42
def http_cookie_manager(params={}, &block)
params[:clearEachIteration] = true if params.keys.include? :clear_each_iteration
super
end
|
70
71
72
73
74
75
|
# File 'lib/ruby-jmeter/dsl.rb', line 70
def (params, &block)
if params.is_a?(Hash)
params['Header.name'] = params[:name]
end
super
end
|
#http_request_defaults(params = {}, &block) ⇒ Object
Also known as:
defaults
32
33
34
35
36
37
38
|
# File 'lib/ruby-jmeter/dsl.rb', line 32
def http_request_defaults(params={}, &block)
params[:image_parser] = true if params.keys.include? :download_resources
params[:concurrentDwn] = true if params.keys.include? :use_concurrent_pool
params[:concurrentPool] = params[:use_concurrent_pool] if params.keys.include? :use_concurrent_pool
params[:embedded_url_re] = params[:urls_must_match] if params.keys.include? :urls_must_match
super
end
|
#jmx(params = {}) ⇒ Object
485
486
487
488
|
# File 'lib/ruby-jmeter/dsl.rb', line 485
def jmx(params={})
file(params)
logger.info "Test plan saved to: #{params[:file]}"
end
|
#latencies_over_time(name = "Response Latencies Over Time", params = {}, &block) ⇒ Object
425
426
427
428
|
# File 'lib/ruby-jmeter/dsl.rb', line 425
def latencies_over_time(name="Response Latencies Over Time", params={}, &block)
node = RubyJmeter::Plugins::LatenciesOverTime.new(name, params)
attach_node(node, &block)
end
|
#loop_controller(params, &block) ⇒ Object
Also known as:
Loop
248
249
250
251
|
# File 'lib/ruby-jmeter/dsl.rb', line 248
def loop_controller(params, &block)
params[:loops] = params[:count] || 1
super
end
|
#module_controller(params, &block) ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/ruby-jmeter/dsl.rb', line 291
def module_controller(params, &block)
node = RubyJmeter::ModuleController.new(params)
if params[:test_fragment]
params[:test_fragment].kind_of?(String) &&
params[:test_fragment].split('/')
elsif params[:node_path]
params[:node_path]
else
[]
end.each_with_index do |node_name, index|
node.doc.at_xpath('//collectionProp') <<
Nokogiri::XML(<<-EOS.strip_heredoc).children
<stringProp name="node_#{index}">#{node_name}</stringProp>
EOS
end
attach_node(node, &block)
end
|
#out(params = {}) ⇒ Object
481
482
483
|
# File 'lib/ruby-jmeter/dsl.rb', line 481
def out(params={})
puts doc.to_xml(:indent => 2)
end
|
#patch(*args, &block) ⇒ Object
144
145
146
147
148
149
150
151
152
|
# File 'lib/ruby-jmeter/dsl.rb', line 144
def patch(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'PATCH'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#perfmon_collector(name, params = {}, &block) ⇒ Object
Also known as:
perfmon
472
473
474
475
|
# File 'lib/ruby-jmeter/dsl.rb', line 472
def perfmon_collector(name, params={}, &block)
node = RubyJmeter::Plugins::PerfmonCollector.new(name, params)
attach_node(node, &block)
end
|
#post(*args, &block) ⇒ Object
Also known as:
submit
112
113
114
115
116
117
118
119
120
|
# File 'lib/ruby-jmeter/dsl.rb', line 112
def post(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'POST'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#put(*args, &block) ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/ruby-jmeter/dsl.rb', line 134
def put(*args, &block)
params = args.shift || {}
params = { url: params }.merge(args.shift || {}) if params.class == String
params[:method] ||= 'PUT'
params[:name] ||= params[:url]
parse_http_request(params)
node = RubyJmeter::HttpRequest.new(params)
attach_node(node, &block)
end
|
#random_timer(delay = 0, range = 0, &block) ⇒ Object
Also known as:
think_time
363
364
365
366
367
368
369
|
# File 'lib/ruby-jmeter/dsl.rb', line 363
def random_timer(delay=0, range=0, &block)
params={}
params[:delay] = delay
params[:range] = range
node = RubyJmeter::GaussianRandomTimer.new(params)
attach_node(node, &block)
end
|
#response_assertion(params = {}, &block) ⇒ Object
Also known as:
assert, web_reg_find
384
385
386
387
388
389
390
391
|
# File 'lib/ruby-jmeter/dsl.rb', line 384
def response_assertion(params={}, &block)
params[:test_type] = parse_test_type(params)
params["0"] = params.values.first
node = RubyJmeter::ResponseAssertion.new(params)
node.doc.xpath("//stringProp[@name='Assertion.scope']").remove if
params[:scope] == 'main' || params['scope'] == 'main'
attach_node(node, &block)
end
|
#response_codes_per_second(name = "Response Codes per Second", params = {}, &block) ⇒ Object
400
401
402
403
|
# File 'lib/ruby-jmeter/dsl.rb', line 400
def response_codes_per_second(name="Response Codes per Second", params={}, &block)
node = RubyJmeter::Plugins::ResponseCodesPerSecond.new(name, params)
attach_node(node, &block)
end
|
#response_times_distribution(name = "Response Times Distribution", params = {}, &block) ⇒ Object
405
406
407
408
|
# File 'lib/ruby-jmeter/dsl.rb', line 405
def response_times_distribution(name="Response Times Distribution", params={}, &block)
node = RubyJmeter::Plugins::ResponseTimesDistribution.new(name, params)
attach_node(node, &block)
end
|
#response_times_over_time(name = "Response Times Over Time", params = {}, &block) ⇒ Object
410
411
412
413
|
# File 'lib/ruby-jmeter/dsl.rb', line 410
def response_times_over_time(name="Response Times Over Time", params={}, &block)
node = RubyJmeter::Plugins::ResponseTimesOverTime.new(name, params)
attach_node(node, &block)
end
|
#response_times_percentiles(name = "Response Times Percentiles", params = {}, &block) ⇒ Object
415
416
417
418
|
# File 'lib/ruby-jmeter/dsl.rb', line 415
def response_times_percentiles(name="Response Times Percentiles", params={}, &block)
node = RubyJmeter::Plugins::ResponseTimesPercentiles.new(name, params)
attach_node(node, &block)
end
|
#run(params = {}) ⇒ Object
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
|
# File 'lib/ruby-jmeter/dsl.rb', line 498
def run(params={})
file(params)
logger.warn "Test executing locally ..."
properties = params.has_key?(:properties) ? params[:properties] : "#{File.dirname(__FILE__)}/helpers/jmeter.properties"
properties = "-q #{properties}" if properties
if params[:remote_hosts]
remote_hosts = params[:remote_hosts]
remote_hosts = remote_hosts.join(',') if remote_hosts.kind_of?(Array)
remote_hosts = "-R #{remote_hosts}"
end
cmd = "#{params[:path]}jmeter #{"-n" unless params[:gui] } -t #{params[:file]} -j #{params[:log] ? params[:log] : 'jmeter.log' } -l #{params[:jtl] ? params[:jtl] : 'jmeter.jtl' } #{properties} #{remote_hosts}"
logger.debug cmd if params[:debug]
Open3.popen2e("#{cmd}") do |stdin, stdout_err, wait_thr|
while line = stdout_err.gets
logger.debug line.chomp if params[:debug]
end
exit_status = wait_thr.value
unless exit_status.success?
abort "FAILED !!! #{cmd}"
end
end
logger.info "Local Results at: #{params[:jtl] ? params[:jtl] : 'jmeter.jtl'}"
end
|
#soapxmlrpc_request(params, &block) ⇒ Object
Also known as:
soap
209
210
211
212
|
# File 'lib/ruby-jmeter/dsl.rb', line 209
def soapxmlrpc_request(params, &block)
params[:method] ||= 'POST'
super
end
|
#stepping_thread_group(params = {}, &block) ⇒ Object
Also known as:
step
#test_data(*args, &block) ⇒ Object
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/ruby-jmeter/dsl.rb', line 179
def test_data(*args, &block)
params = args.shift || {}
params = { key: params.to_s }.merge(args.shift || {}) if(params.class == String || params.class == Symbol)
params[:command] ||= 'SRANDMEMBER'
params[:name] ||= 'testdata'
params[:regex] ||= '"(.+?)"'
params[:match_num] ||= -1
params[:default] ||= ''
params[:host] ||= '54.252.206.143'
params[:url] = params[:key] if URI.parse(URI::encode(params[:key])).scheme
params[:url] = if params[:host]
"http://#{params[:host]}/data/#{params[:command]}/#{params[:key]}?type=text"
end
params[:url] = 'http://54.252.206.143/data/' if params[:stub]
get name: '__testdata', url: params[:url] do
name: params[:name],
regex: params[:regex],
match_num: params[:match_num],
default: params[:default]
end
end
|
#thread_group(*args, &block) ⇒ Object
Also known as:
threads
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/ruby-jmeter/dsl.rb', line 81
def thread_group(*args, &block)
params = args.shift || {}
params = { count: params }.merge(args.shift || {}) if params.class == Fixnum
params[:num_threads] = params[:count] || 1
params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil
params[:start_time] = params[:start_time] || Time.now.to_i * 1000
params[:end_time] = params[:end_time] || Time.now.to_i * 1000
params[:duration] ||= 60
params[:continue_forever] ||= false
params[:loops] = -1 if params[:continue_forever]
node = RubyJmeter::ThreadGroup.new(params)
attach_node(node, &block)
end
|
#throughput_controller(params, &block) ⇒ Object
Also known as:
Throughput
255
256
257
258
259
260
261
262
263
|
# File 'lib/ruby-jmeter/dsl.rb', line 255
def throughput_controller(params, &block)
params[:style] = 1 if params[:percent]
params[:maxThroughput] = params[:total] || params[:percent] || 1
node = RubyJmeter::ThroughputController.new(params)
node.doc.xpath(".//FloatProperty/value").first.content = params[:maxThroughput].to_f
attach_node(node, &block)
end
|
#throughput_shaper(name = "Throughput Shaping Timer", steps = [], params = {}, &block) ⇒ Object
Also known as:
shaper
437
438
439
440
|
# File 'lib/ruby-jmeter/dsl.rb', line 437
def throughput_shaper(name="Throughput Shaping Timer", steps=[], params={}, &block)
node = RubyJmeter::Plugins::ThroughputShapingTimer.new(name, steps)
attach_node(node, &block)
end
|
#to_doc ⇒ Object
494
495
496
|
# File 'lib/ruby-jmeter/dsl.rb', line 494
def to_doc
doc.clone
end
|
#to_xml ⇒ Object
490
491
492
|
# File 'lib/ruby-jmeter/dsl.rb', line 490
def to_xml
doc.to_xml(:indent => 2)
end
|
#transaction_controller(*args, &block) ⇒ Object
Also known as:
transaction
226
227
228
229
230
231
232
233
|
# File 'lib/ruby-jmeter/dsl.rb', line 226
def transaction_controller(*args, &block)
params = args.shift || {}
params = { name: params }.merge(args.shift || {}) if params.class == String
params[:parent] = params[:parent] || false
params[:includeTimers] = params[:include_timers] || false
node = RubyJmeter::TransactionController.new(params)
attach_node(node, &block)
end
|
#transactions_per_second(name = "Transactions per Second", params = {}, &block) ⇒ Object
420
421
422
423
|
# File 'lib/ruby-jmeter/dsl.rb', line 420
def transactions_per_second(name="Transactions per Second", params={}, &block)
node = RubyJmeter::Plugins::TransactionsPerSecond.new(name, params)
attach_node(node, &block)
end
|
#user_defined_variables(params, &block) ⇒ Object
Also known as:
variables
23
24
25
26
27
28
|
# File 'lib/ruby-jmeter/dsl.rb', line 23
def user_defined_variables(params, &block)
if params.is_a?(Hash)
params['Argument.name'] = params[:name]
end
super
end
|
#user_parameters(params, &block) ⇒ Object
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/ruby-jmeter/dsl.rb', line 311
def user_parameters(params, &block)
if params.is_a?(Hash)
params['Argument.name'] = params[:name]
end
params[:names] = Nokogiri::XML::Builder.new do |b|
b.builder do
params[:names].each do |name|
b.stringProp name, name: name
end
end
end
params[:thread_values] = Nokogiri::XML::Builder.new do |b|
b.builder do
params[:thread_values].map do |user, values|
b.collectionProp name: user do
values.each_with_index.map do |value, index|
b.stringProp value, name: index
end
end
end
end
end
super
end
|
#with_browser(device) ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'lib/ruby-jmeter/dsl.rb', line 61
def with_browser(device)
name: 'User-Agent',
value: RubyJmeter::UserAgent.new(device).string
[
{ name: 'Accept-Encoding', value: 'gzip,deflate,sdch' },
{ name: 'Accept', value: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' }
]
end
|
#with_gzip ⇒ Object
169
170
171
172
|
# File 'lib/ruby-jmeter/dsl.rb', line 169
def with_gzip
name: 'Accept-Encoding',
value: 'gzip, deflate'
end
|
#with_json ⇒ Object
174
175
176
177
|
# File 'lib/ruby-jmeter/dsl.rb', line 174
def with_json
name: 'Accept',
value: 'text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8, application/json'
end
|
#with_user_agent(device) ⇒ Object
56
57
58
59
|
# File 'lib/ruby-jmeter/dsl.rb', line 56
def with_user_agent(device)
name: 'User-Agent',
value: RubyJmeter::UserAgent.new(device).string
end
|
#with_xhr ⇒ Object
164
165
166
167
|
# File 'lib/ruby-jmeter/dsl.rb', line 164
def with_xhr
name: 'X-Requested-With',
value: 'XMLHttpRequest'
end
|