ruby-jmeter 2.13.10 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Gemfile +2 -2
- data/LICENSE.txt +2 -2
- data/README.md +4 -5
- data/Rakefile +3 -3
- data/examples/{basic_os_process_sampler.rb → OS_process_sampler.rb} +1 -1
- data/examples/{basic_assertion_results.rb → assertion_results.rb} +1 -3
- data/examples/basic_auth.rb +1 -1
- data/examples/{basic_browser_headers.rb → browser_headers.rb} +1 -1
- data/examples/{basic_composite_graph.rb → composite_graph.rb} +1 -1
- data/examples/{basic_gc_dummy_sampler.rb → dummy_sampler.rb} +1 -3
- data/examples/{basic_duration_assertion.rb → duration_assertion.rb} +1 -1
- data/examples/etsy_login_browse.rb +1 -4
- data/examples/{basic_extract.rb → extract.rb} +1 -1
- data/examples/{basic_foreach.rb → foreach_controller.rb} +1 -4
- data/examples/{basic_header.rb → header_manager.rb} +2 -3
- data/examples/{basic_cache.rb → http_cache_manager.rb} +1 -1
- data/examples/{basic_cookies.rb → http_cookie_manager.rb} +1 -1
- data/examples/{basic_http_request_defaults.rb → http_request_defaults.rb} +3 -2
- data/examples/{basic_post.rb → http_request_post.rb} +1 -5
- data/examples/{basic_http_request_with_files.rb → http_request_with_files.rb} +1 -1
- data/examples/{basic_query_params.rb → http_request_with_query_params.rb} +1 -1
- data/examples/{basic_gc_results.rb → jmeter_plugins_graphs.rb} +1 -2
- data/examples/{basic_json_path_assertion.rb → json_path_assertions.rb} +1 -1
- data/examples/{basic_json_path_extractor.rb → json_path_extractor.rb} +1 -3
- data/examples/{basic_ldap_ext.rb → ldap_sampler.rb} +1 -1
- data/examples/{basic_loadosophia.rb → loadosophia.rb} +1 -1
- data/examples/{basic_loops.rb → loop_controller.rb} +2 -2
- data/examples/{basic_counter.rb → loops_with_counter.rb} +2 -2
- data/examples/{basic_perfmon.rb → perfmon.rb} +1 -1
- data/examples/real_page_objects.rb +1 -1
- data/examples/real_user_objects_github.rb +1 -1
- data/examples/regular_expression_extractor.rb +11 -0
- data/examples/{basic_assertion.rb → response_assertion.rb} +2 -1
- data/examples/{basic_response_time_percentiles_graph.rb → response_time_percentiles_graph.rb} +1 -2
- data/examples/{basic_simple_data_writer.rb → simple_data_writer_listener.rb} +1 -1
- data/examples/{basic_stepping_thread_group.rb → stepping_thread_group.rb} +1 -3
- data/examples/{basic_test_fragment.rb → test_fragment.rb} +1 -1
- data/examples/{basic_think_time.rb → think_time.rb} +2 -2
- data/examples/{basic_thread_groups.rb → thread_groups.rb} +1 -1
- data/examples/{basic_throughput_controller.rb → throughput_controller.rb} +1 -1
- data/examples/{basic_throughput_shaping_timer.rb → throughput_shaping_timer.rb} +1 -2
- data/examples/{basic_ultimate_thread_group.rb → ultimate_thread_group.rb} +1 -2
- data/examples/{basic_user_defined_variables.rb → user_defined_variables.rb} +1 -1
- data/examples/{basic_preprocessor_user_parameters.rb → user_parameters.rb} +7 -7
- data/lib/ruby-jmeter.rb +13 -8
- data/lib/ruby-jmeter/DSL.md +3 -1
- data/lib/ruby-jmeter/dsl.rb +11 -615
- data/lib/ruby-jmeter/dsl/foreach_controller.rb +0 -2
- data/lib/ruby-jmeter/dsl/html_parameter_mask.rb +3 -3
- data/lib/ruby-jmeter/dsl/http_request.rb +0 -2
- data/lib/ruby-jmeter/dsl/http_request_defaults.rb +0 -1
- data/lib/ruby-jmeter/dsl/jms_publisher.rb +2 -0
- data/lib/ruby-jmeter/dsl/regular_expression_extractor.rb +1 -3
- data/lib/ruby-jmeter/dsl/response_assertion.rb +0 -1
- data/lib/ruby-jmeter/dsl/test_fragment.rb +1 -1
- data/lib/ruby-jmeter/dsl/user_parameters.rb +3 -1
- data/lib/ruby-jmeter/extend/assertions/response_assertion.rb +36 -0
- data/lib/ruby-jmeter/extend/config_elements/header_manager.rb +13 -0
- data/lib/ruby-jmeter/extend/config_elements/http_cache_manager.rb +11 -0
- data/lib/ruby-jmeter/extend/config_elements/http_cookie_manager.rb +11 -0
- data/lib/ruby-jmeter/extend/config_elements/http_request_defaults.rb +28 -0
- data/lib/ruby-jmeter/extend/config_elements/user_defined_variables.rb +13 -0
- data/lib/ruby-jmeter/extend/config_elements/user_parameters.rb +31 -0
- data/lib/ruby-jmeter/extend/controllers/foreach_controller.rb +25 -0
- data/lib/ruby-jmeter/extend/controllers/loop_controller.rb +11 -0
- data/lib/ruby-jmeter/extend/controllers/module_controller.rb +23 -0
- data/lib/ruby-jmeter/extend/controllers/throughput_controller.rb +15 -0
- data/lib/ruby-jmeter/extend/controllers/transaction_controller.rb +14 -0
- data/lib/ruby-jmeter/extend/misc/aliases.rb +21 -0
- data/lib/ruby-jmeter/extend/misc/exists.rb +13 -0
- data/lib/ruby-jmeter/extend/misc/flood.rb +48 -0
- data/lib/ruby-jmeter/extend/misc/with_helpers.rb +27 -0
- data/lib/ruby-jmeter/extend/plugins/jmeter_plugins.rb +115 -0
- data/lib/ruby-jmeter/extend/processors/extract.rb +28 -0
- data/lib/ruby-jmeter/extend/processors/regular_expression_extractor.rb +25 -0
- data/lib/ruby-jmeter/extend/samplers/http_request.rb +47 -0
- data/lib/ruby-jmeter/extend/samplers/soapxmlrpc_request.rb +9 -0
- data/lib/ruby-jmeter/extend/threads/setup_thread_group.rb +18 -0
- data/lib/ruby-jmeter/extend/threads/thread_group.rb +19 -0
- data/lib/ruby-jmeter/extend/timers/constant_throughput_timer.rb +12 -0
- data/lib/ruby-jmeter/extend/timers/random_timer.rb +14 -0
- data/lib/ruby-jmeter/helpers/helper.rb +1 -2
- data/lib/ruby-jmeter/idl.xml +6 -4
- data/lib/ruby-jmeter/version.rb +1 -1
- data/ruby-jmeter.gemspec +7 -7
- data/spec/constant_throughput_timer_spec.rb +22 -0
- data/spec/header_manager_spec.rb +37 -0
- data/spec/http_cache_manager_spec.rb +17 -0
- data/spec/http_cookie_manager_spec.rb +17 -0
- data/spec/http_request_defaults_spec.rb +47 -0
- data/spec/http_request_spec.rb +305 -0
- data/spec/jmeter_plugins_spec.rb +155 -0
- data/spec/json_extractor_spec.rb +19 -0
- data/spec/json_path_assertion_spec.rb +28 -0
- data/spec/logic_controller_spec.rb +148 -0
- data/spec/loop_controller_spec.rb +19 -0
- data/spec/module_controller_spec.rb +56 -0
- data/spec/regular_expression_extractor_spec.rb +63 -0
- data/spec/response_assertion_spec.rb +69 -0
- data/spec/setup_thread_group_spec.rb +31 -0
- data/spec/thread_group_spec.rb +57 -0
- data/spec/throughput_controller_spec.rb +24 -0
- data/spec/transaction_controller_spec.rb +30 -0
- data/spec/user_defined_variables_spec.rb +22 -0
- data/spec/user_parameters_spec.rb +45 -0
- data/spec/with_helpers_spec.rb +57 -0
- data/spec/xpath_extractor_spec.rb +15 -0
- metadata +87 -59
- data/examples/basic_flood.rb +0 -12
- data/examples/basic_flood_real.rb +0 -7
- data/examples/basic_flood_with_csv.rb +0 -16
- data/examples/basic_google.rb +0 -8
- data/examples/basic_har.json +0 -4252
- data/examples/basic_har.rb +0 -34
- data/examples/basic_meta_fu.rb +0 -63
- data/examples/basic_response_assertion.rb +0 -13
- data/examples/basic_run.rb +0 -12
- data/examples/basic_testdata.rb +0 -60
- data/examples/demo.csv +0 -3
- data/examples/real_flood_test.rb +0 -14
- data/examples/real_flood_test_data.rb +0 -15
- data/examples/real_immi.gov.au_visa.rb +0 -78
- data/lib/ruby-jmeter/helpers/jmeter.properties +0 -28
- data/spec/dsl_spec.rb +0 -1157
- data/spec/stub.rb +0 -31
@@ -17,8 +17,6 @@ module RubyJmeter
|
|
17
17
|
<stringProp name="ForeachController.inputVal"/>
|
18
18
|
<stringProp name="ForeachController.returnVal"/>
|
19
19
|
<boolProp name="ForeachController.useSeparator">true</boolProp>
|
20
|
-
#{'<stringProp name="ForeachController.startIndex"/>' if params[:startIndex]}
|
21
|
-
#{'<stringProp name="ForeachController.endIndex"/>' if params[:endIndex]}
|
22
20
|
</ForeachController>)
|
23
21
|
EOS
|
24
22
|
update params
|
@@ -13,8 +13,8 @@ module RubyJmeter
|
|
13
13
|
def initialize(params={})
|
14
14
|
testname = params.kind_of?(Array) ? 'HtmlParameterMask' : (params[:name] || 'HtmlParameterMask')
|
15
15
|
@doc = Nokogiri::XML(<<-EOS.strip_heredoc)
|
16
|
-
<
|
17
|
-
<elementProp name="ParamModifier.mask" elementType="
|
16
|
+
<ConfigTestElement guiclass="ObsoleteGui" testclass="ConfigTestElement" testname="#{testname}" enabled="true">
|
17
|
+
<elementProp name="ParamModifier.mask" elementType="ConfigTestElement">
|
18
18
|
<stringProp name="ParamModifier.field_name"/>
|
19
19
|
<stringProp name="ParamModifier.prefix"/>
|
20
20
|
<longProp name="ParamModifier.lower_bound">0</longProp>
|
@@ -22,7 +22,7 @@ module RubyJmeter
|
|
22
22
|
<longProp name="ParamModifier.increment">1</longProp>
|
23
23
|
<stringProp name="ParamModifier.suffix"/>
|
24
24
|
</elementProp>
|
25
|
-
</
|
25
|
+
</ConfigTestElement>)
|
26
26
|
EOS
|
27
27
|
update params
|
28
28
|
update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
|
@@ -29,10 +29,8 @@ module RubyJmeter
|
|
29
29
|
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
30
30
|
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
31
31
|
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
32
|
-
<stringProp name="HTTPSampler.implementation"/>
|
33
32
|
<boolProp name="HTTPSampler.monitor">false</boolProp>
|
34
33
|
<stringProp name="HTTPSampler.embedded_url_re"/>
|
35
|
-
<stringProp name="TestPlan.comments"/>
|
36
34
|
</HTTPSamplerProxy>)
|
37
35
|
EOS
|
38
36
|
update params
|
@@ -28,7 +28,6 @@ module RubyJmeter
|
|
28
28
|
<boolProp name="HTTPSampler.image_parser">true</boolProp>
|
29
29
|
<boolProp name="HTTPSampler.concurrentDwn">true</boolProp>
|
30
30
|
<stringProp name="HTTPSampler.concurrentPool">4</stringProp>
|
31
|
-
<stringProp name="HTTPSampler.embedded_url_re"/>
|
32
31
|
</ConfigTestElement>)
|
33
32
|
EOS
|
34
33
|
update params
|
@@ -20,9 +20,7 @@ module RubyJmeter
|
|
20
20
|
<stringProp name="RegexExtractor.template"/>
|
21
21
|
<stringProp name="RegexExtractor.default"/>
|
22
22
|
<stringProp name="RegexExtractor.match_number"/>
|
23
|
-
|
24
|
-
#{"<stringProp name=\"Sample.scope\">variable</stringProp>" if params[:variable]}
|
25
|
-
#{"<stringProp name=\"Scope.variable\">params[:variable]</stringProp>" if params[:variable]}
|
23
|
+
<stringProp name="Sample.scope">all</stringProp>
|
26
24
|
</RegexExtractor>)
|
27
25
|
EOS
|
28
26
|
update params
|
@@ -21,7 +21,6 @@ module RubyJmeter
|
|
21
21
|
<boolProp name="Assertion.assume_success">false</boolProp>
|
22
22
|
<intProp name="Assertion.test_type">16</intProp>
|
23
23
|
<stringProp name="Assertion.scope">all</stringProp>
|
24
|
-
<stringProp name="Scope.variable"></stringProp>
|
25
24
|
</ResponseAssertion>)
|
26
25
|
EOS
|
27
26
|
update params
|
@@ -13,7 +13,7 @@ module RubyJmeter
|
|
13
13
|
def initialize(params={})
|
14
14
|
testname = params.kind_of?(Array) ? 'TestFragment' : (params[:name] || 'TestFragment')
|
15
15
|
@doc = Nokogiri::XML(<<-EOS.strip_heredoc)
|
16
|
-
<TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController" testname="#{testname}" enabled="
|
16
|
+
<TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController" testname="#{testname}" enabled="true"/>)
|
17
17
|
EOS
|
18
18
|
update params
|
19
19
|
update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
|
@@ -15,7 +15,9 @@ module RubyJmeter
|
|
15
15
|
@doc = Nokogiri::XML(<<-EOS.strip_heredoc)
|
16
16
|
<UserParameters guiclass="UserParametersGui" testclass="UserParameters" testname="#{testname}" enabled="true">
|
17
17
|
<collectionProp name="UserParameters.names"/>
|
18
|
-
<collectionProp name="UserParameters.thread_values"
|
18
|
+
<collectionProp name="UserParameters.thread_values">
|
19
|
+
<collectionProp name="1"/>
|
20
|
+
<collectionProp name="1"/>
|
19
21
|
</collectionProp>
|
20
22
|
<boolProp name="UserParameters.per_iteration">false</boolProp>
|
21
23
|
</UserParameters>)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def response_assertion(params, &block)
|
4
|
+
params[:test_type] = parse_test_type(params)
|
5
|
+
params['0'] = params.values.first
|
6
|
+
|
7
|
+
if params[:json]
|
8
|
+
params[:EXPECTED_VALUE] = params[:value]
|
9
|
+
params[:JSON_PATH] = params[:json]
|
10
|
+
node = RubyJmeter::Plugins::JsonPathAssertion.new(params)
|
11
|
+
end
|
12
|
+
|
13
|
+
node ||= RubyJmeter::ResponseAssertion.new(params).tap do |node|
|
14
|
+
if params[:variable]
|
15
|
+
params['Scope.variable'] = params[:variable]
|
16
|
+
node.doc.xpath("//stringProp[@name='Assertion.scope']").first.content = 'variable'
|
17
|
+
|
18
|
+
node.doc.children.first.add_child (
|
19
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
20
|
+
<stringProp name="Scope.variable">#{params[:variable]}</stringProp>
|
21
|
+
EOS
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
if params[:scope] == 'main'
|
26
|
+
node.doc.xpath("//stringProp[@name='Assertion.scope']").remove
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
attach_node(node, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
alias assert response_assertion
|
34
|
+
alias web_reg_find response_assertion
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def http_request_defaults(params = {}, &block)
|
4
|
+
params[:image_parser] = true if params.keys.include? :download_resources
|
5
|
+
params[:concurrentDwn] = true if params.keys.include? :use_concurrent_pool
|
6
|
+
params[:concurrentPool] = params[:use_concurrent_pool] if params.keys.include? :use_concurrent_pool
|
7
|
+
|
8
|
+
node = RubyJmeter::HttpRequestDefaults.new(params).tap do |node|
|
9
|
+
node.doc.children.first.add_child (
|
10
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
11
|
+
<stringProp name="HTTPSampler.embedded_url_re">#{params[:urls_must_match]}</stringProp>
|
12
|
+
EOS
|
13
|
+
) if params[:urls_must_match]
|
14
|
+
|
15
|
+
node.doc.children.first.add_child (
|
16
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
17
|
+
<boolProp name="HTTPSampler.md5">true</stringProp>
|
18
|
+
EOS
|
19
|
+
) if params[:md5]
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
attach_node(node, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
alias defaults http_request_defaults
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def user_parameters(params, &block)
|
4
|
+
params['Argument.name'] = params[:name] if params.is_a?(Hash)
|
5
|
+
|
6
|
+
params[:names] = Nokogiri::XML::Builder.new do |b|
|
7
|
+
b.builder do
|
8
|
+
params[:names].each do |name|
|
9
|
+
b.stringProp name, name: name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
params[:thread_values] = Nokogiri::XML::Builder.new do |b|
|
15
|
+
b.builder do
|
16
|
+
params[:thread_values].map do |user, values|
|
17
|
+
b.collectionProp name: user do
|
18
|
+
values.each_with_index.map do |value, index|
|
19
|
+
b.stringProp value, name: index
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
alias parameters user_parameters
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def foreach_controller(params = {}, &block)
|
4
|
+
node = RubyJmeter::ForeachController.new(params).tap do |node|
|
5
|
+
if params[:start_index]
|
6
|
+
params[:startIndex] = params[:start_index]
|
7
|
+
node.doc.children.first.add_child (
|
8
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
9
|
+
<stringProp name="ForeachController.startIndex"/>
|
10
|
+
EOS
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
if params[:end_index]
|
15
|
+
params[:endIndex] = params[:end_index]
|
16
|
+
node.doc.children.first.add_child (
|
17
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
18
|
+
<stringProp name="ForeachController.endIndex"/>
|
19
|
+
EOS
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def module_controller(params, &block)
|
4
|
+
node = RubyJmeter::ModuleController.new(params)
|
5
|
+
|
6
|
+
if params[:test_fragment]
|
7
|
+
params[:test_fragment].kind_of?(String) &&
|
8
|
+
params[:test_fragment].split('/')
|
9
|
+
elsif params[:node_path]
|
10
|
+
params[:node_path]
|
11
|
+
else
|
12
|
+
[]
|
13
|
+
end.each_with_index do |node_name, index|
|
14
|
+
node.doc.at_xpath('//collectionProp') <<
|
15
|
+
Nokogiri::XML(<<-EOS.strip_heredoc).children
|
16
|
+
<stringProp name="node_#{index}">#{node_name}</stringProp>
|
17
|
+
EOS
|
18
|
+
end
|
19
|
+
|
20
|
+
attach_node(node, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def throughput_controller(params = {}, &block)
|
4
|
+
params[:style] = 1 if params[:percent]
|
5
|
+
params[:maxThroughput] = params[:total] || params[:percent] || 1
|
6
|
+
|
7
|
+
node = RubyJmeter::ThroughputController.new(params)
|
8
|
+
node.doc.xpath(".//FloatProperty/value").first.content = params[:maxThroughput].to_f
|
9
|
+
|
10
|
+
attach_node(node, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
alias throughput throughput_controller
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def transaction_controller(*args, &block)
|
4
|
+
params = args.shift || {}
|
5
|
+
params = { name: params }.merge(args.shift || {}) if params.class == String
|
6
|
+
params[:parent] = params[:parent] || false
|
7
|
+
params[:includeTimers] = params[:include_timers] || false
|
8
|
+
node = RubyJmeter::TransactionController.new(params)
|
9
|
+
attach_node(node, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
alias transaction transaction_controller
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
alias auth http_authorization_manager
|
4
|
+
alias soap soapxmlrpc_request
|
5
|
+
alias ldap ldap_request
|
6
|
+
alias ldap_ext ldap_extended_request
|
7
|
+
alias ldap_extended ldap_extended_request
|
8
|
+
alias If if_controller
|
9
|
+
alias Switch switch_controller
|
10
|
+
alias While while_controller
|
11
|
+
alias Interleave random_controller
|
12
|
+
alias Random_order random_order_controller
|
13
|
+
alias Simple simple_controller
|
14
|
+
alias Once once_only_controller
|
15
|
+
alias view_results view_results_tree
|
16
|
+
alias log simple_data_writer
|
17
|
+
alias response_graph response_time_graph
|
18
|
+
alias bsh_pre beanshell_preprocessor
|
19
|
+
alias bsh_post beanshell_postprocessor
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def exists(variable, &block)
|
4
|
+
params ||= {}
|
5
|
+
params[:condition] = "\"${#{variable}}\" != \"\\${#{variable}}\""
|
6
|
+
params[:useExpression] = false
|
7
|
+
params[:name] = "if ${#{variable}}"
|
8
|
+
node = RubyJmeter::IfController.new(params)
|
9
|
+
|
10
|
+
attach_node(node, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module RubyJmeter
|
2
|
+
class ExtendedDSL < DSL
|
3
|
+
def flood(token, params = {})
|
4
|
+
RestClient.proxy = params[:proxy] if params[:proxy]
|
5
|
+
begin
|
6
|
+
file = Tempfile.new(['ruby-jmeter', '.jmx'])
|
7
|
+
file.write(doc.to_xml(indent: 2))
|
8
|
+
file.rewind
|
9
|
+
|
10
|
+
flood_files = {
|
11
|
+
file: File.new("#{file.path}", 'rb')
|
12
|
+
}
|
13
|
+
|
14
|
+
if params[:files]
|
15
|
+
flood_files.merge!(Hash[params[:files].map.with_index { |value, index| [index, File.new(value, 'rb')] }])
|
16
|
+
params.delete(:files)
|
17
|
+
end
|
18
|
+
|
19
|
+
response = RestClient.post "#{params[:endpoint] ? params[:endpoint] : 'https://api.flood.io'}/floods?auth_token=#{token}",
|
20
|
+
{
|
21
|
+
flood: {
|
22
|
+
tool: 'jmeter',
|
23
|
+
name: params[:name],
|
24
|
+
notes: params[:notes],
|
25
|
+
tag_list: params[:tag_list],
|
26
|
+
threads: params[:threads],
|
27
|
+
rampup: params[:rampup],
|
28
|
+
duration: params[:duration],
|
29
|
+
override_parameters: params[:override_parameters],
|
30
|
+
started: params[:started],
|
31
|
+
stopped: params[:stopped]
|
32
|
+
},
|
33
|
+
flood_files: flood_files,
|
34
|
+
region: params[:region],
|
35
|
+
multipart: true,
|
36
|
+
content_type: 'application/octet-stream'
|
37
|
+
}.merge(params)
|
38
|
+
if response.code == 201
|
39
|
+
logger.info 'Flood results at: #{JSON.parse(response)["permalink"]}'
|
40
|
+
else
|
41
|
+
logger.fatal "Sorry there was an error: #{JSON.parse(response)["error"]}"
|
42
|
+
end
|
43
|
+
rescue => e
|
44
|
+
logger.fatal "Sorry there was an error: #{JSON.parse(e.response)["error"]}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|