easymon 1.4 → 1.6.0
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/README.md +1 -1
- data/app/controllers/easymon/checks_controller.rb +2 -2
- data/lib/easymon/checks/active_record_mysql_writeable_check.rb +26 -0
- data/lib/easymon/checks/redis_check.rb +9 -5
- data/lib/easymon/checks/redis_writeable_check.rb +36 -0
- data/lib/easymon/checks/split_active_record_check.rb +12 -12
- data/lib/easymon/version.rb +1 -1
- data/lib/easymon.rb +2 -0
- data/test/dummy/app/assets/config/manifest.js +0 -0
- data/test/dummy/config/database.yml +2 -2
- data/test/dummy/config/storage.yml +0 -0
- data/test/dummy/log/development.log +24 -0
- data/test/dummy/log/test.log +6944 -873
- data/test/dummy/tmp/cache/4D4/7A0/health_check +1 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/checks/active_record_mysql_writeable_check_test.rb +27 -0
- data/test/unit/checks/redis_writeable_check_test.rb +28 -0
- data/test/unit/checks/split_active_record_check_test.rb +19 -19
- metadata +19 -8
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@valuei:
|
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ActiveRecordMysqlWriteableCheckTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "#check returns a successful result on a good run" do
|
6
|
+
check = create_check
|
7
|
+
results = check.check
|
8
|
+
|
9
|
+
assert_equal(true, results[0])
|
10
|
+
assert_equal("@@read_only is 0", results[1])
|
11
|
+
end
|
12
|
+
|
13
|
+
test "#check returns a failed result on a failed run" do
|
14
|
+
# Return a mock'd object that responds to .entries that returns [[0]]
|
15
|
+
ActiveRecord::Base.connection.stubs(:execute).returns(mock().stubs(:entries).returns([[1]]))
|
16
|
+
check = create_check
|
17
|
+
results = check.check
|
18
|
+
|
19
|
+
assert_equal(false, results[0])
|
20
|
+
assert_equal("@@read_only is 1", results[1])
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def create_check
|
25
|
+
Easymon::ActiveRecordMysqlWriteableCheck.new(ActiveRecord::Base)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RedisWriteableCheckTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "#run sets success conditions on successful run" do
|
6
|
+
Redis.any_instance.stubs(:set).returns("OK")
|
7
|
+
check = create_check
|
8
|
+
results = check.check
|
9
|
+
|
10
|
+
assert_equal("Writeable", results[1])
|
11
|
+
assert_equal(true, results[0])
|
12
|
+
end
|
13
|
+
|
14
|
+
test "#run sets failure conditions on a failed run" do
|
15
|
+
Redis.any_instance.stubs(:set).raises(Redis::ConnectionError.new)
|
16
|
+
check = create_check
|
17
|
+
results = check.check
|
18
|
+
|
19
|
+
assert_equal("Read Only", results[1])
|
20
|
+
assert_equal(false, results[0])
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def create_check
|
25
|
+
# Get us a config hash from disk in this case
|
26
|
+
Easymon::RedisWriteableCheck.new(YAML.load_file(Rails.root.join("config/redis.yml"))[Rails.env].symbolize_keys)
|
27
|
+
end
|
28
|
+
end
|
@@ -3,50 +3,50 @@ require 'test_helper'
|
|
3
3
|
class SplitActiveRecordCheckTest < ActiveSupport::TestCase
|
4
4
|
|
5
5
|
test "#run sets success conditions on successful run" do
|
6
|
-
|
6
|
+
primary = ActiveRecord::Base.connection
|
7
7
|
Easymon::Base.establish_connection
|
8
|
-
|
8
|
+
replica = Easymon::Base.connection
|
9
9
|
|
10
|
-
check = Easymon::SplitActiveRecordCheck.new { [
|
10
|
+
check = Easymon::SplitActiveRecordCheck.new { [primary, replica] }
|
11
11
|
|
12
12
|
results = check.check
|
13
13
|
|
14
|
-
assert_equal("
|
14
|
+
assert_equal("Primary: Up - Replica: Up", results[1])
|
15
15
|
assert_equal(true, results[0])
|
16
16
|
end
|
17
17
|
|
18
|
-
test "#run sets failed conditions when
|
19
|
-
|
18
|
+
test "#run sets failed conditions when replica is down" do
|
19
|
+
primary = ActiveRecord::Base.connection
|
20
20
|
Easymon::Base.establish_connection
|
21
|
-
|
21
|
+
replica = Easymon::Base.connection
|
22
22
|
|
23
|
-
|
23
|
+
replica.stubs(:active?).raises("boom")
|
24
24
|
|
25
|
-
check = Easymon::SplitActiveRecordCheck.new { [
|
25
|
+
check = Easymon::SplitActiveRecordCheck.new { [primary, replica] }
|
26
26
|
results = check.check
|
27
27
|
|
28
|
-
assert_equal("
|
28
|
+
assert_equal("Primary: Up - Replica: Down", results[1])
|
29
29
|
assert_equal(false, results[0])
|
30
30
|
end
|
31
31
|
|
32
|
-
test "#run sets failed conditions when
|
33
|
-
|
32
|
+
test "#run sets failed conditions when primary is down" do
|
33
|
+
primary = ActiveRecord::Base.connection
|
34
34
|
Easymon::Base.establish_connection
|
35
|
-
|
35
|
+
replica = Easymon::Base.connection
|
36
36
|
|
37
|
-
|
37
|
+
primary.stubs(:active?).raises("boom")
|
38
38
|
|
39
|
-
check = Easymon::SplitActiveRecordCheck.new { [
|
39
|
+
check = Easymon::SplitActiveRecordCheck.new { [primary, replica] }
|
40
40
|
results = check.check
|
41
41
|
|
42
|
-
assert_equal("
|
42
|
+
assert_equal("Primary: Down - Replica: Up", results[1])
|
43
43
|
assert_equal(false, results[0])
|
44
44
|
end
|
45
45
|
|
46
46
|
test "given nil as a config" do
|
47
47
|
check = Easymon::SplitActiveRecordCheck.new { }
|
48
48
|
results = check.check
|
49
|
-
assert_equal("
|
49
|
+
assert_equal("Primary: Down - Replica: Down", results[1])
|
50
50
|
assert_equal(false, results[0])
|
51
51
|
end
|
52
52
|
end
|
@@ -63,8 +63,8 @@ module Easymon
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def database_configuration
|
66
|
-
env = "#{Rails.env}
|
67
|
-
|
66
|
+
env = "#{Rails.env}_replica"
|
67
|
+
YAML.load_file(Rails.root.join('config/database.yml'))[env]
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easymon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -70,28 +70,28 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
73
|
+
version: '1.2'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '1.2'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: mocha
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '1.
|
87
|
+
version: '1.11'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '1.
|
94
|
+
version: '1.11'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: dalli
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,9 +125,11 @@ files:
|
|
125
125
|
- lib/easymon.rb
|
126
126
|
- lib/easymon/checklist.rb
|
127
127
|
- lib/easymon/checks/active_record_check.rb
|
128
|
+
- lib/easymon/checks/active_record_mysql_writeable_check.rb
|
128
129
|
- lib/easymon/checks/http_check.rb
|
129
130
|
- lib/easymon/checks/memcached_check.rb
|
130
131
|
- lib/easymon/checks/redis_check.rb
|
132
|
+
- lib/easymon/checks/redis_writeable_check.rb
|
131
133
|
- lib/easymon/checks/semaphore_check.rb
|
132
134
|
- lib/easymon/checks/split_active_record_check.rb
|
133
135
|
- lib/easymon/checks/traffic_enabled_check.rb
|
@@ -140,6 +142,7 @@ files:
|
|
140
142
|
- test/controllers/easymon/checks_controller_test.rb
|
141
143
|
- test/dummy/README.rdoc
|
142
144
|
- test/dummy/Rakefile
|
145
|
+
- test/dummy/app/assets/config/manifest.js
|
143
146
|
- test/dummy/app/assets/javascripts/application.js
|
144
147
|
- test/dummy/app/assets/javascripts/easymon.js
|
145
148
|
- test/dummy/app/assets/stylesheets/application.css
|
@@ -171,6 +174,7 @@ files:
|
|
171
174
|
- test/dummy/config/memcached.yml
|
172
175
|
- test/dummy/config/redis.yml
|
173
176
|
- test/dummy/config/routes.rb
|
177
|
+
- test/dummy/config/storage.yml
|
174
178
|
- test/dummy/log/development.log
|
175
179
|
- test/dummy/log/test.log
|
176
180
|
- test/dummy/public/404.html
|
@@ -178,15 +182,18 @@ files:
|
|
178
182
|
- test/dummy/public/500.html
|
179
183
|
- test/dummy/public/favicon.ico
|
180
184
|
- test/dummy/script/rails
|
185
|
+
- test/dummy/tmp/cache/4D4/7A0/health_check
|
181
186
|
- test/helpers/easymon/checks_helper_test.rb
|
182
187
|
- test/integration/navigation_test.rb
|
183
188
|
- test/test_helper.rb
|
184
189
|
- test/unit/checklist_test.rb
|
185
190
|
- test/unit/checks/active_record_check_on_postgresql_test.rb
|
186
191
|
- test/unit/checks/active_record_check_test.rb
|
192
|
+
- test/unit/checks/active_record_mysql_writeable_check_test.rb
|
187
193
|
- test/unit/checks/http_check_test.rb
|
188
194
|
- test/unit/checks/memcached_check_test.rb
|
189
195
|
- test/unit/checks/redis_check_test.rb
|
196
|
+
- test/unit/checks/redis_writeable_check_test.rb
|
190
197
|
- test/unit/checks/semaphore_check_test.rb
|
191
198
|
- test/unit/checks/split_active_record_check_test.rb
|
192
199
|
- test/unit/checks/traffic_enabled_check_test.rb
|
@@ -210,14 +217,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
217
|
- !ruby/object:Gem::Version
|
211
218
|
version: '0'
|
212
219
|
requirements: []
|
213
|
-
|
214
|
-
rubygems_version: 2.7.6
|
220
|
+
rubygems_version: 3.1.6
|
215
221
|
signing_key:
|
216
222
|
specification_version: 4
|
217
223
|
summary: Simple availability checks for your rails app
|
218
224
|
test_files:
|
219
225
|
- test/unit/checks/memcached_check_test.rb
|
220
226
|
- test/unit/checks/http_check_test.rb
|
227
|
+
- test/unit/checks/active_record_mysql_writeable_check_test.rb
|
228
|
+
- test/unit/checks/redis_writeable_check_test.rb
|
221
229
|
- test/unit/checks/semaphore_check_test.rb
|
222
230
|
- test/unit/checks/active_record_check_test.rb
|
223
231
|
- test/unit/checks/active_record_check_on_postgresql_test.rb
|
@@ -231,6 +239,7 @@ test_files:
|
|
231
239
|
- test/dummy/app/views/easymon/index.html.erb
|
232
240
|
- test/dummy/app/views/easymon/show.html.erb
|
233
241
|
- test/dummy/app/views/layouts/application.html.erb
|
242
|
+
- test/dummy/app/assets/config/manifest.js
|
234
243
|
- test/dummy/app/assets/javascripts/easymon.js
|
235
244
|
- test/dummy/app/assets/javascripts/application.js
|
236
245
|
- test/dummy/app/assets/stylesheets/application.css
|
@@ -244,6 +253,7 @@ test_files:
|
|
244
253
|
- test/dummy/config/environments/test.rb
|
245
254
|
- test/dummy/config/environment.rb
|
246
255
|
- test/dummy/config/redis.yml
|
256
|
+
- test/dummy/config/storage.yml
|
247
257
|
- test/dummy/config/application.rb
|
248
258
|
- test/dummy/config/memcached.yml
|
249
259
|
- test/dummy/config/database.yml
|
@@ -265,6 +275,7 @@ test_files:
|
|
265
275
|
- test/dummy/public/404.html
|
266
276
|
- test/dummy/log/test.log
|
267
277
|
- test/dummy/log/development.log
|
278
|
+
- test/dummy/tmp/cache/4D4/7A0/health_check
|
268
279
|
- test/dummy/README.rdoc
|
269
280
|
- test/integration/navigation_test.rb
|
270
281
|
- test/test_helper.rb
|