ruby-jmeter 2.13.4 → 2.13.5

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: 3dda9f4e86561144164191340739f1ec3e28905a
4
- data.tar.gz: 82074b1073ebbeedb1dd18efede806ab49cf0f03
3
+ metadata.gz: 2bc45180e9ae9b2911cbe73279e54fe7a367b33b
4
+ data.tar.gz: 9e1d2afeb4dcaf99274a2b3804717fdcfa2134ed
5
5
  SHA512:
6
- metadata.gz: a656d71dd7996db38de4d913a737c322996c47fd87c331b67c1d1d5316238e6a55c9b2ff87d373c50791ec3da945d8fa199bbce5f8e0a9087993655a457e1169
7
- data.tar.gz: 30aa94e631a5c7e23c3baa60e336af53e4c7c13f0dde6befac1a59a96cbd96985e05ccfc5e3f52c24ec16449dbd95971682d94e4726f12237f358e7692ad77bc
6
+ metadata.gz: 5c7322a18414e08695dbd0eb280af2423580c65cf801e7b5d89345f171016ad2a80f1f42a60a74a7705216cf33c755813b91ffb19930cd35cede75a26f9ee7d1
7
+ data.tar.gz: 6db79206bc45f66291c0f58ea3d84ede37e67d4e733ee307bf176fc4d4f2a110d7b03ff2798440d56bd993c2a6c9061a728fc5bbc7457a4ed85bc1bea662ca94
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'ruby-jmeter'
3
+
4
+ build_args = ->(args) do
5
+ args.collect do |arg|
6
+ {
7
+ xpath: "//collectionProp[@name='Arguments.arguments']",
8
+ value: Nokogiri::XML(<<-EOF.strip_heredoc).children
9
+ <elementProp name="" elementType="Argument">
10
+ <stringProp name="Argument.name"></stringProp>
11
+ <stringProp name="Argument.value">#{arg}</stringProp>
12
+ <stringProp name="Argument.metadata">=</stringProp>
13
+ </elementProp>
14
+ EOF
15
+ }
16
+ end
17
+ end
18
+
19
+
20
+ test do
21
+ os_process_sampler 'SystemSampler.command' => 'git',
22
+ update_at_xpath: build_args.call(['push', 'origin', 'master'])
23
+
24
+ end.run(path: '/usr/share/jmeter-2.13/bin/', gui: true)
@@ -94,6 +94,20 @@ module RubyJmeter
94
94
 
95
95
  alias_method :threads, :thread_group
96
96
 
97
+ def setup_thread_group(*args, &block)
98
+ params = args.shift || {}
99
+ params = { count: params }.merge(args.shift || {}) if params.class == Fixnum
100
+ params[:num_threads] = params[:count] || 1
101
+ params[:ramp_time] = params[:rampup] || (params[:num_threads]/2.0).ceil
102
+ params[:start_time] = params[:start_time] || Time.now.to_i * 1000
103
+ params[:end_time] = params[:end_time] || Time.now.to_i * 1000
104
+ params[:duration] ||= 60
105
+ params[:continue_forever] ||= false
106
+ params[:loops] = -1 if params[:continue_forever]
107
+ node = RubyJmeter::SetupThreadGroup.new(params)
108
+ attach_node(node, &block)
109
+ end
110
+
97
111
  ##
98
112
  # HTTP Samplers
99
113
 
@@ -0,0 +1,36 @@
1
+ module RubyJmeter
2
+ class DSL
3
+ def setup_thread_group(params={}, &block)
4
+ node = RubyJmeter::SetupThreadGroup.new(params)
5
+ attach_node(node, &block)
6
+ end
7
+ end
8
+
9
+ class SetupThreadGroup
10
+ attr_accessor :doc
11
+ include Helper
12
+
13
+ def initialize(params={})
14
+ testname = params.kind_of?(Array) ? 'SetupThreadGroup' : (params[:name] || 'SetupThreadGroup')
15
+ @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
16
+ <SetupThreadGroup guiclass="SetupThreadGroupGui" testclass="SetupThreadGroup" testname="#{testname}" enabled="true">
17
+ <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
18
+ <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="#{testname}" enabled="true">
19
+ <boolProp name="LoopController.continue_forever">false</boolProp>
20
+ <stringProp name="LoopController.loops">-1</stringProp>
21
+ </elementProp>
22
+ <stringProp name="ThreadGroup.num_threads">1</stringProp>
23
+ <stringProp name="ThreadGroup.ramp_time">1</stringProp>
24
+ <longProp name="ThreadGroup.start_time">1442954623000</longProp>
25
+ <longProp name="ThreadGroup.end_time">1442954623000</longProp>
26
+ <boolProp name="ThreadGroup.scheduler">true</boolProp>
27
+ <stringProp name="ThreadGroup.duration"></stringProp>
28
+ <stringProp name="ThreadGroup.delay"></stringProp>
29
+ </SetupThreadGroup>)
30
+ EOS
31
+ update params
32
+ update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
33
+ end
34
+ end
35
+
36
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = '2.13.4'
2
+ VERSION = '2.13.5'
3
3
  end
@@ -186,6 +186,36 @@ describe 'DSL' do
186
186
  end
187
187
  end
188
188
 
189
+ describe 'setup thread groups' do
190
+ let(:doc) do
191
+ test do
192
+ setup_thread_group count: 101, continue_forever: true, duration: 69
193
+ end.to_doc
194
+ end
195
+
196
+ let(:fragment) { doc.search("//SetupThreadGroup").first }
197
+
198
+ it 'should match on num_threads' do
199
+ fragment.search(".//stringProp[@name='ThreadGroup.num_threads']").text.should == '101'
200
+ end
201
+
202
+ it 'should match on scheduler' do
203
+ fragment.search(".//boolProp[@name='ThreadGroup.scheduler']").text.should == 'true'
204
+ end
205
+
206
+ it 'should match on continue_forever' do
207
+ fragment.search(".//boolProp[@name='LoopController.continue_forever']").text.should == 'true'
208
+ end
209
+
210
+ it 'should match on loops' do
211
+ fragment.search(".//stringProp[@name='LoopController.loops']").text.should == '-1'
212
+ end
213
+
214
+ it 'should match on duration' do
215
+ fragment.search(".//stringProp[@name='ThreadGroup.duration']").text.should == '69'
216
+ end
217
+ end
218
+
189
219
  describe 'thread groups old syntax' do
190
220
  let(:doc) do
191
221
  test do
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.4
4
+ version: 2.13.5
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-08-08 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -84,6 +84,7 @@ files:
84
84
  - examples/basic_loadosophia.rb
85
85
  - examples/basic_loops.rb
86
86
  - examples/basic_meta_fu.rb
87
+ - examples/basic_os_process_sampler.rb
87
88
  - examples/basic_perfmon.rb
88
89
  - examples/basic_post.rb
89
90
  - examples/basic_preprocessor_user_parameters.rb
@@ -198,6 +199,7 @@ files:
198
199
  - lib/ruby-jmeter/dsl/result_status_action_handler.rb
199
200
  - lib/ruby-jmeter/dsl/runtime_controller.rb
200
201
  - lib/ruby-jmeter/dsl/save_responses_to_a_file.rb
202
+ - lib/ruby-jmeter/dsl/setup_thread_group.rb
201
203
  - lib/ruby-jmeter/dsl/simple_config_element.rb
202
204
  - lib/ruby-jmeter/dsl/simple_controller.rb
203
205
  - lib/ruby-jmeter/dsl/simple_data_writer.rb