mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Fix undefined method check_email_sync_heartbeat in unicorn conf (#30360)
This is a follow-up to 9812407f76
This commit is contained in:
committed by
GitHub
parent
74aeec8ea3
commit
e4e5db57f0
53
spec/lib/demon/email_sync_spec.rb
Normal file
53
spec/lib/demon/email_sync_spec.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Demon::EmailSync do
|
||||
describe ".check_email_sync_heartbeat" do
|
||||
after do
|
||||
described_class.reset_demons
|
||||
described_class.test_cleanup
|
||||
end
|
||||
|
||||
it "should restart email sync daemons when last heartbeat is older than the heartbeat interval" do
|
||||
track_log_messages do |logger|
|
||||
daemon = described_class.new(1)
|
||||
daemon.set_pid(999_999)
|
||||
|
||||
described_class.set_demons({ "daemon" => daemon })
|
||||
|
||||
Discourse.redis.set(
|
||||
described_class::HEARTBEAT_KEY,
|
||||
Time.now.to_i - described_class::HEARTBEAT_INTERVAL.to_i - 1,
|
||||
)
|
||||
|
||||
daemon.expects(:restart)
|
||||
|
||||
described_class.check_email_sync_heartbeat
|
||||
|
||||
expect(logger.warnings.first).to eq(
|
||||
"EmailSync heartbeat test failed (last heartbeat was 61s ago), restarting",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it "should restart email sync daemons when memory usage exceeds the maximum allowed memory" do
|
||||
track_log_messages do |logger|
|
||||
daemon = described_class.new(1)
|
||||
daemon.set_pid(999_999)
|
||||
|
||||
described_class.set_demons({ "daemon" => daemon })
|
||||
|
||||
Discourse.redis.set(described_class::HEARTBEAT_KEY, Time.now.to_i)
|
||||
|
||||
daemon.expects(:restart)
|
||||
|
||||
# Set to negative value to fake that process is using too much memory
|
||||
described_class.expects(:max_allowed_email_sync_rss).returns(-1)
|
||||
described_class.check_email_sync_heartbeat
|
||||
|
||||
expect(logger.warnings.first).to eq(
|
||||
"EmailSync is consuming too much memory (using: 0.00M) for '#{described_class::HOSTNAME}', restarting",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user