ruby-jmeter 2.11.0 → 2.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -310,6 +310,17 @@ module RubyJmeter
310
310
 
311
311
  alias_method :think_time, :random_timer
312
312
 
313
+ def constant_throughput_timer(params, &block)
314
+ params[:value] ||= params[:throughput] || 0.0
315
+
316
+ node = RubyJmeter::ConstantThroughputTimer.new(params)
317
+ node.doc.xpath(".//value").first.content = params[:value].to_f
318
+
319
+ attach_node(node, &block)
320
+ end
321
+
322
+ alias_method :ConstantThroughputTimer, :constant_throughput_timer
323
+
313
324
  def response_assertion(params={}, &block)
314
325
  params[:test_type] = parse_test_type(params)
315
326
  params["0"] = params.values.first
@@ -399,8 +410,9 @@ module RubyJmeter
399
410
  def run(params={})
400
411
  file(params)
401
412
  logger.warn "Test executing locally ..."
402
- properties = params[:properties] || "#{File.dirname(__FILE__)}/helpers/jmeter.properties"
403
- 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' } -q #{properties}"
413
+ properties = params.has_key?(:properties) ? params[:properties] : "#{File.dirname(__FILE__)}/helpers/jmeter.properties"
414
+ properties = "-q #{properties}" if properties
415
+ 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}"
404
416
  logger.debug cmd if params[:debug]
405
417
  Open3.popen2e("#{cmd}") do |stdin, stdout_err, wait_thr|
406
418
  while line = stdout_err.gets
@@ -72,7 +72,7 @@ module RubyJmeter
72
72
  :value => Nokogiri::XML(<<-EOF.strip_heredoc).children
73
73
  <elementProp name="" elementType="HTTPArgument">
74
74
  <boolProp name="HTTPArgument.always_encode">false</boolProp>
75
- <stringProp name="Argument.value">#{params[:raw_body]}</stringProp>
75
+ <stringProp name="Argument.value">#{params[:raw_body].encode(:xml => :text)}</stringProp>
76
76
  <stringProp name="Argument.metadata">=</stringProp>
77
77
  </elementProp>
78
78
  EOF
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = "2.11.0"
2
+ VERSION = "2.11.1"
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -681,4 +681,72 @@ describe "DSL" do
681
681
  end
682
682
 
683
683
  end
684
+
685
+ describe 'raw body containing xml entities' do
686
+ let(:doc) do
687
+ test do
688
+ threads do
689
+ post url: 'http://example.com', raw_body: 'username=my_name&password=my_password&email="my name <test@example.com>"'
690
+ end
691
+ end.to_doc
692
+ end
693
+
694
+ let(:fragment) { doc.search("//HTTPSamplerProxy").first }
695
+
696
+ it 'escape raw_body' do
697
+ fragment.search(".//stringProp[@name='Argument.value']").text.should == 'username=my_name&password=my_password&email="my name <test@example.com>"'
698
+ end
699
+ end
700
+
701
+ describe 'constant_throughput_timer' do
702
+ let(:doc) do
703
+ test do
704
+ threads do
705
+ constant_throughput_timer value: 60.0
706
+ constant_throughput_timer throughput: 70.0
707
+ end
708
+ end.to_doc
709
+ end
710
+
711
+ let(:fragment) { doc.search("//ConstantThroughputTimer").first }
712
+
713
+ it 'should match on throughput using value' do
714
+ fragment.search("//doubleProp/value").first.text.should == '60.0'
715
+ end
716
+
717
+ it 'should match on throughput using throughput' do
718
+ fragment.search("//doubleProp/value").last.text.should == '70.0'
719
+ end
720
+ end
721
+
722
+ describe 'run' do
723
+ let(:deflate_properties) {
724
+ File.expand_path('../../lib/ruby-jmeter/helpers/jmeter.properties', __FILE__)
725
+ }
726
+
727
+ it 'pass a properties file' do
728
+ Open3.should_receive(:popen2e)
729
+ .with('jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl -q my-jmeter.properties')
730
+
731
+ test do
732
+ end.run(properties: 'my-jmeter.properties')
733
+ end
734
+
735
+ it 'do not pass a properties file' do
736
+ Open3.should_receive(:popen2e)
737
+ .with("jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl -q #{deflate_properties}")
738
+
739
+ test do
740
+ end.run
741
+ end
742
+
743
+ it 'pass a nil properties file' do
744
+ Open3.should_receive(:popen2e)
745
+ .with('jmeter -n -t jmeter.jmx -j jmeter.log -l jmeter.jtl ')
746
+
747
+ test do
748
+ end.run(properties: nil)
749
+ end
750
+ end
751
+
684
752
  end
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.11.0
4
+ version: 2.11.1
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: 2014-01-14 00:00:00.000000000 Z
12
+ date: 2014-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client