ruby-jmeter 2.11.8 → 2.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/real_user_objects_github.rb +112 -0
- data/lib/ruby-jmeter/dsl.rb +5 -0
- data/lib/ruby-jmeter/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 364b3c932e81a8d896c5c79a0d3bd34bd3d1ed3b
|
4
|
+
data.tar.gz: 25a8fc5ef8549bef2f84cc23f71332b0a5729cff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ec776fbc3bcfeb18ee8f18b7d5001cabfe328d397f772f546006303fd0fd195fa6b30c39f79ecc3c5909feb196c6d583f77ffdd6c9bb4b373c735842da1202
|
7
|
+
data.tar.gz: d22b98b39df23d4bc1f32d8a28c1c56cf847c76c88e8260a242c4dd1bf13e6f3a165f27d998a120fc049cf6233c0351d03c01fcf38eb6db4c4d1fb1a70c5d20a
|
@@ -0,0 +1,112 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'ruby-jmeter'
|
3
|
+
|
4
|
+
# Virtual user definitions
|
5
|
+
class VirtualUser
|
6
|
+
|
7
|
+
# initializes the VirtualUser object and adds some default test
|
8
|
+
# components.
|
9
|
+
# @param dsl the dsl
|
10
|
+
def initialize(dsl)
|
11
|
+
@dsl = dsl
|
12
|
+
|
13
|
+
defaults domain: 'github.com', # default domain if not specified in URL
|
14
|
+
protocol: 'http', # default protocol if not specified in URL
|
15
|
+
download_resources: true, # download images/CSS/JS
|
16
|
+
use_concurrent_pool: 6, # mimic Chrome/IE parallelism for images/CSS/JS
|
17
|
+
urls_must_match: '(https?.\/\/)?([^\.]*\.)*(github\.com)?\/.*' # only download resources for the target domain
|
18
|
+
|
19
|
+
cookies # om nom nom
|
20
|
+
|
21
|
+
cache clear_each_iteration: true # each thread iteration mimics a new user with an empty browser cache
|
22
|
+
|
23
|
+
with_user_agent 'ie9' # send IE9 browser headers
|
24
|
+
|
25
|
+
with_gzip # add HTTP request headers to allow GZIP compression. Most sites support this nowadays.
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
# Adds a user think time. Note that this is slightly different than the
|
30
|
+
# default JMeter think time, in that it executes sequentially with test steps.
|
31
|
+
# @param delay [int] the target pause time, in milliseconds
|
32
|
+
# @param deviation [int] the pause deviation, in milliseconds
|
33
|
+
def pause(delay=30000, deviation=5000)
|
34
|
+
test_action name: 'Think Time', action: 1, target: 0, duration: 0 do
|
35
|
+
think_time delay, deviation
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Requests the home page.
|
40
|
+
def home_page
|
41
|
+
visit name: 'Home page', url: '/'
|
42
|
+
pause
|
43
|
+
end
|
44
|
+
|
45
|
+
# Searches for a repository.
|
46
|
+
# @param repo [String] the repository to search for
|
47
|
+
def search_for_repository(repo)
|
48
|
+
visit name: 'Search for project', url: '/search',
|
49
|
+
always_encode: true,
|
50
|
+
fill_in: {
|
51
|
+
'q' => repo,
|
52
|
+
'ref' => 'cmdform'
|
53
|
+
}
|
54
|
+
pause
|
55
|
+
end
|
56
|
+
|
57
|
+
# Visits a repository page.
|
58
|
+
# @param repo_path [String] the repository URL path
|
59
|
+
def view_repository(repo_path)
|
60
|
+
visit name: 'Repository page', url: repo_path
|
61
|
+
pause
|
62
|
+
end
|
63
|
+
|
64
|
+
# Views a branch/tag page.
|
65
|
+
# @param branch_path [String] the branch URL path
|
66
|
+
def view_branch(branch_path)
|
67
|
+
visit name: 'Branch page', url: branch_path
|
68
|
+
pause
|
69
|
+
end
|
70
|
+
|
71
|
+
####################################################################
|
72
|
+
private
|
73
|
+
|
74
|
+
# Passes method calls through to the underlying DSL.
|
75
|
+
# @param method the method
|
76
|
+
# @param args the arguments
|
77
|
+
# @param block the block
|
78
|
+
def method_missing method, *args, &block
|
79
|
+
@dsl.__send__ method, *args, &block
|
80
|
+
end
|
81
|
+
####################################################################
|
82
|
+
end
|
83
|
+
|
84
|
+
# JMeter test plan begins here.
|
85
|
+
test do
|
86
|
+
|
87
|
+
# Defines a thread group. We allow certain parameters to be passed in
|
88
|
+
# as system properties.
|
89
|
+
threads count: '${__P(threads,1)}',
|
90
|
+
rampup: '${__P(rampup,600)}',
|
91
|
+
name: 'Test Scenario - GitHub project navigation',
|
92
|
+
duration: '${__P(duration, 600)}' do
|
93
|
+
|
94
|
+
user = VirtualUser.new(self) # This will add a bunch of test components.
|
95
|
+
|
96
|
+
# In the event of an error, the thread will start a new loop. If this
|
97
|
+
# happens on the first request, we could start flooding the site with
|
98
|
+
# requests.
|
99
|
+
# To prevent this from happening, we insert a quick pause before the
|
100
|
+
# first request.
|
101
|
+
user.pause 1000,0
|
102
|
+
|
103
|
+
# User workflow begins here.
|
104
|
+
# Note that think times are defined inside the page methods.
|
105
|
+
user.home_page
|
106
|
+
user.search_for_repository 'ruby-jmeter'
|
107
|
+
user.view_repository '/flood-io/ruby-jmeter'
|
108
|
+
user.view_branch '/flood-io/ruby-jmeter/tree/v2.11.8'
|
109
|
+
|
110
|
+
end
|
111
|
+
end.run(path: '/usr/share/jmeter-2.11/bin/', gui: true)
|
112
|
+
|
data/lib/ruby-jmeter/dsl.rb
CHANGED
@@ -142,6 +142,11 @@ module RubyJmeter
|
|
142
142
|
value: 'gzip, deflate'
|
143
143
|
end
|
144
144
|
|
145
|
+
def with_json
|
146
|
+
http_header_manager name: 'Accept',
|
147
|
+
value: 'text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8, application/json'
|
148
|
+
end
|
149
|
+
|
145
150
|
def test_data(*args, &block)
|
146
151
|
params = args.shift || {}
|
147
152
|
params = { key: params.to_s }.merge(args.shift || {}) if(params.class == String || params.class == Symbol)
|
data/lib/ruby-jmeter/version.rb
CHANGED
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.
|
4
|
+
version: 2.11.9
|
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-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- examples/real_flood_test_data.rb
|
89
89
|
- examples/real_immi.gov.au_visa.rb
|
90
90
|
- examples/real_page_objects.rb
|
91
|
+
- examples/real_user_objects_github.rb
|
91
92
|
- lib/ruby-jmeter.rb
|
92
93
|
- lib/ruby-jmeter/DSL.md
|
93
94
|
- lib/ruby-jmeter/dsl.rb
|