Evita 500 senza SMTP e chiude gli incidenti overflow stale.

Reset password e mail replay usano deliver_mail; il health check overflow risolve tutte le fingerprint del kind, non solo quella sana.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-31 08:55:36 +02:00
co-authored by Cursor
parent b08049cf69
commit 645807b853
9 changed files with 104 additions and 3 deletions
@@ -40,6 +40,44 @@ RSpec.describe Ops::HealthChecks do
expect(Ops::Incident.find_by(fingerprint: "disk_space:root").status).to eq("resolved")
end
it "chiude gli incidenti overflow anche se la fingerprint sana è diversa" do
Ops::Incident.create!(
kind: "stream_overflow",
severity: "warning",
status: "open",
title: "Capacità stream al massimo",
message: "overflow=3/3",
metadata: {},
fingerprint: "stream_overflow:at_max",
occurrence_count: 1,
first_seen_at: Time.current,
last_seen_at: Time.current
)
allow_any_instance_of(described_class).to receive(:check_stream_overflow).and_return(
described_class::Finding.new(
kind: "stream_overflow", severity: "info", healthy: true,
title: "Overflow streaming OK", message: "OK", metadata: {}, fingerprint: "stream_overflow:ok"
)
)
%i[
check_disk_root check_recordings_size check_postgres check_redis check_mediamtx check_garage
check_sidekiq_heartbeat check_sidekiq_dead check_http_rails check_rails_latency
].each do |method|
allow_any_instance_of(described_class).to receive(method).and_return(
described_class::Finding.new(
kind: "test", severity: "info", healthy: true,
title: "OK", message: "OK", metadata: {}, fingerprint: "#{method}:ok"
)
)
end
allow_any_instance_of(described_class).to receive(:public_check_due?).and_return(false)
described_class.new.call
expect(Ops::Incident.find_by(fingerprint: "stream_overflow:at_max").status).to eq("resolved")
end
end
describe "#summary" do
@@ -52,4 +52,28 @@ RSpec.describe Ops::IncidentRecorder do
expect(incident.reload.status).to eq("resolved")
end
end
describe ".resolve_kind" do
it "chiude tutti gli incidenti aperti di quel kind" do
at_max = described_class.record(
kind: "stream_overflow",
severity: "warning",
title: "Max",
message: "max",
fingerprint: "stream_overflow:at_max"
)
orphan = described_class.record(
kind: "stream_overflow",
severity: "warning",
title: "Idle",
message: "idle",
fingerprint: "stream_overflow:orphan_idle"
)
described_class.resolve_kind("stream_overflow")
expect(at_max.reload.status).to eq("resolved")
expect(orphan.reload.status).to eq("resolved")
end
end
end
@@ -27,4 +27,22 @@ RSpec.describe Recordings::NotifyReady do
expect(recording.reload.ready_notified_at).to be_present
end
it "marca notificato anche se in produzione manca SMTP" do
recording = Recording.create!(
stream_session: session,
team: team,
status: "ready",
expires_at: 10.days.from_now,
storage_key: "key"
)
allow(MatchLiveTv).to receive(:smtp_configured?).and_return(false)
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
expect {
described_class.new(recording).call
}.not_to change { ActionMailer::Base.deliveries.size }
expect(recording.reload.ready_notified_at).to be_present
end
end