easymon 1.6.5 → 1.6.6
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/lib/easymon/checks/multi_active_record_check.rb +30 -4
- data/lib/easymon/version.rb +1 -1
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +23610 -572
- data/test/dummy/tmp/local_secret.txt +1 -1
- data/test/unit/checks/multi_active_record_check_test.rb +94 -0
- metadata +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
79f81bb4cf23d45aa2723411d62127883f7397ec467f9615e61c085574119d0966fdd9f4ac1291878c77a05da7c115b7e00fca74cc19e563c4b46e04973bb0a8
|
|
@@ -53,6 +53,100 @@ class MultiActiveRecordCheckTest < ActiveSupport::TestCase
|
|
|
53
53
|
assert_equal(false, results[0])
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
test "#run uses the health check query when given" do
|
|
57
|
+
primary = ActiveRecord::Base.connection
|
|
58
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
59
|
+
|
|
60
|
+
check = Easymon::MultiActiveRecordCheck.new(query: "SELECT 1") do
|
|
61
|
+
{ "Primary": primary, "PrimaryReplica": primary_replica }
|
|
62
|
+
end
|
|
63
|
+
results = check.check
|
|
64
|
+
|
|
65
|
+
assert_equal("Primary: Up - PrimaryReplica: Up", results[1])
|
|
66
|
+
assert_equal(true, results[0])
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "#run sets failed conditions when the health check query returns false" do
|
|
70
|
+
primary = ActiveRecord::Base.connection
|
|
71
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
72
|
+
|
|
73
|
+
primary_replica.stubs(:select_value).with("SELECT 1").returns(0)
|
|
74
|
+
|
|
75
|
+
check = Easymon::MultiActiveRecordCheck.new(query: "SELECT 1") do
|
|
76
|
+
{ "Primary": primary, "PrimaryReplica": primary_replica }
|
|
77
|
+
end
|
|
78
|
+
results = check.check
|
|
79
|
+
|
|
80
|
+
assert_equal("Primary: Up - PrimaryReplica: Down", results[1])
|
|
81
|
+
assert_equal(false, results[0])
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
test "#run sets failed conditions when the health check query returns null" do
|
|
85
|
+
primary = ActiveRecord::Base.connection
|
|
86
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
87
|
+
|
|
88
|
+
check = Easymon::MultiActiveRecordCheck.new(query: "SELECT NULL") do
|
|
89
|
+
{ "Primary": primary, "PrimaryReplica": primary_replica }
|
|
90
|
+
end
|
|
91
|
+
results = check.check
|
|
92
|
+
|
|
93
|
+
assert_equal("Primary: Down - PrimaryReplica: Down", results[1])
|
|
94
|
+
assert_equal(false, results[0])
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
test "#run sets failed conditions when the health check query raises" do
|
|
98
|
+
primary = ActiveRecord::Base.connection
|
|
99
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
100
|
+
|
|
101
|
+
primary_replica.stubs(:select_value).raises("boom")
|
|
102
|
+
|
|
103
|
+
check = Easymon::MultiActiveRecordCheck.new(query: "SELECT 1") do
|
|
104
|
+
{ "Primary": primary, "PrimaryReplica": primary_replica }
|
|
105
|
+
end
|
|
106
|
+
results = check.check
|
|
107
|
+
|
|
108
|
+
assert_equal("Primary: Up - PrimaryReplica: Down", results[1])
|
|
109
|
+
assert_equal(false, results[0])
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
test "#run uses per-connection queries when given" do
|
|
113
|
+
primary = ActiveRecord::Base.connection
|
|
114
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
115
|
+
other_replica = Easymon::OtherReplica.connection
|
|
116
|
+
|
|
117
|
+
primary_replica.stubs(:select_value).with("SELECT 0").returns(0)
|
|
118
|
+
|
|
119
|
+
check = Easymon::MultiActiveRecordCheck.new do
|
|
120
|
+
{
|
|
121
|
+
"Primary": [ primary, "SELECT 1" ],
|
|
122
|
+
"PrimaryReplica": [ primary_replica, "SELECT 0" ],
|
|
123
|
+
"OtherReplica": other_replica
|
|
124
|
+
}
|
|
125
|
+
end
|
|
126
|
+
results = check.check
|
|
127
|
+
|
|
128
|
+
assert_equal("Primary: Up - PrimaryReplica: Down - OtherReplica: Up", results[1])
|
|
129
|
+
assert_equal(false, results[0])
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
test "#run prefers the per-connection query over the default query" do
|
|
133
|
+
primary = ActiveRecord::Base.connection
|
|
134
|
+
primary_replica = Easymon::PrimaryReplica.connection
|
|
135
|
+
|
|
136
|
+
primary_replica.stubs(:select_value).with("SELECT 0").returns(0)
|
|
137
|
+
|
|
138
|
+
check = Easymon::MultiActiveRecordCheck.new(query: "SELECT 1") do
|
|
139
|
+
{
|
|
140
|
+
"Primary": primary,
|
|
141
|
+
"PrimaryReplica": [ primary_replica, "SELECT 0" ]
|
|
142
|
+
}
|
|
143
|
+
end
|
|
144
|
+
results = check.check
|
|
145
|
+
|
|
146
|
+
assert_equal("Primary: Up - PrimaryReplica: Down", results[1])
|
|
147
|
+
assert_equal(false, results[0])
|
|
148
|
+
end
|
|
149
|
+
|
|
56
150
|
test "given nil as a config" do
|
|
57
151
|
check = Easymon::MultiActiveRecordCheck.new { }
|
|
58
152
|
results = check.check
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easymon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Anderson
|
|
@@ -190,6 +190,7 @@ files:
|
|
|
190
190
|
- test/dummy/config/redis.yml
|
|
191
191
|
- test/dummy/config/routes.rb
|
|
192
192
|
- test/dummy/config/storage.yml
|
|
193
|
+
- test/dummy/log/development.log
|
|
193
194
|
- test/dummy/log/test.log
|
|
194
195
|
- test/dummy/public/400.html
|
|
195
196
|
- test/dummy/public/404.html
|
|
@@ -274,6 +275,7 @@ test_files:
|
|
|
274
275
|
- test/dummy/config/redis.yml
|
|
275
276
|
- test/dummy/config/routes.rb
|
|
276
277
|
- test/dummy/config/storage.yml
|
|
278
|
+
- test/dummy/log/development.log
|
|
277
279
|
- test/dummy/log/test.log
|
|
278
280
|
- test/dummy/public/400.html
|
|
279
281
|
- test/dummy/public/404.html
|