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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f95a944bc3ea7c0e6db69ceae559e9907ed098a
4
- data.tar.gz: 4fa447acd5f53650ac5c90f7f64bb8bbe016a29b
3
+ metadata.gz: eb29e570cff26d9c406b0c00f33ff23ae995d58e
4
+ data.tar.gz: ebda52213a4941d5295aa53463a5d28e28bf6cf2
5
5
  SHA512:
6
- metadata.gz: ec5adf72039c8e6c37015cff8897627b138b29cf55d247e7f9963c1090cd1a41555f05d5a386171e0154d131a4e6ff435c7ea34134f5a02a389d846bfae36823
7
- data.tar.gz: 891198f7dfd2caa16786ebfcfc8c36db22b2cbaacaf2f81d86486bd3f49e2c6532b92c235121faab4aef9e23d124f66539dd3564b5ace26a772a33d8a49d300e
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.separator "\nOther"
54
- opts.on('--server') do
55
- PerfCheck::Server.start
56
- exit!(0)
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 ''
@@ -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
- case response.code
93
- when '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
- 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
@@ -18,24 +18,22 @@ class PerfCheck
18
18
  self.resource = route
19
19
  end
20
20
 
21
- def run(server, count)
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
- (count+1).times do |i|
28
- errors = 0
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
- begin
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(e.body)
34
+ error_dump.write(profile.response_body)
37
35
  end
38
- error = sprintf("\t%2i:\tFAILED! (HTTP %s)", i, e.code)
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
@@ -67,7 +67,7 @@ class PerfCheck
67
67
  end
68
68
 
69
69
  puts("\n\nBenchmarking #{test.resource}:")
70
- test.run(server, options.number_of_requests)
70
+ test.run(server, options)
71
71
  end
72
72
  end
73
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perf_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubytune