Let a module stream declare work-queue retention (issue 1177)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package broker
|
||||
|
||||
import "testing"
|
||||
|
||||
// mailSendsStream is mesh-mail's future `mail-sends` stream (novox/hq ADR 0436 §7, §8), as the bus holds it:
|
||||
// work-queue retention, a 24-hour duplicate window, kept one day and at most 64 MiB.
|
||||
var mailSendsStream = ModuleStream{Module: "mesh-mail", Name: "MAIL_SENDS",
|
||||
Events: []string{"mail.send.approved"}, MaxAgeDays: 1, MaxMiB: 64, WorkQueue: true, Duplicates: 24}
|
||||
|
||||
// 1177/AC1: a work-queue stream is composed with work-queue retention, refusing a new message when full
|
||||
// (DiscardNew), a 24-hour duplicate window, a one-day maximum age and a 64 MiB cap.
|
||||
func TestAWorkQueueStreamIsComposedToRefuseWhenFull(t *testing.T) {
|
||||
s := mailSendsStream.Stream()
|
||||
if s.Retention != RetentionWorkQueue {
|
||||
t.Fatalf("retention: %v, want %v", s.Retention, RetentionWorkQueue)
|
||||
}
|
||||
if !s.DiscardNew {
|
||||
t.Fatal("a work-queue stream did not refuse a new message when full")
|
||||
}
|
||||
if s.DuplicatesSeconds != 24*60*60 {
|
||||
t.Fatalf("duplicate window: %d seconds, want %d (24 hours)", s.DuplicatesSeconds, 24*60*60)
|
||||
}
|
||||
if s.MaxAge != 24*60*60 {
|
||||
t.Fatalf("max age: %d seconds, want %d (1 day)", s.MaxAge, 24*60*60)
|
||||
}
|
||||
if s.MaxBytes != 64<<20 {
|
||||
t.Fatalf("max bytes: %d, want %d (64 MiB)", s.MaxBytes, 64<<20)
|
||||
}
|
||||
}
|
||||
|
||||
// 1177/AC3: a stream with no work-queue clause composes exactly as main does: limits retention, dropping its
|
||||
// oldest, never refusing a new message.
|
||||
func TestANonWorkQueueStreamStillDropsItsOldest(t *testing.T) {
|
||||
s := mailStream.Stream()
|
||||
if s.Retention != RetentionLimits || s.DiscardNew || s.DuplicatesSeconds != 0 {
|
||||
t.Fatalf("composed as %+v; want limits retention, never discarding new, no duplicate window", s)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user