gridinit-jmeter 1.1.0.pre → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,335 +1,3 @@
1
- # Gridinit::Jmeter
1
+ # gridinit-jmeter
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/altentee/gridinit-jmeter.png)](https://codeclimate.com/github/altentee/gridinit-jmeter)
4
-
5
- Tired of using the JMeter GUI or looking at hairy XML files?
6
-
7
- This gem lets you write test plans for JMeter in your favourite text editor, and optionally run them on [Gridinit.com](http://gridinit.com). Here's some background on [why we think](http://www.slideshare.net/90kts/gridinit-jmeter) a DSL is necessary. Don't have Ruby? No problems, you can try out this DSL online in our [sandbox](http://sandbox.gridinit.com)
8
-
9
- ## Installation
10
-
11
- Install it yourself as:
12
-
13
- $ gem install gridinit-jmeter
14
-
15
- ## Basic Usage
16
-
17
- *Gridinit::Jmeter* exposes easy-to-use domain specific language for fluent communication with [JMeter](http://jmeter.apache.org/). As the name of the gem suggests, it also includes API integration with [Gridinit](http://gridinit.com), a cloud based load testing service.
18
-
19
- To use the DSL, first let's require the gem:
20
-
21
- ```ruby
22
- require 'rubygems'
23
- require 'gridinit-jmeter'
24
- ```
25
-
26
- ### Basic Example
27
- Let's create a `test` and save the related `jmx` testplan to file, so we can edit/view it in JMeter.
28
-
29
- ```ruby
30
- test do
31
- threads count: 10 do
32
- visit name: 'Google Search', url: 'http://google.com'
33
- end
34
- end.jmx
35
- ```
36
-
37
- So in this example, we just created a test plan, with 10 threads, each of which visited the search page at Google.
38
-
39
- ### Generating a JMeter Test Plan (JMX)
40
- Note also how we called the `jmx` method of the test. Calling this method will write the contents of the JMeter test plan to file like this.
41
-
42
- ```
43
- $ ruby testplan.rb
44
- [2013-04-23T10:29:03.275743 #42060] INFO -- : Test plan saved to: jmeter.jmx
45
- ```
46
-
47
- ```xml
48
- <?xml version="1.0" encoding="UTF-8"?>
49
- <jmeterTestPlan version="1.2" properties="2.1">
50
- <hashTree>
51
- <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
52
- ...
53
- </TestPlan>
54
- </hashTree>
55
- </jmeterTestPlan>
56
- JMX saved to: jmeter.jmx
57
- ```
58
-
59
- The file that is created can then be executed in the JMeter GUI. If you want to create the file with a different filename and/or path, just add the `file` parameter to the `jmx` method call like this.
60
-
61
- ```ruby
62
- test do
63
- threads count: 10 do
64
- visit name: 'Google Search', url: 'http://google.com'
65
- end
66
- end.jmx(file: "/tmp/my_testplan.jmx")
67
- ```
68
-
69
- Windows users should specify a path like this.
70
-
71
- ```ruby
72
- .jmx(file: "C:\\TEMP\\MyTestplan.jmx")
73
- ```
74
-
75
- ### Running a JMeter Test Plan locally
76
- You can execute the JMeter test plan by calling the `run` method of the test like this.
77
-
78
- ```ruby
79
- test do
80
- threads count: 10 do
81
- visit name: 'Google Search', url: 'http://google.com'
82
- end
83
- end.run
84
- ```
85
-
86
- 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.
87
-
88
- ```ruby
89
- test do
90
- threads count: 10 do
91
- visit name: 'Google Search', url: 'http://google.com'
92
- end
93
- end.run(
94
- path: '/usr/share/jmeter/bin/',
95
- file: 'jmeter.jmx',
96
- log: 'jmeter.log',
97
- jtl: 'results.jtl')
98
- ```
99
-
100
- ### Running a JMeter Test Plan on Gridinit.com
101
-
102
- As the gem name implies, you can also execute JMeter test plans on Gridinit.com using our API. To do so, you require an account and API token. If you don't know your token, sign in to the Grid and [generate a new token](http://gridinit.com/api).
103
-
104
- To execute the test on the Grid, call the `grid` method on the test and pass it the API token like this.
105
-
106
- ```ruby
107
- test do
108
- threads count: 10 do
109
- visit name: 'Google Search', url: 'http://google.com'
110
- end
111
- end.grid('OxtZ-4v-v0koSz5Y0enEQQ')
112
- ```
113
-
114
- This will then provide you with a link to the live test results on the Grid like this.
115
-
116
- ```
117
- Results at: http://prod.gridinit.com/shared?testguid=73608030311611e2962f123141011033&run_id=339&tags=jmeter&domain=altentee.com&cluster=54.251.48.129&status=running&view=
118
- ```
119
-
120
- ## Advanced Usage
121
-
122
- ### Blocks
123
-
124
- Each of the methods take an optional block delimited by `do` and `end` or braces `{}`
125
-
126
- Blocks let you nest methods within methods, so you can scope the execution of methods as you would in a normal JMeter test plan. For example.
127
-
128
- ```ruby
129
- test do
130
- threads count: 100 do
131
- visit name: 'Home', url: 'http://altentee.com' do
132
- extract regex: "content='(.+?)' name='csrf-token'", name: 'csrf-token'
133
- end
134
- end
135
- end
136
- ```
137
-
138
- This would create a new test plan, with a 100 user thread group, each user visiting the "Home" page and extracting the CSRF token from the response of each visit.
139
-
140
- All methods are nestable, but you should only have one test method, and typically only one threads method. For example, it wouldn't make sense to have a test plan within a test plan, or a thread group within a thread group. You can have multiple thread groups per test plan though. This implies *some* knowlege of how JMeter works.
141
-
142
- All methods take a parameter hash to configure related options.
143
-
144
- ### Threads
145
-
146
- You can use the `threads` method to define a group of users:
147
-
148
- ```ruby
149
- threads count: 100
150
- threads count: 100, continue_forever: true
151
- threads count: 100, loops: 10
152
- threads count: 100, ramup: 30, duration: 60
153
- threads count: 100, scheduler: true,
154
- start_time: Time.now.to_i * 1000,
155
- end_time: (Time.now.to_i * 1000) + (3600 * 1000)
156
- ```
157
-
158
- ### Cookies
159
-
160
- You can use the `cookies` method to define a Cookie Manager:
161
-
162
- ```ruby
163
- test do
164
- cookies
165
- end
166
- ```
167
-
168
- This methods takes an optional parameters hash. This is based on the [HTTP Cookie Manager](http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cookie_Manager).
169
-
170
- ```ruby
171
- test do
172
- cookies clear_each_iteration: false
173
- end
174
-
175
- test do
176
- cookies policy: 'rfc2109', clear_each_iteration: true
177
- end
178
- ```
179
-
180
- ### Cache
181
-
182
- You can use the `cache` method to define a Cache Manager:
183
-
184
- ```ruby
185
- test do
186
- cache
187
- end
188
- ```
189
-
190
- This methods takes an optional parameters hash. This is based on the [HTTP Cache Manager](http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Cache_Manager).
191
-
192
- ```ruby
193
- test do
194
- cache clear_each_iteration: false
195
- end
196
-
197
- test do
198
- cache use_expires: true, clear_each_iteration: true
199
- end
200
- ```
201
-
202
- ### Authorization
203
-
204
- You can use the `auth` method to define an Authorization Manager:
205
-
206
- ```ruby
207
- test do
208
- auth
209
- end
210
- ```
211
-
212
- This methods takes an optional parameters hash. This is based on the [HTTP Authorization Manager](http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Authorization_Manager).
213
-
214
- ```ruby
215
- test do
216
- auth url: '/', username: 'tim', password: 'secret', domain: 'altentee.com'
217
- end
218
- ```
219
-
220
- ### Navigating
221
-
222
- You can use the `visit` method to navigate to pages:
223
-
224
- ```ruby
225
- visit name: 'Google Search', url: 'http://google.com'
226
- visit name: 'Google Search', url: 'http://google.com'
227
- visit name: 'Google Search', url: 'http://google.com',
228
- method: 'POST',
229
- 'DO_MULTIPART_POST': 'true'
230
- visit name: 'Google Search', url: 'http://google.com',
231
- use_keepalive: 'false'
232
- visit name: 'Google Search', url: 'http://google.com',
233
- connect_timeout: '1000',
234
- response_timeout: '60000'
235
- visit name: 'View Login', url: '/login',
236
- protocol: "https",
237
- port: 443
238
- ```
239
-
240
- ### Submitting a Form
241
-
242
- You can use the `submit` method to POST a HTTP form:
243
-
244
- ```ruby
245
- submit name: 'Submit Form', url: 'http://altentee.com/',
246
- fill_in: {
247
- username: 'tim',
248
- password: 'password',
249
- 'csrf-token' => '${csrf-token}'
250
- }
251
- ```
252
-
253
- This method makes a single request. The fill_in parameter lets you specify key/value pairs for form field parameters. You can also use the built in JMeter `${expression}` language to access run time variables extracted from previous responses.
254
-
255
- ### Think Time
256
-
257
- You can use the `think_time` method to insert pauses into the simulation. This method is aliased as `random_timer`.
258
-
259
- ```ruby
260
- think_time 3000
261
- ```
262
-
263
- This method takes 2 parameters: the constant delay, and an optional variable delay. Both are specified in milliseconds. This is based on the [Gaussian Random Timer](http://jmeter.apache.org/usermanual/component_reference.html#Gaussian_Random_Timer). This timer pauses each thread request for a random amount of time, with most of the time intervals ocurring near a particular value. The total delay is the sum of the Gaussian distributed value (with mean 0.0 and standard deviation 1.0) times the deviation value you specify, and the offset value.
264
-
265
- ```ruby
266
- # constant delay of 3 seconds
267
- think_time 3000
268
- # constant delay of 1 seconds with variance up to 6 seconds.
269
- random_timer 1000,5000
270
- ```
271
-
272
- ### Response Extractor
273
-
274
- You can use the `extract` method to extract values from a server response using a regular expression. This is aliased as the `web_reg_save_param` method. This method is typically used inside a `visit` or `submit` block.
275
-
276
- ```ruby
277
- extract regex: "content='(.+?)' name='csrf-token'", name: 'csrf-token'
278
-
279
- visit name: 'Google', url: "http://google.com/" do
280
- extract regex: 'aria-label="(.+?)"', name: 'button_text'
281
- extract xpath: '//button', name: 'button'
282
- end
283
- ```
284
-
285
- This is based on the [Regular Expression Extractor](http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor) and [XPath Extractor](http://jmeter.apache.org/usermanual/component_reference.html#XPath_Extractor)
286
-
287
- ```ruby
288
- visit name: "Altentee", url: "http://altentee.com" do
289
- extract regex: "content='(.+?)' name='csrf-token'", name: 'csrf-token'
290
- extract regex: 'value="(.+?)" name="JESSIONSID"', name: 'JSESSIONID'
291
- web_reg_save_param regex: 'value="(.+?)" name="VIEWSTATE"', name: 'VIEWSTATE'
292
- extract name: 'username', regex: 'value="(.+?)", name="username"',
293
- default: 'Tim Koopmans',
294
- match_number: 1
295
- extract name: 'shopping_item', regex: 'id="(.+?)" name="book"',
296
- match_number: 0 # random
297
- end
298
- ```
299
-
300
- ### Response Assertion
301
-
302
- You can use the `assert` method to extract values from a server response using a regular expression. This is aliased as the `web_reg_find` method. This method is typically used inside a `visit` or `submit` block.
303
-
304
- ```ruby
305
- visit "Altentee", "http://altentee.com" do
306
- assert contains: "We test, tune and secure your site"
307
- end
308
- ```
309
-
310
-
311
- This method takes 3 parameters: the matching rule, the test string, and an optional parameters hash. This is based on the [Response Assertion](http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion).
312
-
313
- ```ruby
314
- visit "Altentee", "http://altentee.com" do
315
- assert "contains": "We test, tune and secure your site"
316
- assert "not-contains": "We price gouge on cloud services"
317
- assert "matches": "genius"
318
- assert "not-matches": "fakers"
319
- assert "contains": "magic"
320
- assert "not-contains": "unicorns", scope: 'all'
321
- end
322
- ```
323
-
324
- ## Roadmap
325
-
326
- This is very much a work-in-progress. Future work is being sponsored by Gridinit.com. Get in touch with us if you'd like to be involved.
327
-
328
- ## Contributing
329
-
330
- 1. Fork it
331
- 2. Create your feature branch (`git checkout -b my-new-feature`)
332
- 3. Create some specs, make them pass
333
- 4. Commit your changes (`git commit -am 'Add some feature'`)
334
- 5. Push to the branch (`git push origin my-new-feature`)
335
- 6. Create new Pull Request
3
+ Moved to [ruby-jmeter](https://github.com/flood-io/ruby-jmeter).
@@ -19,4 +19,10 @@ Gem::Specification.new do |gem|
19
19
  gem.executables << 'grid'
20
20
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
21
  gem.require_paths = ['lib']
22
+
23
+ gem.post_install_message = <<-MESSAGE
24
+ ! The 'gridinit-jmeter' gem has been deprecated and has been replaced by 'ruby-jmeter'.
25
+ ! See: https://rubygems.org/gems/ruby-jmeter
26
+ ! And: https://github.com/flood-io/ruby-jmeter
27
+ MESSAGE
22
28
  end
@@ -16,3 +16,6 @@ lib = File.dirname(File.absolute_path(__FILE__))
16
16
  Dir.glob(lib + '/gridinit-jmeter/dsl/*', &method(:require))
17
17
  Dir.glob(lib + '/gridinit-jmeter/plugins/*', &method(:require))
18
18
  require 'gridinit-jmeter/dsl'
19
+
20
+ warn "[DEPRECATION] This gem has been renamed to ruby-jmeter and will no longer be supported. Please switch to ruby-jmeter as soon as possible."
21
+
@@ -1,5 +1,5 @@
1
1
  module Gridinit
2
2
  module Jmeter
3
- VERSION = "1.1.0.pre"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridinit-jmeter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.pre
5
- prerelease: 6
4
+ version: 1.1.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Koopmans
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -220,7 +220,14 @@ files:
220
220
  - spec/stub.rb
221
221
  homepage: http://github.com/altentee/gridinit-jmeter
222
222
  licenses: []
223
- post_install_message:
223
+ post_install_message: ! '! The ''gridinit-jmeter'' gem has been deprecated and
224
+ has been replaced by ''ruby-jmeter''.
225
+
226
+ ! See: https://rubygems.org/gems/ruby-jmeter
227
+
228
+ ! And: https://github.com/flood-io/ruby-jmeter
229
+
230
+ '
224
231
  rdoc_options: []
225
232
  require_paths:
226
233
  - lib
@@ -233,16 +240,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
233
240
  required_rubygems_version: !ruby/object:Gem::Requirement
234
241
  none: false
235
242
  requirements:
236
- - - ! '>'
243
+ - - ! '>='
237
244
  - !ruby/object:Gem::Version
238
- version: 1.3.1
245
+ version: '0'
239
246
  requirements: []
240
247
  rubyforge_project:
241
248
  rubygems_version: 1.8.23
242
249
  signing_key:
243
250
  specification_version: 3
244
251
  summary: This is a Ruby based DSL for writing JMeter test plans
245
- test_files:
246
- - spec/dsl_spec.rb
247
- - spec/spec_helper.rb
248
- - spec/stub.rb
252
+ test_files: []