ruby-jmeter 2.13.5 → 2.13.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bc45180e9ae9b2911cbe73279e54fe7a367b33b
4
- data.tar.gz: 9e1d2afeb4dcaf99274a2b3804717fdcfa2134ed
3
+ metadata.gz: 1aba397b4e80c6a55097ab98a90b1d4349a833c9
4
+ data.tar.gz: 380054d564616ec16f3f5e7c29d5c1ffb34df146
5
5
  SHA512:
6
- metadata.gz: 5c7322a18414e08695dbd0eb280af2423580c65cf801e7b5d89345f171016ad2a80f1f42a60a74a7705216cf33c755813b91ffb19930cd35cede75a26f9ee7d1
7
- data.tar.gz: 6db79206bc45f66291c0f58ea3d84ede37e67d4e733ee307bf176fc4d4f2a110d7b03ff2798440d56bd993c2a6c9061a728fc5bbc7457a4ed85bc1bea662ca94
6
+ metadata.gz: 085d457e7c39d09c50547b218000fd8656e1753a080f76b511f603be355be1168b0822b88d876e3e6b7027ae15d8d762dc1b450377a0d839a9ba8a0e5ac66134
7
+ data.tar.gz: 13e6162f551447c0806923bfb46755e6f027a04aa144099cec2265bf1b7c6e9ca85d6ba589f2d98e31cc447bb990c5e4dc132cf83b018ef6d0c8e9b1fa67504b
@@ -223,8 +223,6 @@
223
223
  `monitor_results`
224
224
  - Response Time Graph
225
225
  `response_time_graph`
226
- - Response Time Graph
227
- `response_time_graph`
228
226
  - Save Responses to a file
229
227
  `save_responses_to_a_file`
230
228
  - Simple Data Writer
@@ -402,6 +402,10 @@ module RubyJmeter
402
402
  params[:test_type] = parse_test_type(params)
403
403
  params['0'] = params.values.first
404
404
  node = RubyJmeter::ResponseAssertion.new(params)
405
+ if params[:variable] then
406
+ params['Scope.variable'] = params[:variable]
407
+ node.doc.xpath("//stringProp[@name='Assertion.scope']").first.content = 'variable'
408
+ end
405
409
  node.doc.xpath("//stringProp[@name='Assertion.scope']").remove if
406
410
  params[:scope] == 'main' || params['scope'] == 'main'
407
411
  attach_node(node, &block)
@@ -486,8 +490,8 @@ module RubyJmeter
486
490
 
487
491
  alias_method :active_threads, :active_threads_over_time
488
492
 
489
- def perfmon_collector(name, params = {}, &block)
490
- node = RubyJmeter::Plugins::PerfmonCollector.new(name, params)
493
+ def perfmon_collector(name, params = {}, filename="perfMon.jtl", &block)
494
+ node = RubyJmeter::Plugins::PerfmonCollector.new(name, params, filename)
491
495
  attach_node(node, &block)
492
496
  end
493
497
 
@@ -524,8 +528,7 @@ module RubyJmeter
524
528
  def run(params = {})
525
529
  file(params)
526
530
  logger.warn "Test executing locally ..."
527
- properties = params.has_key?(:properties) ? params[:properties] : "#{File.dirname(__FILE__)}/helpers/jmeter.properties"
528
- properties = "-q #{properties}" if properties
531
+ properties = params.has_key?(:properties) ? build_properties(params[:properties]) : "-q #{File.dirname(__FILE__)}/helpers/jmeter.properties"
529
532
 
530
533
  if params[:remote_hosts]
531
534
  remote_hosts = params[:remote_hosts]
@@ -635,6 +638,14 @@ module RubyJmeter
635
638
  Nokogiri::XML(@root.to_s, &:noblanks)
636
639
  end
637
640
 
641
+ def build_properties(properties)
642
+ if properties.kind_of?(String)
643
+ "-q #{properties}"
644
+ elsif properties.kind_of?(Hash)
645
+ properties.map{ |k,v| "-J#{k}=#{v}" }.join(" ")
646
+ end
647
+ end
648
+
638
649
  def logger
639
650
  @log ||= Logger.new(STDOUT)
640
651
  @log.level = Logger::DEBUG
@@ -21,6 +21,7 @@ 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>
24
25
  </ResponseAssertion>)
25
26
  EOS
26
27
  update params
@@ -5,7 +5,7 @@ module RubyJmeter
5
5
  include Helper
6
6
  def initialize(name, params={})
7
7
  @doc = Nokogiri::XML(<<-EOF.strip_heredoc)
8
- <kg.apc.jmeter.samplers.DummySampler guiclass="kg.apc.jmeter.samplers.DummySamplerGui" testclass="kg.apc.jmeter.samplers.DummySampler" testname="jp@gc - Dummy Sampler" enabled="true">
8
+ <kg.apc.jmeter.samplers.DummySampler guiclass="kg.apc.jmeter.samplers.DummySamplerGui" testclass="kg.apc.jmeter.samplers.DummySampler" testname="#{name}" enabled="true">
9
9
  <boolProp name="WAITING">true</boolProp>
10
10
  <boolProp name="SUCCESFULL">true</boolProp>
11
11
  <stringProp name="RESPONSE_CODE">200</stringProp>
@@ -3,7 +3,7 @@ module RubyJmeter
3
3
  class PerfmonCollector
4
4
  attr_accessor :doc
5
5
  include Helper
6
- def initialize(name, params={})
6
+ def initialize(name, params={}, filename="perfMon.jtl")
7
7
  metricNodes = params.collect do |m|
8
8
  "
9
9
  <collectionProp name=\"\">
@@ -41,7 +41,7 @@ module RubyJmeter
41
41
  <subresults>false</subresults>
42
42
  <responseData>false</responseData>
43
43
  <samplerData>false</samplerData>
44
- <xml>false</xml>
44
+ <xml>true</xml>
45
45
  <fieldNames>false</fieldNames>
46
46
  <responseHeaders>false</responseHeaders>
47
47
  <requestHeaders>false</requestHeaders>
@@ -53,7 +53,7 @@ module RubyJmeter
53
53
  <sampleCount>true</sampleCount>
54
54
  </value>
55
55
  </objProp>
56
- <stringProp name="filename"></stringProp>
56
+ <stringProp name="filename">#{filename}</stringProp>
57
57
  <longProp name="interval_grouping">1000</longProp>
58
58
  <boolProp name="graph_aggregated">false</boolProp>
59
59
  <stringProp name="include_sample_labels"></stringProp>
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = '2.13.5'
2
+ VERSION = '2.13.6'
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -759,6 +759,26 @@ describe 'DSL' do
759
759
  fragment.search(".//stringProp[@name='Assertion.scope']").text.should == ""
760
760
  end
761
761
  end
762
+
763
+ describe 'scope variable' do
764
+ let(:doc) do
765
+ test do
766
+ visit '/' do
767
+ assert contains: 'someting', variable: 'some_jmeter_variable'
768
+ end
769
+ end.to_doc
770
+ end
771
+
772
+ let(:fragment) { doc.search("//ResponseAssertion").first }
773
+
774
+ it 'should match on scope' do
775
+ fragment.search(".//stringProp[@name='Assertion.scope']").text.should == "variable"
776
+ end
777
+
778
+ it 'should match on variable' do
779
+ fragment.search(".//stringProp[@name='Scope.variable']").text.should == "some_jmeter_variable"
780
+ end
781
+ end
762
782
  end
763
783
 
764
784
  describe 'Nested controllers' do
@@ -853,6 +873,22 @@ describe 'DSL' do
853
873
  end.run(properties: 'my-jmeter.properties')
854
874
  end
855
875
 
876
+ it 'pass an inline property' do
877
+ Open3.should_receive(:popen2e)
878
+ .with('jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl -Jjmeter.save.saveservice.output_format=xml ')
879
+
880
+ test do
881
+ end.run(properties: {"jmeter.save.saveservice.output_format" => "xml"})
882
+ end
883
+
884
+ it 'pass multiple inline properties' do
885
+ Open3.should_receive(:popen2e)
886
+ .with('jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl -Jtlon=uqbar -Jorbis=tertius ')
887
+
888
+ test do
889
+ end.run(properties: {tlon: "uqbar", orbis: "tertius"})
890
+ end
891
+
856
892
  it 'do not pass a properties file' do
857
893
  Open3.should_receive(:popen2e)
858
894
  .with("jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl -q #{deflate_properties} ")
@@ -940,4 +976,25 @@ describe 'DSL' do
940
976
  nodes[2].text.should == 'some_test_fragment'
941
977
  end
942
978
  end
979
+
980
+ describe 'dummy sampler' do
981
+ let(:doc) do
982
+ test do
983
+ threads do
984
+ dummy_sampler 'dummy sampler name', { RESPONSE_DATA: "Some response data" }
985
+ end
986
+ end.to_doc
987
+ end
988
+
989
+ let(:fragment) { doc.search("//kg.apc.jmeter.samplers.DummySampler").first }
990
+
991
+ it 'should match on name' do
992
+ fragment.attributes['testname'].value.should == 'dummy sampler name'
993
+ end
994
+
995
+ it 'should match on response data' do
996
+ fragment.search("//stringProp[@name='RESPONSE_DATA']").text.should == 'Some response data'
997
+ end
998
+
999
+ end
943
1000
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jmeter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.5
4
+ version: 2.13.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Koopmans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client