check_passenger 1.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
1
4
  lib = File.expand_path('../lib', File.dirname(__FILE__))
2
5
  $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
3
6
 
@@ -10,10 +10,10 @@ describe CheckPassenger::NagiosCheck do
10
10
  describe '#nagios_status' do
11
11
  it 'returns the correct status' do
12
12
  assert_equal :ok, @obj.send(:nagios_status, 2)
13
- assert_equal :ok, @obj.send(:nagios_status, 2, { warn: '3' })
14
- assert_equal :warn, @obj.send(:nagios_status, 6, { warn: '5' })
15
- assert_equal :warn, @obj.send(:nagios_status, -1, { warn: '5' })
16
- assert_equal :crit, @obj.send(:nagios_status, 6, { warn: '5', crit: '5' })
13
+ assert_equal :ok, @obj.send(:nagios_status, 2, warn: '3')
14
+ assert_equal :warn, @obj.send(:nagios_status, 6, warn: '5')
15
+ assert_equal :warn, @obj.send(:nagios_status, -1, warn: '5')
16
+ assert_equal :crit, @obj.send(:nagios_status, 6, warn: '5', crit: '5')
17
17
  end
18
18
  end
19
19
 
@@ -10,7 +10,7 @@ describe CheckPassenger::Parser do
10
10
  ----------- General information -----------
11
11
  Max pool size : 40
12
12
  Processes : 26
13
- Requests in top-level queue : 0
13
+ Requests in top-level queue : 2
14
14
 
15
15
  ----------- Application groups -----------
16
16
  HEREDOC
@@ -19,25 +19,25 @@ describe CheckPassenger::Parser do
19
19
  it 'correctly handles process life' do
20
20
  begin
21
21
  parser = CheckPassenger::Parser.new(@sample_output)
22
- rescue Exception => e
23
- assert false, 'Exception %s raised with message: %s' % [e.class.to_s, e.to_s]
22
+ rescue e
23
+ assert false, "Exception #{e.class} raised with message: #{e}"
24
24
  end
25
25
 
26
26
  last_used = '23x 4d 5h 4s'
27
27
  assert_raises CheckPassenger::StatusOutputError do
28
- parser.send(:'is_process_alive?', last_used)
28
+ parser.send(:'process_alive?', last_used)
29
29
  end
30
30
 
31
31
  last_used = '4d 5h 4s'
32
32
 
33
33
  begin
34
34
  life_in_seconds = parser.send(:life_to_seconds, last_used)
35
- rescue Exception => e
36
- assert false, 'Exception %s raised with message: %s' % [e.class.to_s, e.to_s]
35
+ rescue e
36
+ assert false, "Exception #{e.class} raised with message: #{e}"
37
37
  end
38
38
  assert_equal 363_604, life_in_seconds
39
39
 
40
- refute parser.send(:'is_process_alive?', last_used)
40
+ refute parser.send(:'process_alive?', last_used)
41
41
  end
42
42
 
43
43
  it 'correctly parses max pool size' do
@@ -55,6 +55,11 @@ describe CheckPassenger::Parser do
55
55
  end
56
56
  end
57
57
 
58
+ it 'correctly parses requests in top-level queue' do
59
+ parser = CheckPassenger::Parser.new(@sample_output)
60
+ assert_equal 2, parser.top_level_request_count
61
+ end
62
+
58
63
  it 'gets Passenger version' do
59
64
  parser = CheckPassenger::Parser.new(@sample_output)
60
65
  assert_respond_to parser, :passenger_version
@@ -79,6 +84,10 @@ describe CheckPassenger::Parser do
79
84
  assert_equal 40, @parser.max_pool_size
80
85
  end
81
86
 
87
+ it 'reports the number of requests in top-level queue' do
88
+ assert_equal 10, @parser.top_level_request_count
89
+ end
90
+
82
91
  describe 'for all applications' do
83
92
  it 'reports all memory used' do
84
93
  refute @parser.memory.nil?
@@ -92,6 +101,10 @@ describe CheckPassenger::Parser do
92
101
  it 'reports the number of live processes' do
93
102
  assert_equal 9, @parser.live_process_count
94
103
  end
104
+
105
+ it 'reports the number of requests queued' do
106
+ assert_equal 60, @parser.request_count
107
+ end
95
108
  end
96
109
 
97
110
  describe 'for a specific application' do
@@ -108,6 +121,10 @@ describe CheckPassenger::Parser do
108
121
  assert_equal 4, @parser.live_process_count('application_4')
109
122
  end
110
123
 
124
+ it 'reports the requests queued' do
125
+ assert_equal 12, @parser.request_count('application_2')
126
+ end
127
+
111
128
  it 'raises exception if term matches multiple apps' do
112
129
  assert_raises CheckPassenger::MultipleApplicationsError do
113
130
  @parser.memory('application')
@@ -133,6 +150,10 @@ describe CheckPassenger::Parser do
133
150
  assert_equal 40, @parser.max_pool_size
134
151
  end
135
152
 
153
+ it 'reports the number of requests in top-level queue' do
154
+ assert_equal 12, @parser.top_level_request_count
155
+ end
156
+
136
157
  describe 'for all applications' do
137
158
  it 'reports all memory used' do
138
159
  refute @parser.memory.nil?
@@ -141,7 +162,7 @@ describe CheckPassenger::Parser do
141
162
 
142
163
  it 'reports the total count of processes' do
143
164
  assert_equal 22, @parser.process_count
144
- end
165
+ end
145
166
 
146
167
  it 'reports the number of live processes' do
147
168
  assert_equal 7, @parser.live_process_count
@@ -161,6 +182,11 @@ describe CheckPassenger::Parser do
161
182
  assert_equal 4, @parser.live_process_count('application_1')
162
183
  assert_equal 0, @parser.live_process_count('application_2')
163
184
  end
185
+
186
+ it 'reports the number of requests in application queue' do
187
+ assert_equal 21, @parser.request_count('application_1')
188
+ assert_equal 22, @parser.request_count('application_2')
189
+ end
164
190
  end
165
191
  end
166
192
  end
@@ -16,8 +16,8 @@ describe CheckPassenger::PassengerStatus do
16
16
  it 'can find the executable in a directory' do
17
17
  CheckPassenger::PassengerStatus.path = File.dirname(__FILE__)
18
18
  begin
19
- output = CheckPassenger::PassengerStatus.run
20
- rescue Exception => e
19
+ CheckPassenger::PassengerStatus.run
20
+ rescue e
21
21
  assert false, e.to_s
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_passenger
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alvaro Redondo
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.6'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.6'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: minitest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: minitest-reporters
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: thor
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: 0.19.1
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: 0.19.1
94
83
  description:
@@ -99,7 +88,12 @@ executables:
99
88
  extensions: []
100
89
  extra_rdoc_files: []
101
90
  files:
102
- - .gitignore
91
+ - ".codeclimate.yml"
92
+ - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - ".travis.yml"
95
+ - CHANGELOG.md
96
+ - CONTRIBUTING.md
103
97
  - Gemfile
104
98
  - LICENSE.txt
105
99
  - README.md
@@ -127,33 +121,26 @@ files:
127
121
  homepage: https://github.com/aredondo/check_passenger
128
122
  licenses:
129
123
  - MIT
124
+ metadata: {}
130
125
  post_install_message:
131
126
  rdoc_options: []
132
127
  require_paths:
133
128
  - lib
134
129
  required_ruby_version: !ruby/object:Gem::Requirement
135
- none: false
136
130
  requirements:
137
- - - ! '>='
131
+ - - ">="
138
132
  - !ruby/object:Gem::Version
139
133
  version: '0'
140
- segments:
141
- - 0
142
- hash: 2306355991957231543
143
134
  required_rubygems_version: !ruby/object:Gem::Requirement
144
- none: false
145
135
  requirements:
146
- - - ! '>='
136
+ - - ">="
147
137
  - !ruby/object:Gem::Version
148
138
  version: '0'
149
- segments:
150
- - 0
151
- hash: 2306355991957231543
152
139
  requirements: []
153
140
  rubyforge_project:
154
- rubygems_version: 1.8.29
141
+ rubygems_version: 2.4.5
155
142
  signing_key:
156
- specification_version: 3
143
+ specification_version: 4
157
144
  summary: Nagios check to monitor Passenger processes and memory
158
145
  test_files:
159
146
  - test/passenger-status