feat: add durable relative task delays and outage recovery regression

This commit is contained in:
2026-09-17 23:43:57 +08:00
parent 522fe2ef3e
commit a664ec9370
34 changed files with 811 additions and 28 deletions

View File

@@ -24,7 +24,14 @@ func TestSubmitNormalizationAndBounds(t *testing.T) {
"unbounded attempts": func(v *SubmitInput) { v.Retry.MaxAttempts = 101 },
"unknown recovery policy": func(v *SubmitInput) { v.RecoverySafety = "UNKNOWN" },
"excess timeout": func(v *SubmitInput) { v.TaskTimeoutMS = 30*86400000 + 1 },
"sub-microsecond time": func(v *SubmitInput) { now := time.Date(2026, 1, 1, 0, 0, 0, 1, time.UTC); v.AvailableAt = &now },
"delay equals deadline": func(v *SubmitInput) { v.DelayMS = 86400000 },
"delay overflow": func(v *SubmitInput) { v.DelayMS = ^uint64(0) },
"both timing modes": func(v *SubmitInput) {
now := time.Now().UTC().Truncate(time.Microsecond)
v.AvailableAt = &now
v.DelayMS = 1
},
"sub-microsecond time": func(v *SubmitInput) { now := time.Date(2026, 1, 1, 0, 0, 0, 1, time.UTC); v.AvailableAt = &now },
} {
t.Run(name, func(t *testing.T) {
in := base
@@ -34,6 +41,10 @@ func TestSubmitNormalizationAndBounds(t *testing.T) {
}
})
}
base.DelayMS = 86400000 - 1
if out, err := NormalizeSubmit(base); err != nil || out.DelayMS != base.DelayMS || out.AvailableAt != nil {
t.Fatal("relative delay was resolved before database acceptance", err)
}
for _, key := range []string{"", strings.Repeat("a", 129), "with space", "带中文", "line\n"} {
if ValidateKey(key) == nil {
t.Fatal("accepted invalid key")