ruby-jmeter 2.11.10 → 2.11.11

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: 4773c5365592998c6d1cc60058034d36fbcf6a10
4
- data.tar.gz: 1720ec95ab23cb8f6d51bef69ea0985af00df34d
3
+ metadata.gz: eca901af7971565233871283172ae07dc5cd15bf
4
+ data.tar.gz: 13db5eeaf05cae1a9a0ec13daf508ed1422171f7
5
5
  SHA512:
6
- metadata.gz: b33d8bdff32b78d969fb16e5525d2177f1b2af775d6570ac71cc2d8594ff0235a710415076fc929dc331eb3a866f0f1670ca7b02026f5c06ec905f3c6acd61cd
7
- data.tar.gz: d00d654d034c7de1d4f97147b8d1d274471e35912fb8d62d6d2c85c090fd4130c8b15a577e08d138930dbf9ee7f11af9a32af8cb0226ff7bc3eae8d9bca795c6
6
+ metadata.gz: 74c809f63d71cb7273ce15cdf20d5adb1ac8c0e0a1e466b1e99f99ebf3f8e399a851b219cc2f50b59ca69560f3d2c443f75c16d3ff2ec250b8f9f9368e679478
7
+ data.tar.gz: 06e5aa4a6e85a3842df98d22e17647e628c0c9a37effdf0c855875c07bc5da036db520d452ae44e3949cc32de4fa7803526b00725d8c9919c4b3a693820f97d3
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'ruby-jmeter'
3
+
4
+ test do
5
+
6
+ test_fragment name: 'anonymous_user', enabled: false do
7
+ get name: 'Home Page', url: 'http://google.com'
8
+ end
9
+
10
+ threads count: 1 do
11
+ module_controller test_fragment: 'WorkBench/TestPlan/anonymous_user'
12
+ end
13
+
14
+ end.run(path: '/usr/share/jmeter-2.11/bin/', gui: true)
@@ -37,6 +37,8 @@
37
37
  `tcp_sampler_config`
38
38
  - User Defined Variables
39
39
  `user_defined_variables`
40
+ - Test Fragment
41
+ `test_fragment`
40
42
  - Thread Group
41
43
  `thread_group`
42
44
  - ForEach Controller
@@ -262,8 +262,14 @@ module RubyJmeter
262
262
  def module_controller(params, &block)
263
263
  node = RubyJmeter::ModuleController.new(params)
264
264
 
265
- node_path = params.kind_of?(Array) ? [] : (params[:node_path] || [])
266
- node_path.each_with_index do |node_name, index|
265
+ if params[:test_fragment]
266
+ params[:test_fragment].kind_of?(String) &&
267
+ params[:test_fragment].split('/')
268
+ elsif params[:node_path]
269
+ params[:node_path]
270
+ else
271
+ []
272
+ end.each_with_index do |node_name, index|
267
273
  node.doc.at_xpath('//collectionProp') <<
268
274
  Nokogiri::XML(<<-EOS.strip_heredoc).children
269
275
  <stringProp name="node_#{index}">#{node_name}</stringProp>
@@ -0,0 +1,23 @@
1
+ module RubyJmeter
2
+ class DSL
3
+ def test_fragment(params={}, &block)
4
+ node = RubyJmeter::TestFragment.new(params)
5
+ attach_node(node, &block)
6
+ end
7
+ end
8
+
9
+ class TestFragment
10
+ attr_accessor :doc
11
+ include Helper
12
+
13
+ def initialize(params={})
14
+ testname = params.kind_of?(Array) ? 'TestFragment' : (params[:name] || 'TestFragment')
15
+ @doc = Nokogiri::XML(<<-EOS.strip_heredoc)
16
+ <TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController" testname="#{testname}" enabled="false"/>)
17
+ EOS
18
+ update params
19
+ update_at_xpath params if params.is_a?(Hash) && params[:update_at_xpath]
20
+ end
21
+ end
22
+
23
+ end
@@ -17,6 +17,7 @@ module RubyJmeter
17
17
  module Helper
18
18
  def update(params)
19
19
  params.delete(:name)
20
+ enabled_disabled(params)
20
21
  if params.class == Array
21
22
  update_collection params
22
23
  else
@@ -32,6 +33,11 @@ module RubyJmeter
32
33
  end
33
34
  end
34
35
 
36
+ def enabled_disabled(params)
37
+ return unless params.is_a?(Hash)
38
+ @doc.children.first.attributes['enabled'].value = params[:enabled].to_s.empty? ? 'true' : 'false'
39
+ end
40
+
35
41
  def update_at_xpath(params)
36
42
  params[:update_at_xpath].each do |fragment|
37
43
  @doc.at_xpath(fragment[:xpath]) << fragment[:value]
@@ -241,6 +241,8 @@
241
241
  <stringProp name="TestPlan.comments"> </stringProp>
242
242
  </Arguments>
243
243
  <hashTree/>
244
+ <TestFragmentController guiclass="TestFragmentControllerGui" testclass="TestFragmentController" testname="Test Fragment" enabled="true"/>
245
+ <hashTree/>
244
246
  <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
245
247
  <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
246
248
  <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
@@ -1,3 +1,3 @@
1
1
  module RubyJmeter
2
- VERSION = "2.11.10"
2
+ VERSION = "2.11.11"
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -84,6 +84,21 @@ describe "DSL" do
84
84
  end
85
85
 
86
86
 
87
+ describe 'disabled elements' do
88
+ let(:doc) do
89
+ test do
90
+ header name: 'Accept', value: '*', enabled: false
91
+ end.to_doc
92
+ end
93
+
94
+ let(:fragment) { doc.search("//HeaderManager") }
95
+
96
+ it 'should be disabled' do
97
+ fragment.first.attributes['enabled'].value.should == 'false'
98
+ end
99
+ end
100
+
101
+
87
102
  describe 'header manager' do
88
103
  let(:doc) do
89
104
  test do
@@ -121,6 +136,7 @@ describe "DSL" do
121
136
  end
122
137
  end
123
138
 
139
+
124
140
  describe 'the clear_each_iteration option should be respected' do
125
141
  let(:doc) do
126
142
  test do
@@ -138,6 +154,7 @@ describe "DSL" do
138
154
  end
139
155
  end
140
156
 
157
+
141
158
  describe 'test plan' do
142
159
  it 'should allow to take params' do
143
160
  test_plan = test({"TestPlan.serialize_threadgroups" => "false"}) {}
@@ -301,6 +318,7 @@ describe "DSL" do
301
318
  end
302
319
  end
303
320
 
321
+
304
322
  describe 'visit raw_path' do
305
323
  let(:doc) do
306
324
  test do
@@ -606,6 +624,7 @@ describe "DSL" do
606
624
  end
607
625
  end
608
626
 
627
+
609
628
  describe 'regex extract' do
610
629
  let(:doc) do
611
630
  test do
@@ -754,6 +773,7 @@ describe "DSL" do
754
773
 
755
774
  end
756
775
 
776
+
757
777
  describe 'raw body containing xml entities' do
758
778
  let(:doc) do
759
779
  test do
@@ -770,6 +790,7 @@ describe "DSL" do
770
790
  end
771
791
  end
772
792
 
793
+
773
794
  describe 'constant_throughput_timer' do
774
795
  let(:doc) do
775
796
  test do
@@ -791,6 +812,7 @@ describe "DSL" do
791
812
  end
792
813
  end
793
814
 
815
+
794
816
  describe 'run' do
795
817
  let(:deflate_properties) {
796
818
  File.expand_path('../../lib/ruby-jmeter/helpers/jmeter.properties', __FILE__)
@@ -838,6 +860,7 @@ describe "DSL" do
838
860
 
839
861
  end
840
862
 
863
+
841
864
  describe 'module controllers' do
842
865
  let(:doc) do
843
866
  test name: 'tests' do
@@ -859,7 +882,6 @@ describe "DSL" do
859
882
  let(:test_module) { doc.search("//ModuleController").first }
860
883
  let(:nodes) { test_module.search(".//stringProp") }
861
884
 
862
-
863
885
  it 'should have a node path' do
864
886
  nodes.length.should == 4
865
887
  nodes[0].text.should == 'WorkBench'
@@ -869,4 +891,29 @@ describe "DSL" do
869
891
  end
870
892
  end
871
893
 
894
+
895
+ describe 'module controllers with test fragment' do
896
+ let(:doc) do
897
+ test do
898
+ test_fragment name: 'some_test_fragment', enabled: 'false' do
899
+ get name: 'Home Page', url: 'http://google.com'
900
+ end
901
+
902
+ threads count: 1 do
903
+ module_controller test_fragment: 'WorkBench/TestPlan/some_test_fragment'
904
+ end
905
+ end.to_doc
906
+ end
907
+
908
+ let(:simple_controller) { doc.search("//GenericController").first }
909
+ let(:test_module) { doc.search("//ModuleController").first }
910
+ let(:nodes) { test_module.search(".//stringProp") }
911
+
912
+ it 'should have a node path specified by test fragment' do
913
+ nodes.length.should == 3
914
+ nodes[0].text.should == 'WorkBench'
915
+ nodes[1].text.should == 'TestPlan'
916
+ nodes[2].text.should == 'some_test_fragment'
917
+ end
918
+ end
872
919
  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.11.10
4
+ version: 2.11.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Koopmans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -80,6 +80,7 @@ files:
80
80
  - examples/basic_query_params.rb
81
81
  - examples/basic_run.rb
82
82
  - examples/basic_simple_data_writer.rb
83
+ - examples/basic_test_fragment.rb
83
84
  - examples/basic_testdata.rb
84
85
  - examples/basic_think_time.rb
85
86
  - examples/basic_throughput_controller.rb
@@ -194,6 +195,7 @@ files:
194
195
  - lib/ruby-jmeter/dsl/tcp_sampler.rb
195
196
  - lib/ruby-jmeter/dsl/tcp_sampler_config.rb
196
197
  - lib/ruby-jmeter/dsl/test_action.rb
198
+ - lib/ruby-jmeter/dsl/test_fragment.rb
197
199
  - lib/ruby-jmeter/dsl/test_plan.rb
198
200
  - lib/ruby-jmeter/dsl/thread_group.rb
199
201
  - lib/ruby-jmeter/dsl/throughput_controller.rb