gridinit-jmeter 0.3.2 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. data/Gemfile +2 -1
  2. data/README.md +51 -72
  3. data/examples/basic_assertion.rb +6 -6
  4. data/examples/basic_auth.rb +5 -5
  5. data/examples/basic_cache.rb +5 -5
  6. data/examples/basic_cookies.rb +5 -5
  7. data/examples/basic_extract.rb +4 -10
  8. data/examples/basic_gc_results.rb +12 -9
  9. data/examples/basic_google.rb +3 -3
  10. data/examples/basic_grid.rb +3 -6
  11. data/examples/basic_header.rb +12 -10
  12. data/examples/basic_ldap_ext.rb +11 -12
  13. data/examples/basic_post.rb +5 -6
  14. data/examples/basic_query_params.rb +3 -3
  15. data/examples/basic_think_time.rb +7 -4
  16. data/examples/basic_throughput_shaping_timer.rb +4 -4
  17. data/examples/etsy_login_browse.rb +21 -21
  18. data/lib/gridinit-jmeter/DSL.md +237 -0
  19. data/lib/gridinit-jmeter/{idl → dsl}/access_log_sampler.rb +4 -2
  20. data/lib/gridinit-jmeter/{idl → dsl}/aggregate_graph.rb +4 -2
  21. data/lib/gridinit-jmeter/{idl → dsl}/aggregate_report.rb +4 -2
  22. data/lib/gridinit-jmeter/{idl → dsl}/ajp13_sampler.rb +5 -3
  23. data/lib/gridinit-jmeter/{idl → dsl}/assertion_results.rb +4 -2
  24. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_assertion.rb +4 -2
  25. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_listener.rb +4 -2
  26. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_postprocessor.rb +4 -2
  27. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_preprocessor.rb +4 -2
  28. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_sampler.rb +4 -2
  29. data/lib/gridinit-jmeter/{idl → dsl}/beanshell_timer.rb +4 -2
  30. data/lib/gridinit-jmeter/{idl → dsl}/bsf_assertion.rb +4 -2
  31. data/lib/gridinit-jmeter/{idl → dsl}/bsf_listener.rb +4 -2
  32. data/lib/gridinit-jmeter/{idl → dsl}/bsf_postprocessor.rb +4 -2
  33. data/lib/gridinit-jmeter/{idl → dsl}/bsf_preprocessor.rb +4 -2
  34. data/lib/gridinit-jmeter/{idl → dsl}/bsf_sampler.rb +4 -2
  35. data/lib/gridinit-jmeter/{idl → dsl}/bsf_timer.rb +4 -2
  36. data/lib/gridinit-jmeter/{idl → dsl}/compare_assertion.rb +4 -2
  37. data/lib/gridinit-jmeter/{idl → dsl}/comparison_assertion_visualizer.rb +4 -2
  38. data/lib/gridinit-jmeter/{idl → dsl}/constant_throughput_timer.rb +4 -2
  39. data/lib/gridinit-jmeter/{idl → dsl}/constant_timer.rb +4 -2
  40. data/lib/gridinit-jmeter/{idl → dsl}/counter.rb +4 -2
  41. data/lib/gridinit-jmeter/{idl → dsl}/cssjquery_extractor.rb +4 -2
  42. data/lib/gridinit-jmeter/{idl → dsl}/csv_data_set_config.rb +4 -2
  43. data/lib/gridinit-jmeter/{idl → dsl}/debug_postprocessor.rb +4 -2
  44. data/lib/gridinit-jmeter/{idl → dsl}/debug_sampler.rb +4 -2
  45. data/lib/gridinit-jmeter/{idl → dsl}/distribution_graphalpha.rb +4 -2
  46. data/lib/gridinit-jmeter/{idl → dsl}/duration_assertion.rb +4 -2
  47. data/lib/gridinit-jmeter/{idl → dsl}/foreach_controller.rb +4 -2
  48. data/lib/gridinit-jmeter/{idl → dsl}/ftp_request.rb +4 -2
  49. data/lib/gridinit-jmeter/{idl → dsl}/ftp_request_defaults.rb +4 -2
  50. data/lib/gridinit-jmeter/{idl → dsl}/gaussian_random_timer.rb +4 -2
  51. data/lib/gridinit-jmeter/{idl → dsl}/generate_summary_results.rb +4 -2
  52. data/lib/gridinit-jmeter/{idl → dsl}/graph_results.rb +4 -2
  53. data/lib/gridinit-jmeter/{idl → dsl}/html_assertion.rb +4 -2
  54. data/lib/gridinit-jmeter/{idl → dsl}/html_link_parser.rb +4 -2
  55. data/lib/gridinit-jmeter/{idl → dsl}/html_parameter_mask.rb +4 -2
  56. data/lib/gridinit-jmeter/dsl/http_authorization_manager.rb +36 -0
  57. data/lib/gridinit-jmeter/{idl → dsl}/http_cache_manager.rb +4 -2
  58. data/lib/gridinit-jmeter/{idl → dsl}/http_cookie_manager.rb +5 -2
  59. data/lib/gridinit-jmeter/{idl → dsl}/http_header_manager.rb +10 -3
  60. data/lib/gridinit-jmeter/{idl → dsl}/http_request.rb +5 -3
  61. data/lib/gridinit-jmeter/{idl → dsl}/http_request_defaults.rb +15 -4
  62. data/lib/gridinit-jmeter/{idl → dsl}/http_url_rewriting_modifier.rb +4 -2
  63. data/lib/gridinit-jmeter/{idl → dsl}/if_controller.rb +5 -2
  64. data/lib/gridinit-jmeter/{idl → dsl}/include_controller.rb +4 -2
  65. data/lib/gridinit-jmeter/{idl → dsl}/java_request.rb +4 -2
  66. data/lib/gridinit-jmeter/{idl → dsl}/java_request_defaults.rb +4 -2
  67. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_connection_configuration.rb +4 -2
  68. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_postprocessor.rb +4 -2
  69. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_preprocessor.rb +4 -2
  70. data/lib/gridinit-jmeter/{idl → dsl}/jdbc_request.rb +4 -2
  71. data/lib/gridinit-jmeter/{idl → dsl}/jms_pointtopoint.rb +6 -4
  72. data/lib/gridinit-jmeter/{idl → dsl}/jms_publisher.rb +5 -3
  73. data/lib/gridinit-jmeter/{idl → dsl}/jms_subscriber.rb +4 -2
  74. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_assertion.rb +4 -2
  75. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_listener.rb +4 -2
  76. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_postprocessor.rb +4 -2
  77. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_preprocessor.rb +4 -2
  78. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_sampler.rb +4 -2
  79. data/lib/gridinit-jmeter/{idl → dsl}/jsr223_timer.rb +4 -2
  80. data/lib/gridinit-jmeter/{idl → dsl}/junit_request.rb +4 -2
  81. data/lib/gridinit-jmeter/{idl → dsl}/keystore_configuration.rb +4 -2
  82. data/lib/gridinit-jmeter/{idl → dsl}/ldap_extended_request.rb +4 -2
  83. data/lib/gridinit-jmeter/{idl → dsl}/ldap_extended_request_defaults.rb +4 -2
  84. data/lib/gridinit-jmeter/{idl → dsl}/ldap_request.rb +5 -3
  85. data/lib/gridinit-jmeter/{idl → dsl}/ldap_request_defaults.rb +13 -4
  86. data/lib/gridinit-jmeter/{idl → dsl}/login_config_element.rb +4 -2
  87. data/lib/gridinit-jmeter/{idl → dsl}/loop_controller.rb +4 -2
  88. data/lib/gridinit-jmeter/{idl → dsl}/mail_reader_sampler.rb +4 -2
  89. data/lib/gridinit-jmeter/{idl → dsl}/mailer_visualizer.rb +4 -2
  90. data/lib/gridinit-jmeter/{idl → dsl}/md5hex_assertion.rb +4 -2
  91. data/lib/gridinit-jmeter/{idl → dsl}/module_controller.rb +4 -2
  92. data/lib/gridinit-jmeter/{idl → dsl}/monitor_results.rb +4 -2
  93. data/lib/gridinit-jmeter/{idl → dsl}/once_only_controller.rb +4 -2
  94. data/lib/gridinit-jmeter/{idl → dsl}/os_process_sampler.rb +6 -4
  95. data/lib/gridinit-jmeter/{idl → dsl}/poisson_random_timer.rb +4 -2
  96. data/lib/gridinit-jmeter/{idl → dsl}/random_controller.rb +4 -2
  97. data/lib/gridinit-jmeter/{idl → dsl}/random_order_controller.rb +4 -2
  98. data/lib/gridinit-jmeter/{idl → dsl}/random_variable.rb +4 -2
  99. data/lib/gridinit-jmeter/{idl → dsl}/recording_controller.rb +4 -2
  100. data/lib/gridinit-jmeter/{idl → dsl}/regex_user_parameters.rb +4 -2
  101. data/lib/gridinit-jmeter/{idl → dsl}/regular_expression_extractor.rb +5 -2
  102. data/lib/gridinit-jmeter/{idl → dsl}/response_assertion.rb +8 -3
  103. data/lib/gridinit-jmeter/{idl → dsl}/response_time_graph.rb +4 -2
  104. data/lib/gridinit-jmeter/{idl → dsl}/result_status_action_handler.rb +4 -2
  105. data/lib/gridinit-jmeter/{idl → dsl}/runtime_controller.rb +4 -2
  106. data/lib/gridinit-jmeter/{idl → dsl}/save_responses_to_a_file.rb +4 -2
  107. data/lib/gridinit-jmeter/{idl → dsl}/simple_config_element.rb +4 -2
  108. data/lib/gridinit-jmeter/{idl → dsl}/simple_controller.rb +4 -2
  109. data/lib/gridinit-jmeter/{idl → dsl}/simple_data_writer.rb +4 -2
  110. data/lib/gridinit-jmeter/{idl → dsl}/smime_assertion.rb +4 -2
  111. data/lib/gridinit-jmeter/{idl → dsl}/smtp_sampler.rb +4 -2
  112. data/lib/gridinit-jmeter/{idl → dsl}/soapxmlrpc_request.rb +4 -2
  113. data/lib/gridinit-jmeter/{idl → dsl}/spline_visualizer.rb +4 -2
  114. data/lib/gridinit-jmeter/{idl → dsl}/summary_report.rb +4 -2
  115. data/lib/gridinit-jmeter/{idl → dsl}/switch_controller.rb +4 -2
  116. data/lib/gridinit-jmeter/{idl → dsl}/synchronizing_timer.rb +4 -2
  117. data/lib/gridinit-jmeter/{idl → dsl}/tcp_sampler.rb +4 -2
  118. data/lib/gridinit-jmeter/{idl → dsl}/tcp_sampler_config.rb +4 -2
  119. data/lib/gridinit-jmeter/{idl → dsl}/test_action.rb +4 -2
  120. data/lib/gridinit-jmeter/{idl → dsl}/test_plan.rb +5 -3
  121. data/lib/gridinit-jmeter/{idl → dsl}/thread_group.rb +5 -3
  122. data/lib/gridinit-jmeter/{idl → dsl}/throughput_controller.rb +5 -3
  123. data/lib/gridinit-jmeter/{idl → dsl}/transaction_controller.rb +6 -3
  124. data/lib/gridinit-jmeter/{idl → dsl}/uniform_random_timer.rb +4 -2
  125. data/lib/gridinit-jmeter/dsl/user_defined_variables.rb +35 -0
  126. data/lib/gridinit-jmeter/{idl → dsl}/user_parameters.rb +4 -2
  127. data/lib/gridinit-jmeter/{idl → dsl}/view_results_in_table.rb +4 -2
  128. data/lib/gridinit-jmeter/{idl → dsl}/view_results_tree.rb +4 -2
  129. data/lib/gridinit-jmeter/{idl → dsl}/while_controller.rb +4 -2
  130. data/lib/gridinit-jmeter/{idl → dsl}/xml_assertion.rb +4 -2
  131. data/lib/gridinit-jmeter/{idl → dsl}/xml_schema_assertion.rb +4 -2
  132. data/lib/gridinit-jmeter/{idl → dsl}/xpath_assertion.rb +4 -2
  133. data/lib/gridinit-jmeter/{idl → dsl}/xpath_extractor.rb +4 -2
  134. data/lib/gridinit-jmeter/dsl.rb +170 -187
  135. data/lib/gridinit-jmeter/helpers/helper.rb +43 -0
  136. data/lib/gridinit-jmeter/helpers/parser.rb +109 -0
  137. data/lib/gridinit-jmeter/idl.rb +16 -6
  138. data/lib/gridinit-jmeter/idl.xml +54 -11
  139. data/lib/gridinit-jmeter/{listeners → plugins}/gc_console_status_logger.rb +0 -0
  140. data/lib/gridinit-jmeter/{listeners → plugins}/gc_latencies_over_time.rb +0 -0
  141. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_codes_per_second.rb +0 -0
  142. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_distribution.rb +0 -0
  143. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_over_time.rb +0 -0
  144. data/lib/gridinit-jmeter/{listeners → plugins}/gc_response_times_percentiles.rb +0 -0
  145. data/lib/gridinit-jmeter/{listeners → plugins}/gc_transactions_per_second.rb +0 -0
  146. data/lib/gridinit-jmeter/{timers/gc_throughput_shaping_timer.rb → plugins/gc_variable_throughput_timer.rb} +1 -1
  147. data/lib/gridinit-jmeter/version.rb +1 -1
  148. data/lib/gridinit-jmeter.rb +6 -105
  149. data/spec/dsl_spec.rb +377 -82
  150. metadata +131 -174
  151. data/examples/basic_proxy.rb +0 -8
  152. data/examples/basic_results.rb +0 -22
  153. data/examples/basic_run.rb +0 -12
  154. data/examples/basic_simple_data_writer.rb +0 -14
  155. data/examples/basic_stdout.rb +0 -8
  156. data/examples/basic_test_data.rb +0 -15
  157. data/examples/basic_testplan.jmx +0 -138
  158. data/examples/basic_testplan.rb +0 -44
  159. data/examples/jbhifi_now_search.rb +0 -94
  160. data/lib/gridinit-jmeter/assertions/response_assertion.rb +0 -55
  161. data/lib/gridinit-jmeter/config/auth_manager.rb +0 -26
  162. data/lib/gridinit-jmeter/config/cache_manager.rb +0 -20
  163. data/lib/gridinit-jmeter/config/cookie_manager.rb +0 -21
  164. data/lib/gridinit-jmeter/config/counter_config.rb +0 -24
  165. data/lib/gridinit-jmeter/config/header_manager.rb +0 -26
  166. data/lib/gridinit-jmeter/config/random_variable.rb +0 -24
  167. data/lib/gridinit-jmeter/config/request_defaults.rb +0 -31
  168. data/lib/gridinit-jmeter/config/user_defined_variable.rb +0 -25
  169. data/lib/gridinit-jmeter/controllers/if_controller.rb +0 -20
  170. data/lib/gridinit-jmeter/controllers/interleave.rb +0 -18
  171. data/lib/gridinit-jmeter/controllers/loop_controller.rb +0 -19
  172. data/lib/gridinit-jmeter/controllers/once_only.rb +0 -17
  173. data/lib/gridinit-jmeter/controllers/random_order.rb +0 -16
  174. data/lib/gridinit-jmeter/controllers/simple.rb +0 -17
  175. data/lib/gridinit-jmeter/controllers/switch.rb +0 -20
  176. data/lib/gridinit-jmeter/controllers/throughput.rb +0 -26
  177. data/lib/gridinit-jmeter/controllers/transaction.rb +0 -19
  178. data/lib/gridinit-jmeter/controllers/while_controller.rb +0 -18
  179. data/lib/gridinit-jmeter/helpers/dsl_helper.rb +0 -21
  180. data/lib/gridinit-jmeter/idl/http_authorization_manager.rb +0 -26
  181. data/lib/gridinit-jmeter/idl/user_defined_variables.rb +0 -26
  182. data/lib/gridinit-jmeter/listeners/aggregate_report.rb +0 -47
  183. data/lib/gridinit-jmeter/listeners/graph_visualizer.rb +0 -46
  184. data/lib/gridinit-jmeter/listeners/response_time_graph_visualizer.rb +0 -47
  185. data/lib/gridinit-jmeter/listeners/simple_data_writer.rb +0 -51
  186. data/lib/gridinit-jmeter/listeners/stat_visualizer.rb +0 -46
  187. data/lib/gridinit-jmeter/listeners/summary_report.rb +0 -46
  188. data/lib/gridinit-jmeter/listeners/table_visualizer.rb +0 -46
  189. data/lib/gridinit-jmeter/listeners/view_results_full_visualizer.rb +0 -57
  190. data/lib/gridinit-jmeter/post_processors/regex_extractor.rb +0 -34
  191. data/lib/gridinit-jmeter/post_processors/xpath_extractor.rb +0 -23
  192. data/lib/gridinit-jmeter/pre_processors/bean_shell_pre_processor.rb +0 -23
  193. data/lib/gridinit-jmeter/samplers/http_sampler.rb +0 -99
  194. data/lib/gridinit-jmeter/samplers/ldap_ext_sampler.rb +0 -36
  195. data/lib/gridinit-jmeter/samplers/soap_sampler.rb +0 -26
  196. data/lib/gridinit-jmeter/test_plan/test_plan.rb +0 -23
  197. data/lib/gridinit-jmeter/threads/thread_group.rb +0 -30
  198. data/lib/gridinit-jmeter/timers/gaussian_random_timer.rb +0 -18
@@ -12,9 +12,10 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'UserParameters'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <UserParameters guiclass="UserParametersGui" testclass="UserParameters" testname="#{name}" enabled="true">
18
+ <UserParameters guiclass="UserParametersGui" testclass="UserParameters" testname="#{params[:name]}" enabled="true">
18
19
  <collectionProp name="UserParameters.names"/>
19
20
  <collectionProp name="UserParameters.thread_values">
20
21
  <collectionProp name="1"/>
@@ -23,6 +24,7 @@ module Gridinit
23
24
  </UserParameters>)
24
25
  EOS
25
26
  update params
27
+ update_at_xpath params if params[:update_at_xpath]
26
28
  end
27
29
  end
28
30
 
@@ -12,9 +12,10 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'ViewResultsInTable'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="#{name}" enabled="true">
18
+ <ResultCollector guiclass="TableVisualizer" testclass="ResultCollector" testname="#{params[:name]}" enabled="true">
18
19
  <boolProp name="ResultCollector.error_logging">false</boolProp>
19
20
  <objProp>
20
21
  <name>saveConfig</name>
@@ -49,6 +50,7 @@ module Gridinit
49
50
  </ResultCollector>)
50
51
  EOS
51
52
  update params
53
+ update_at_xpath params if params[:update_at_xpath]
52
54
  end
53
55
  end
54
56
 
@@ -12,9 +12,10 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'ViewResultsTree'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="#{name}" enabled="true">
18
+ <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="#{params[:name]}" enabled="true">
18
19
  <boolProp name="ResultCollector.error_logging">false</boolProp>
19
20
  <objProp>
20
21
  <name>saveConfig</name>
@@ -49,6 +50,7 @@ module Gridinit
49
50
  </ResultCollector>)
50
51
  EOS
51
52
  update params
53
+ update_at_xpath params if params[:update_at_xpath]
52
54
  end
53
55
  end
54
56
 
@@ -12,13 +12,15 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'WhileController'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="#{name}" enabled="true">
18
+ <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="#{params[:name]}" enabled="true">
18
19
  <stringProp name="WhileController.condition"/>
19
20
  </WhileController>)
20
21
  EOS
21
22
  update params
23
+ update_at_xpath params if params[:update_at_xpath]
22
24
  end
23
25
  end
24
26
 
@@ -12,11 +12,13 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'XmlAssertion'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <XMLAssertion guiclass="XMLAssertionGui" testclass="XMLAssertion" testname="#{name}" enabled="true"/>)
18
+ <XMLAssertion guiclass="XMLAssertionGui" testclass="XMLAssertion" testname="#{params[:name]}" enabled="true"/>)
18
19
  EOS
19
20
  update params
21
+ update_at_xpath params if params[:update_at_xpath]
20
22
  end
21
23
  end
22
24
 
@@ -12,13 +12,15 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'XmlSchemaAssertion'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <XMLSchemaAssertion guiclass="XMLSchemaAssertionGUI" testclass="XMLSchemaAssertion" testname="#{name}" enabled="true">
18
+ <XMLSchemaAssertion guiclass="XMLSchemaAssertionGUI" testclass="XMLSchemaAssertion" testname="#{params[:name]}" enabled="true">
18
19
  <stringProp name="xmlschema_assertion_filename"/>
19
20
  </XMLSchemaAssertion>)
20
21
  EOS
21
22
  update params
23
+ update_at_xpath params if params[:update_at_xpath]
22
24
  end
23
25
  end
24
26
 
@@ -12,9 +12,10 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'XpathAssertion'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <XPathAssertion guiclass="XPathAssertionGui" testclass="XPathAssertion" testname="#{name}" enabled="true">
18
+ <XPathAssertion guiclass="XPathAssertionGui" testclass="XPathAssertion" testname="#{params[:name]}" enabled="true">
18
19
  <boolProp name="XPath.negate">false</boolProp>
19
20
  <stringProp name="XPath.xpath">/</stringProp>
20
21
  <boolProp name="XPath.validate">false</boolProp>
@@ -24,6 +25,7 @@ module Gridinit
24
25
  </XPathAssertion>)
25
26
  EOS
26
27
  update params
28
+ update_at_xpath params if params[:update_at_xpath]
27
29
  end
28
30
  end
29
31
 
@@ -12,9 +12,10 @@ module Gridinit
12
12
  attr_accessor :doc
13
13
  include Helper
14
14
 
15
- def initialize(name, params={})
15
+ def initialize(params={})
16
+ params[:name] ||= 'XpathExtractor'
16
17
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
17
- <XPathExtractor guiclass="XPathExtractorGui" testclass="XPathExtractor" testname="#{name}" enabled="true">
18
+ <XPathExtractor guiclass="XPathExtractorGui" testclass="XPathExtractor" testname="#{params[:name]}" enabled="true">
18
19
  <stringProp name="XPathExtractor.default"/>
19
20
  <stringProp name="XPathExtractor.refname"/>
20
21
  <stringProp name="XPathExtractor.xpathQuery"/>
@@ -24,6 +25,7 @@ module Gridinit
24
25
  </XPathExtractor>)
25
26
  EOS
26
27
  update params
28
+ update_at_xpath params if params[:update_at_xpath]
27
29
  end
28
30
  end
29
31
 
@@ -1,22 +1,9 @@
1
1
  module Gridinit
2
2
 
3
- def dsl_eval(dsl, &block)
4
- block_context = eval("self", block.binding)
5
- proxy_context = Gridinit::Jmeter::FallbackContextProxy.new(dsl, block_context)
6
- begin
7
- block_context.instance_variables.each { |ivar| proxy_context.instance_variable_set(ivar, block_context.instance_variable_get(ivar)) }
8
- proxy_context.instance_eval(&block)
9
- ensure
10
- block_context.instance_variables.each { |ivar| block_context.instance_variable_set(ivar, proxy_context.instance_variable_get(ivar)) }
11
- end
12
- dsl
13
- end
14
-
15
- module_function :dsl_eval
16
-
17
3
  module Jmeter
18
4
 
19
- class DSL
5
+ class ExtendedDSL < DSL
6
+ include Parser
20
7
  attr_accessor :root
21
8
 
22
9
  def initialize
@@ -29,295 +16,291 @@ module Gridinit
29
16
  EOF
30
17
  node = Gridinit::Jmeter::TestPlan.new
31
18
 
32
-
33
19
  @current_node = @root.at_xpath("//jmeterTestPlan/hashTree")
34
20
  @current_node = attach_to_last(node)
35
21
 
36
- variables(
37
- :name => 'testguid',
38
- :value => '${__P(testguid,${__time(,)})}',
39
- :comments => 'The testguid variable is mandatory when running on the Grid.') {}
22
+ variables :name => 'testguid',
23
+ :value => '${__P(testguid,${__time(,)})}',
24
+ :comments => 'Gridinit testguid automatically generated by DSL'
40
25
  end
41
26
 
42
- def variables(params={}, &block)
43
- node = Gridinit::Jmeter::UserDefinedVariable.new(params)
44
- attach_node(node, &block)
45
- end
27
+ ##
28
+ # Config Elements
46
29
 
47
- def defaults(params={}, &block)
48
- node = Gridinit::Jmeter::RequestDefaults.new(params)
49
- attach_node(node, &block)
30
+ def user_defined_variables(params, &block)
31
+ params['Argument.name'] = params[:name]
32
+ super
50
33
  end
51
34
 
52
- def cookies(params={}, &block)
53
- node = Gridinit::Jmeter::CookieManager.new(params)
54
- attach_node(node, &block)
55
- end
35
+ alias_method :variables, :user_defined_variables
56
36
 
57
- def cache(params={}, &block)
58
- node = Gridinit::Jmeter::CacheManager.new(params)
59
- attach_node(node, &block)
60
- end
37
+ alias_method :defaults, :http_request_defaults
61
38
 
62
- def header(params={}, &block)
63
- node = Gridinit::Jmeter::HeaderManager.new(params)
64
- attach_node(node, &block)
39
+ def http_cookie_manager(params={}, &block)
40
+ params[:clearEachIteration] = true if params.keys.include? 'clear_each_iteration'
41
+ super
65
42
  end
66
43
 
67
- def with_xhr(params={}, &block)
68
- node = Gridinit::Jmeter::HeaderManager.new(
69
- params.merge('X-Requested-With' => 'XMLHttpRequest')
70
- )
71
- attach_node(node, &block)
72
- end
44
+ alias_method :cookies, :http_cookie_manager
73
45
 
74
- def with_user_agent(device, params={}, &block)
75
- node = Gridinit::Jmeter::HeaderManager.new(
76
- params.merge('User-Agent' => Gridinit::Jmeter::UserAgent.new(device).string)
77
- )
78
- attach_node(node, &block)
46
+ def http_cache_manager(params={}, &block)
47
+ params[:clearEachIteration] = true if params.keys.include? 'clear_each_iteration'
48
+ super
79
49
  end
80
50
 
81
- def auth(params={}, &block)
82
- node = Gridinit::Jmeter::AuthManager.new(params)
83
- attach_node(node, &block)
84
- end
51
+ alias_method :cache, :http_cache_manager
85
52
 
86
- def threads(num_threads=1, params={}, &block)
87
- node = Gridinit::Jmeter::ThreadGroup.new(num_threads, params)
88
- attach_node(node, &block)
53
+ def with_user_agent(device)
54
+ http_header_manager name: 'User-Agent',
55
+ value: Gridinit::Jmeter::UserAgent.new(device).string
89
56
  end
90
57
 
91
- def transaction(name="Transaction Contoller", params={}, &block)
92
- node = Gridinit::Jmeter::Transaction.new(name, params)
93
- attach_node(node, &block)
58
+ def http_header_manager(params, &block)
59
+ params['Header.name'] = params[:name]
60
+ super
94
61
  end
95
62
 
96
- def exists(var, params={}, &block)
97
- params[:condition] = "'${#{var}}'.length > 0"
98
- node = Gridinit::Jmeter::IfController.new("if #{var}", params)
99
- attach_node(node, &block)
100
- end
63
+ alias_method :header, :http_header_manager
101
64
 
102
- def once(name="do once", params={}, &block)
103
- node = Gridinit::Jmeter::OnceOnly.new(name, params)
104
- attach_node(node, &block)
105
- end
65
+ alias_method :auth, :http_authorization_manager
106
66
 
107
- def throughput(name="throughput", percent=100.0, params={}, &block)
108
- node = Gridinit::Jmeter::Throughput.new(name, percent, params)
67
+ def thread_group(*args, &block)
68
+ params = args.shift || {}
69
+ params = { count: params }.merge(args.shift || {}) if params.class == Fixnum
70
+ params[:num_threads] = params[:count] || 1
71
+ params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil
72
+ params[:start_time] = params[:start_time] || Time.now.to_i * 1000
73
+ params[:end_time] = params[:end_time] || Time.now.to_i * 1000
74
+ params[:duration] ||= 60
75
+ params[:continue_forever] ||= false
76
+ params[:loops] = -1 if params[:continue_forever]
77
+ node = Gridinit::Jmeter::ThreadGroup.new(params)
109
78
  attach_node(node, &block)
110
79
  end
111
80
 
112
- def If(name="If Controller", condition="", params={}, &block)
113
- node = Gridinit::Jmeter::IfController.new(name, condition, params)
114
- attach_node(node, &block)
115
- end
81
+ alias_method :threads, :thread_group
116
82
 
117
- def Loop(loops=1, params={}, &block)
118
- node = Gridinit::Jmeter::LoopController.new(loops, params)
119
- attach_node(node, &block)
120
- end
83
+ ##
84
+ # HTTP Samplers
121
85
 
122
- def Switch(name, switch_value, params={}, &block)
123
- node = Gridinit::Jmeter::SwitchController.new(name, switch_value, params)
86
+ def get(*args, &block)
87
+ params = args.shift || {}
88
+ params = { url: params }.merge(args.shift || {}) if params.class == String
89
+ params[:method] ||= 'GET'
90
+ params[:name] ||= params[:url]
91
+ parse_http_request(params)
92
+ node = Gridinit::Jmeter::HttpRequest.new(params)
124
93
  attach_node(node, &block)
125
94
  end
126
95
 
127
- def While(condition, params={}, &block)
128
- node = Gridinit::Jmeter::WhileController.new(condition, params)
129
- attach_node(node, &block)
130
- end
96
+ alias_method :visit, :get
131
97
 
132
- def counter(name="counter", params={}, &block)
133
- node = Gridinit::Jmeter::CounterConfig.new(name, params)
98
+ def post(*args, &block)
99
+ params = args.shift || {}
100
+ params = { url: params }.merge(args.shift || {}) if params.class == String
101
+ params[:method] ||= 'POST'
102
+ params[:name] ||= params[:url]
103
+ parse_http_request(params)
104
+ node = Gridinit::Jmeter::HttpRequest.new(params)
134
105
  attach_node(node, &block)
135
106
  end
136
107
 
137
- def random_variable(name, min, max, params={}, &block)
138
- node = Gridinit::Jmeter::RandomVariableConfig.new(name, min, max, params)
139
- attach_node(node, &block)
140
- end
108
+ alias_method :submit, :post
141
109
 
142
- def random_order(name='Random Order Controller', params={}, &block)
143
- node = Gridinit::Jmeter::RandomOrderController.new(name, params)
110
+ def delete(*args, &block)
111
+ params = args.shift || {}
112
+ params = { url: params }.merge(args.shift || {}) if params.class == String
113
+ params[:method] ||= 'DELETE'
114
+ params[:name] ||= params[:url]
115
+ parse_http_request(params)
116
+ node = Gridinit::Jmeter::HttpRequest.new(params)
144
117
  attach_node(node, &block)
145
118
  end
146
119
 
147
- def interleave(name='Interleave Controller', params={}, &block)
148
- node = Gridinit::Jmeter::InterleaveController.new(name, params)
120
+ def put(*args, &block)
121
+ params = args.shift || {}
122
+ params = { url: params }.merge(args.shift || {}) if params.class == String
123
+ params[:method] ||= 'PUT'
124
+ params[:name] ||= params[:url]
125
+ parse_http_request(params)
126
+ node = Gridinit::Jmeter::HttpRequest.new(params)
149
127
  attach_node(node, &block)
150
128
  end
151
129
 
152
- def simple(name='Simple Controller', params={}, &block)
153
- node = Gridinit::Jmeter::SimpleController.new(name, params)
154
- attach_node(node, &block)
130
+ def with_xhr
131
+ http_header_manager name: 'X-Requested-With',
132
+ value: 'XMLHttpRequest'
155
133
  end
156
134
 
157
- def bsh_pre(script, params={}, &block)
158
- node = Gridinit::Jmeter::BeanShellPreProcessor.new(script, params)
159
- attach_node(node, &block)
160
- end
135
+ ##
136
+ # Other Samplers
161
137
 
162
- def visit(name="HTTP Request", url="", params={}, &block)
163
- params[:method] ||= 'GET'
164
- node = Gridinit::Jmeter::HttpSampler.new(name, url, params)
165
- node = Gridinit::Jmeter::HttpSampler.new(name, url, params)
166
- attach_node(node, &block)
138
+ def soapxmlrpc_request(params, &block)
139
+ params[:method] ||= 'POST'
140
+ super
167
141
  end
168
142
 
169
- def soap(name="SOAP Request", params={}, &block)
170
- params[:method] = 'POST' if params[:method] == nil
171
- node = Gridinit::Jmeter::SoapSampler.new(name, params)
172
- attach_to_last(node, caller)
173
- self.instance_exec(&block) if block
174
- end
143
+ alias_method :soap, :soapxmlrpc_request
175
144
 
176
- alias_method :get, :visit
145
+ alias_method :ldap, :ldap_request
177
146
 
178
- def submit(name="HTTP Request", url="", params={}, &block)
179
- params[:method] ||= 'POST'
180
- node = Gridinit::Jmeter::HttpSampler.new(name, url, params)
181
- attach_node(node, &block)
182
- end
147
+ alias_method :ldap_ext, :ldap_extended_request
183
148
 
184
- alias_method :post, :submit
149
+ alias_method :ldap_extended, :ldap_extended_request
185
150
 
186
- def delete(name="HTTP Request", url="", params={}, &block)
187
- params[:method] ||= 'DELETE'
188
- node = Gridinit::Jmeter::HttpSampler.new(name, url, params)
189
- attach_node(node, &block)
190
- end
191
151
 
192
- def put(name="HTTP Request", url="", params={}, &block)
193
- params[:method] ||= 'PUT'
194
- node = Gridinit::Jmeter::HttpSampler.new(name, url, params)
195
- attach_node(node, &block)
196
- end
152
+ ##
153
+ # Controllers
197
154
 
198
- def extract(*args, &block)
199
- node = case args.first
200
- when :regex
201
- Gridinit::Jmeter::RegexExtractor.new(*args[1..-1])
202
- when :xpath
203
- Gridinit::Jmeter::XpathExtractor.new(*args[1..-1])
204
- else
205
- Gridinit::Jmeter::RegexExtractor.new(*args)
206
- end
155
+ def transaction_controller(*args, &block)
156
+ params = args.shift || {}
157
+ params = { name: params }.merge(args.shift || {}) if params.class == String
158
+ params[:parent] ||= true
159
+ params[:includeTimers] = params[:include_timers] || false
160
+ node = Gridinit::Jmeter::TransactionController.new(params)
207
161
  attach_node(node, &block)
208
162
  end
209
163
 
210
- alias_method :web_reg_save_param, :extract
164
+ alias_method :transaction, :transaction_controller
211
165
 
212
- def random_timer(delay=0, range=0, &block)
213
- node = Gridinit::Jmeter::GaussianRandomTimer.new(delay, range)
166
+ def exists(variable, &block)
167
+ params ||= {}
168
+ params[:condition] = "'${#{variable}}'.length > 0"
169
+ node = Gridinit::Jmeter::IfController.new(params)
214
170
  attach_node(node, &block)
215
171
  end
216
172
 
217
- alias_method :think_time, :random_timer
173
+ alias_method :If, :if_controller
218
174
 
219
- def assert(match="contains", pattern="", params={}, &block)
220
- node = Gridinit::Jmeter::ResponseAssertion.new(match, pattern, params)
221
- attach_node(node, &block)
175
+ def loop_controller(params, &block)
176
+ params[:loops] = params[:count] || 1
177
+ super
222
178
  end
223
179
 
224
- alias_method :web_reg_find, :assert
180
+ alias_method :Loop, :loop_controller
225
181
 
226
- def view_results_full_visualizer(name="View Results Tree", params={}, &block)
227
- node = Gridinit::Jmeter::ViewResultsFullVisualizer.new(name, params)
228
- attach_node(node, &block)
229
- end
182
+ alias_method :Throughput, :throughput_controller
230
183
 
231
- alias_method :view_results, :view_results_full_visualizer
184
+ alias_method :Switch, :switch_controller
232
185
 
233
- def table_visualizer(name="View Results in Table", params={}, &block)
234
- node = Gridinit::Jmeter::TableVisualizer.new(name, params)
235
- attach_node(node, &block)
236
- end
186
+ alias_method :While, :while_controller
237
187
 
238
- def graph_visualizer(name="Graph Results", params={}, &block)
239
- node = Gridinit::Jmeter::GraphVisualizer.new(name, params)
240
- attach_node(node, &block)
241
- end
188
+ alias_method :Interleave, :random_controller
242
189
 
243
- def stat_visualizer(name="Stat Results", params={}, &block)
244
- node = Gridinit::Jmeter::StatVisualizer.new(name, params)
245
- attach_node(node, &block)
246
- end
190
+ alias_method :Random_order, :random_order_controller
247
191
 
248
- def simple_data_writer(name="Simple Data Writer", params={}, &block)
249
- node = Gridinit::Jmeter::SimpleDataWriter.new(name, params)
250
- attach_node(node, &block)
251
- end
192
+ alias_method :Simple, :simple_controller
193
+
194
+ alias_method :Once, :once_only_controller
195
+
196
+ ##
197
+ # Listeners
198
+
199
+ alias_method :view_results, :view_results_tree
252
200
 
253
201
  alias_method :log, :simple_data_writer
254
202
 
255
- def response_time_graph_visualizer(name="Reponse Time Graph", params={}, &block)
256
- node = Gridinit::Jmeter::ResponseTimeGraphVisualizer.new(name, params)
257
- attach_node(node, &block)
203
+ alias_method :response_graph, :response_time_graph
204
+
205
+ ##
206
+ # Other Elements
207
+
208
+ def beanshell_preprocessor(params, &block)
209
+ params[:script] = "<![CDATA[#{params[:script]}]]>"
210
+ super
258
211
  end
259
212
 
260
- alias_method :response_graph, :response_time_graph_visualizer
213
+ alias_method :bsh_pre, :beanshell_preprocessor
261
214
 
262
- def summary_report(name="Summary Report", params={}, &block)
263
- node = Gridinit::Jmeter::SummaryReport.new(name, params)
215
+ def extract(params, &block)
216
+ node = if params[:regex]
217
+ params[:refname] = params[:name]
218
+ params[:regex] = params[:regex] #CGI.escapeHTML
219
+ params[:template] = params[:template] || "$1$"
220
+ Gridinit::Jmeter::RegularExpressionExtractor.new(params)
221
+ else
222
+ params[:refname] = params[:name]
223
+ params[:xpathQuery] = params[:xpath]
224
+ Gridinit::Jmeter::XpathExtractor.new(params)
225
+ end
264
226
  attach_node(node, &block)
265
227
  end
266
228
 
267
- def aggregate_report(name="Aggregate Report", params={}, &block)
268
- node = Gridinit::Jmeter::AggregateReport.new(name, params)
229
+ alias_method :web_reg_save_param, :extract
230
+
231
+ def random_timer(delay=0, range=0, &block)
232
+ params={}
233
+ params[:delay] = delay
234
+ params[:range] = range
235
+ node = Gridinit::Jmeter::GaussianRandomTimer.new(params)
269
236
  attach_node(node, &block)
270
237
  end
271
238
 
272
- def ldap_ext(name="LDAPExtSampler", params={}, &block)
273
- node = Gridinit::Jmeter::LDAPExtSampler.new(name, params)
239
+ alias_method :think_time, :random_timer
240
+
241
+ def response_assertion(params={}, &block)
242
+ params[:test_type] = parse_test_type(params)
243
+ params[:match] = params.values.first
244
+ node = Gridinit::Jmeter::ResponseAssertion.new(params)
245
+ node.doc.xpath("//stringProp[@name='Assertion.scope']").remove if
246
+ params[:scope] == 'main' || params['scope'] == 'main'
274
247
  attach_node(node, &block)
275
248
  end
276
249
 
277
- def gc_response_codes_per_second(name="jp@gc - Response Codes per Second", params={}, &block)
250
+ alias_method :assert, :response_assertion
251
+
252
+ alias_method :web_reg_find, :response_assertion
253
+
254
+ ##
255
+ # JMeter Plugins
256
+
257
+ def response_codes_per_second(name="jp@gc - Response Codes per Second", params={}, &block)
278
258
  node = Gridinit::Jmeter::GCResponseCodesPerSecond.new(name, params)
279
259
  attach_node(node, &block)
280
260
  end
281
261
 
282
- def gc_response_times_distribution(name="jp@gc - Response Times Distribution", params={}, &block)
262
+ def response_times_distribution(name="jp@gc - Response Times Distribution", params={}, &block)
283
263
  node = Gridinit::Jmeter::GCResponseTimesDistribution.new(name, params)
284
264
  attach_node(node, &block)
285
265
  end
286
266
 
287
- def gc_response_times_over_time(name="jp@gc - Response Times Over Time", params={}, &block)
267
+ def response_times_over_time(name="jp@gc - Response Times Over Time", params={}, &block)
288
268
  node = Gridinit::Jmeter::GCResponseTimesOverTime.new(name, params)
289
269
  attach_node(node, &block)
290
270
  end
291
271
 
292
- def gc_response_times_percentiles(name="jp@gc - Response Times Percentiles", params={}, &block)
272
+ def response_times_percentiles(name="jp@gc - Response Times Percentiles", params={}, &block)
293
273
  node = Gridinit::Jmeter::GCResponseTimesPercentiles.new(name, params)
294
274
  attach_node(node, &block)
295
275
  end
296
276
 
297
- def gc_transactions_per_second(name="jp@gc - Transactions per Second", params={}, &block)
277
+ def transactions_per_second(name="jp@gc - Transactions per Second", params={}, &block)
298
278
  node = Gridinit::Jmeter::GCTransactionsPerSecond.new(name, params)
299
279
  attach_node(node, &block)
300
280
  end
301
281
 
302
- def gc_latencies_over_time(name="jp@gc - Response Latencies Over Time", params={}, &block)
282
+ def latencies_over_time(name="jp@gc - Response Latencies Over Time", params={}, &block)
303
283
  node = Gridinit::Jmeter::GCLatenciesOverTime.new(name, params)
304
284
  attach_node(node, &block)
305
285
  end
306
286
 
307
- def gc_console_status_logger(name="jp@gc - Console Status Logger", params={}, &block)
287
+ def console_status_logger(name="jp@gc - Console Status Logger", params={}, &block)
308
288
  node = Gridinit::Jmeter::GCConsoleStatusLogger.new(name, params)
309
289
  attach_node(node, &block)
310
290
  end
311
291
 
312
- alias_method :console, :gc_console_status_logger
292
+ alias_method :console, :console_status_logger
313
293
 
314
294
  def throughput_shaper(name="jp@gc - Throughput Shaping Timer", steps=[], params={}, &block)
315
- node = Gridinit::Jmeter::ThroughputShapingTimer.new(name, steps)
295
+ node = Gridinit::Jmeter::GCThroughputShapingTimer.new(name, steps)
316
296
  attach_node(node, &block)
317
297
  end
318
298
 
319
299
  alias_method :shaper, :throughput_shaper
320
300
 
301
+
302
+ # API Methods
303
+
321
304
  def out(params={})
322
305
  puts doc.to_xml(:indent => 2)
323
306
  end
@@ -425,5 +408,5 @@ module Gridinit
425
408
  end
426
409
 
427
410
  def test(&block)
428
- Gridinit.dsl_eval(Gridinit::Jmeter::DSL.new, &block)
411
+ Gridinit.dsl_eval(Gridinit::Jmeter::ExtendedDSL.new, &block)
429
412
  end