perf_check 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/perf_check +7 -4
- data/lib/perf_check/server.rb +7 -20
- data/lib/perf_check/test_case.rb +8 -10
- data/lib/perf_check.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb29e570cff26d9c406b0c00f33ff23ae995d58e
|
4
|
+
data.tar.gz: ebda52213a4941d5295aa53463a5d28e28bf6cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33a44a973a4b30bffbf46ad429c9b8ae1097981afab251a65a60e130de94d7d60b422ae42ad9c1212befd1d83a9fa01b82f14958f0cca6526c13db6401cb2e01
|
7
|
+
data.tar.gz: 770e9614a6d3349fa0df0770158f0a4e30ca5adc048a4bd076dc6cf17adb897b3924c70bb294be5de799f8c90ba975e716d7b43ce409c0b1fce25a18389350ca
|
data/bin/perf_check
CHANGED
@@ -7,6 +7,7 @@ options = perf_check.options
|
|
7
7
|
options.login = nil
|
8
8
|
options.number_of_requests = 10
|
9
9
|
options.reference = 'master'
|
10
|
+
options.http_statuses = [200]
|
10
11
|
|
11
12
|
|
12
13
|
opts = OptionParser.new do |opts|
|
@@ -50,10 +51,12 @@ opts = OptionParser.new do |opts|
|
|
50
51
|
options.reference = nil
|
51
52
|
end
|
52
53
|
|
53
|
-
opts.
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
opts.on('--302-success', 'Consider HTTP 302 code a successful request') do
|
55
|
+
options.http_statuses.push(302)
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('--302-failure', 'Consider HTTP 302 code an unsuccessful request') do
|
59
|
+
options.http_statuses.delete(302)
|
57
60
|
end
|
58
61
|
|
59
62
|
opts.separator ''
|
data/lib/perf_check/server.rb
CHANGED
@@ -21,6 +21,7 @@ class PerfCheck
|
|
21
21
|
get_perf_check_session(params[:login], params[:route])
|
22
22
|
render :nothing => true
|
23
23
|
end
|
24
|
+
controller.send(:skip_before_filter, :verify_authenticity_token)
|
24
25
|
|
25
26
|
authorization do |login, route|
|
26
27
|
http = Net::HTTP.new(host, port)
|
@@ -29,6 +30,7 @@ class PerfCheck
|
|
29
30
|
elsif method == :get
|
30
31
|
response = http.get(login_route+"?login=#{login}")
|
31
32
|
end
|
33
|
+
|
32
34
|
response['Set-Cookie']
|
33
35
|
end
|
34
36
|
end
|
@@ -89,15 +91,11 @@ class PerfCheck
|
|
89
91
|
http.finish
|
90
92
|
end.real
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
result.response_body = response.body
|
98
|
-
end
|
99
|
-
else
|
100
|
-
raise Server::ApplicationError.new(response) unless response.code == '200'
|
94
|
+
Profile.new.tap do |result|
|
95
|
+
result.latency = latency
|
96
|
+
result.profile_url = latest_profiler_url
|
97
|
+
result.response_body = response.body
|
98
|
+
result.response_code = response.code.to_i
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
@@ -135,17 +133,6 @@ class PerfCheck
|
|
135
133
|
3031
|
136
134
|
end
|
137
135
|
|
138
|
-
class ApplicationError < Exception
|
139
|
-
def initialize(resp)
|
140
|
-
@response = resp
|
141
|
-
end
|
142
|
-
def code
|
143
|
-
@response.code
|
144
|
-
end
|
145
|
-
def body
|
146
|
-
@response.body
|
147
|
-
end
|
148
|
-
end
|
149
136
|
class Profile < OpenStruct; end
|
150
137
|
end
|
151
138
|
end
|
data/lib/perf_check/test_case.rb
CHANGED
@@ -18,24 +18,22 @@ class PerfCheck
|
|
18
18
|
self.resource = route
|
19
19
|
end
|
20
20
|
|
21
|
-
def run(server,
|
21
|
+
def run(server, options)
|
22
22
|
print("\t"+'request #'.underline)
|
23
23
|
print(" "+'latency'.underline)
|
24
24
|
print(" "+'server rss'.underline)
|
25
25
|
puts(" "+'profiler data'.underline)
|
26
26
|
|
27
|
-
(
|
28
|
-
|
27
|
+
(options.number_of_requests+1).times do |i|
|
28
|
+
profile = server.profile do |http|
|
29
|
+
http.get(resource, {'Cookie' => "#{cookie}"})
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
profile = server.profile do |http|
|
32
|
-
http.get(resource, {'Cookie' => "#{cookie}"})
|
33
|
-
end
|
34
|
-
rescue Server::ApplicationError => e
|
32
|
+
unless options.http_statuses.include? profile.response_code
|
35
33
|
File.open("public/perf_check_failed_request.html", 'w') do |error_dump|
|
36
|
-
error_dump.write(
|
34
|
+
error_dump.write(profile.response_body)
|
37
35
|
end
|
38
|
-
error = sprintf("\t%2i:\tFAILED! (HTTP %
|
36
|
+
error = sprintf("\t%2i:\tFAILED! (HTTP %d)", i, profile.response_code)
|
39
37
|
puts(error.red.bold)
|
40
38
|
puts("\t The server responded with a non-2xx status for this request.")
|
41
39
|
print("\t The response has been written to public")
|
data/lib/perf_check.rb
CHANGED