Add activity tracking to prevent stall timeouts during message transfers
Add OnActivity callback to CopyDeps to prevent stall timeouts during large message transfers Implement touchReader and touchWriter wrappers to call OnActivity during FETCH and APPEND operations Add slow message logging to identify performance bottlenecks Add test case to verify activity reporting during message transfers Clean up orchestrator account reset code formatting
This commit is contained in:
@@ -169,6 +169,56 @@ func TestCopyFolderPreservesInternalDate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestCopyFolderReportsActivityDuringBody proves CopyFolder invokes OnActivity
|
||||
// while a message body is being transferred (FETCH/APPEND), not only between
|
||||
// messages. This is what keeps the orchestrator's stall watchdog from killing a
|
||||
// single large-but-live message whose transfer legitimately exceeds the stall
|
||||
// timeout: without an in-body activity signal, one slow message looks identical
|
||||
// to a wedged connection.
|
||||
func TestCopyFolderReportsActivityDuringBody(t *testing.T) {
|
||||
ep := testEP(t)
|
||||
ctx := context.Background()
|
||||
|
||||
seedInbox(t, ep, "actsrc@localhost", "p", 1)
|
||||
|
||||
src, err := Connect(ctx, ep)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = src.Logout().Wait() }()
|
||||
if err := src.Login("actsrc@localhost", "p").Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dst, err := Connect(ctx, ep)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = dst.Logout().Wait() }()
|
||||
if err := dst.Login("actdst@localhost", "p").Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var activity int
|
||||
deps := CopyDeps{
|
||||
IsMigrated: func(string) (bool, error) { return false, nil },
|
||||
MarkMigrated: func(_, _ string) error { return nil },
|
||||
OnProgress: func(_, _ int) {},
|
||||
OnActivity: func() { activity++ },
|
||||
}
|
||||
|
||||
r, err := CopyFolder(ctx, src, dst, "INBOX", "INBOX", deps)
|
||||
if err != nil {
|
||||
t.Fatalf("CopyFolder: %v", err)
|
||||
}
|
||||
if r.Copied != 1 {
|
||||
t.Fatalf("copied=%d want 1", r.Copied)
|
||||
}
|
||||
if activity == 0 {
|
||||
t.Fatal("OnActivity never called during body transfer")
|
||||
}
|
||||
}
|
||||
|
||||
// Требует два ящика на greenmail. Первый запуск копирует N, второй — 0 (все skipped).
|
||||
func TestCopyFolderIdempotent(t *testing.T) {
|
||||
ep := testEP(t) // plain greenmail
|
||||
|
||||
Reference in New Issue
Block a user