feat(mail): send service identity mail through a leased worker
This commit is contained in:
1 parent
204c6bae62
commit
d21fd49a42
58 files changed
+7577
-164
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMetricsHandlerExposesWhetherTheMailSenderRuns(t *testing.T) {
|
||||
metrics := New()
|
||||
// The series exists before any loop starts, so an alert that needs
|
||||
// "the sender runs" sees 0 instead of a missing series.
|
||||
requireSeries(t, scrape(t, metrics), "lincodex_mail_sender_running 0")
|
||||
|
||||
metrics.SetMailSenderRunning(true)
|
||||
requireSeries(t, scrape(t, metrics), "lincodex_mail_sender_running 1")
|
||||
|
||||
metrics.SetMailSenderRunning(false)
|
||||
requireSeries(t, scrape(t, metrics), "lincodex_mail_sender_running 0")
|
||||
}
|
||||
|
||||
func TestMetricsHandlerCountsCancelledMailByABoundedReason(t *testing.T) {
|
||||
metrics := New()
|
||||
// Every reason exists at zero before the first cancellation.
|
||||
body := scrape(t, metrics)
|
||||
requireSeries(t, body,
|
||||
`lincodex_mail_sender_cancelled_total{reason="content_invalid"} 0`,
|
||||
`lincodex_mail_sender_cancelled_total{reason="processing_failed"} 0`,
|
||||
`lincodex_mail_sender_cancelled_total{reason="token_revoked"} 0`,
|
||||
)
|
||||
metrics.ObserveMailCancelled("content_invalid")
|
||||
metrics.ObserveMailCancelled("content_invalid")
|
||||
// A reason outside the domain set cannot become a label.
|
||||
metrics.ObserveMailCancelled("someone@example.com")
|
||||
requireSeries(t, scrape(t, metrics),
|
||||
`lincodex_mail_sender_cancelled_total{reason="content_invalid"} 2`,
|
||||
`lincodex_mail_sender_cancelled_total{reason="processing_failed"} 1`,
|
||||
)
|
||||
if strings.Contains(scrape(t, metrics), "someone@example.com") {
|
||||
t.Fatal("an arbitrary reason became a label")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user