ruby-jmeter 3.0.7 → 3.0.8

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: 4bd3659e8b6c63f914431419f9eeacfa7e7df8d8
4
- data.tar.gz: 1706ffed23bd94c9a6bfdb39c5895a8125fb385f
3
+ metadata.gz: 5f7e301f7230400fc1209e14de0cab9a9c598870
4
+ data.tar.gz: 2c2dd6207bc2ef9109b94dbaef2bc7dbedcaa10c
5
5
  SHA512:
6
- metadata.gz: d4cdbda09d55d140d39a938f02abec9565ed94a004017ff34756009de8cda1b681f86028d5b1e958f13d934b3533e5daa2837aa183e3bea4e7cdb3925caa20c7
7
- data.tar.gz: 03a415a86d46d38dc238c6410b59982159d66b46ba0631376ceb73967f0d9213599048e16777c33a2a9d3c8f6438bd172d038c9905841d84f47c8c819c4ed863
6
+ metadata.gz: 979db78c9a2b2dde3d6286f31f6af42b8bad9a29b219d9ec50007f25ebcb580fb653add14979edb2a13cf9f37649ecb4970c8c8f74a75fc2446501fe51e11f3a
7
+ data.tar.gz: 117c2a81ebb929b0ebb72e236d40091e8fdebf26090c6a281fae341a10c4341aac7d9cf7109d4b8ce0fc336d8d1eb5c9cb7906e1931572e76425441010c1a0bb
data/README.md CHANGED
@@ -86,7 +86,7 @@ test do
86
86
  end.run
87
87
  ```
88
88
 
89
- This will launch JMeter in headless (non-GUI mode) and execute the test plan. This is useful for shaking out the script before you push it to the Grid. There are a few parameters that you can set such as the `path` to the JMeter binary, the `file` path/name for the JMX file, the `log` path/name to output JMeter logs and the `jtl` path/name for JMeter results like this.
89
+ This will launch JMeter in headless (non-GUI mode) and execute the test plan. This is useful for shaking out the script before you push it to the Grid. There are a few parameters that you can set such as the `path` to the JMeter binary, the `file` path/name for the JMX file, the `log` path/name to output JMeter logs, the `jtl` path/name for JMeter results like this, and the `properties` path/name for the additional JMeter property file.
90
90
 
91
91
  ```ruby
92
92
  test do
@@ -97,7 +97,8 @@ end.run(
97
97
  path: '/usr/share/jmeter/bin/',
98
98
  file: 'jmeter.jmx',
99
99
  log: 'jmeter.log',
100
- jtl: 'results.jtl')
100
+ jtl: 'results.jtl',
101
+ properties: 'jmeter.properties')
101
102
  ```
102
103
 
103
104
  ### Running a JMeter Test Plan on Flood IO
@@ -38,7 +38,7 @@ module RubyJmeter
38
38
  file(params)
39
39
  logger.warn 'Test executing locally ...'
40
40
 
41
- 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' }"
41
+ cmd = "#{params[:path] ? File.join(params[:path], 'jmeter') : 'jmeter'} #{"-n" unless params[:gui] } -t #{params[:file]} -j #{params[:log] ? params[:log] : 'jmeter.log' } -l #{params[:jtl] ? params[:jtl] : 'jmeter.jtl' } #{build_properties(params[:properties]) if params[:properties]}"
42
42
  logger.debug cmd if params[:debug]
43
43
  Open3.popen2e("#{cmd}") do |stdin, stdout_err, wait_thr|
44
44
  while line = stdout_err.gets
@@ -81,6 +81,14 @@ module RubyJmeter
81
81
  Nokogiri::XML(@root.to_s, &:noblanks)
82
82
  end
83
83
 
84
+ def build_properties(properties)
85
+ if properties.kind_of?(String)
86
+ "-q #{properties}"
87
+ elsif properties.kind_of?(Hash)
88
+ properties.map{ |k,v| "-J#{k}=#{v}" }.join(" ")
89
+ end
90
+ end
91
+
84
92
  def logger
85
93
  @log ||= Logger.new(STDOUT)
86
94
  @log.level = Logger::DEBUG
@@ -15,11 +15,7 @@ module RubyJmeter
15
15
  @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
16
16
  <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="#{testname}" enabled="true">
17
17
  <intProp name="calcMode">0</intProp>
18
- <doubleProp>
19
- <name>throughput</name>
20
- <value>0.0</value>
21
- <savedValue>0.0</savedValue>
22
- </doubleProp>
18
+ <stringProp name="throughput">0.0</stringProp>
23
19
  </ConstantThroughputTimer>)
24
20
  EOS
25
21
  update params
@@ -43,7 +43,7 @@ module RubyJmeter
43
43
  logger.fatal "Sorry there was an error: #{JSON.parse(response)["error"]}"
44
44
  end
45
45
  rescue => e
46
- logger.fatal "Sorry there was an error: #{JSON.parse(e.response)["error"]}"
46
+ logger.fatal "Sorry there was an error: #{e}"
47
47
  end
48
48
  end
49
49
  end
@@ -4,8 +4,7 @@ module RubyJmeter
4
4
  params[:value] ||= params[:throughput] || 0.0
5
5
 
6
6
  node = RubyJmeter::ConstantThroughputTimer.new(params)
7
- node.doc.xpath('.//value').first.content = params[:value].to_f
8
-
7
+ node.doc.xpath('//stringProp[@name="throughput"]').first.content = params[:value]
9
8
  attach_node(node, &block)
10
9
  end
11
10
  end
@@ -340,11 +340,7 @@
340
340
  <hashTree/>
341
341
  <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
342
342
  <intProp name="calcMode">0</intProp>
343
- <doubleProp>
344
- <name>throughput</name>
345
- <value>0.0</value>
346
- <savedValue>0.0</savedValue>
347
- </doubleProp>
343
+ <stringProp name="throughput">0.0</stringProp>
348
344
  </ConstantThroughputTimer>
349
345
  <hashTree/>
350
346
  <ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = '3.0.7'
2
+ VERSION = '3.0.8'
3
3
  end
@@ -10,13 +10,11 @@ describe 'constant_throughput_timer' do
10
10
  end.to_doc
11
11
  end
12
12
 
13
- let(:fragment) { doc.search("//ConstantThroughputTimer").first }
14
-
15
13
  it 'should match on throughput using value' do
16
- expect(fragment.search("//doubleProp/value").first.text).to eq '60.0'
14
+ expect(doc.search('//ConstantThroughputTimer[1]/stringProp[@name="throughput"]').first.content).to eq '60.0'
17
15
  end
18
-
16
+
19
17
  it 'should match on throughput using throughput' do
20
- expect(fragment.search("//doubleProp/value").last.text).to eq '70.0'
18
+ expect(doc.search('//ConstantThroughputTimer[2]/stringProp[@name="throughput"]').first.content).to eq '70.0'
21
19
  end
22
20
  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: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Koopmans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-24 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client