feat: complete cmpp gateway delivery recovery workflows
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package upstream
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHandleConnectionLossNotifiesPendingSubmitters(t *testing.T) {
|
||||
conn := &connection{
|
||||
pending: make(map[uint32]chan submitPartResponse),
|
||||
}
|
||||
waiter := make(chan submitPartResponse, 1)
|
||||
conn.pending[7] = waiter
|
||||
|
||||
loss := errors.New("socket closed")
|
||||
conn.handleConnectionLoss(loss)
|
||||
|
||||
select {
|
||||
case result := <-waiter:
|
||||
if !errors.Is(result.err, loss) {
|
||||
t.Fatalf("pending waiter err = %v, want %v", result.err, loss)
|
||||
}
|
||||
default:
|
||||
t.Fatal("expected pending waiter to be notified")
|
||||
}
|
||||
|
||||
if !conn.closed {
|
||||
t.Fatal("expected connection to be marked closed")
|
||||
}
|
||||
if len(conn.pending) != 0 {
|
||||
t.Fatalf("expected pending map to be reset, got %d entries", len(conn.pending))
|
||||
}
|
||||
}
|
||||
|
||||
func TestTemporaryReadTimeoutDetection(t *testing.T) {
|
||||
if !isTemporaryReadTimeout(fakeNetError{timeout: true}) {
|
||||
t.Fatal("expected timeout error to be treated as temporary")
|
||||
}
|
||||
if isTemporaryReadTimeout(errors.New("eof")) {
|
||||
t.Fatal("did not expect non-timeout error to be treated as temporary")
|
||||
}
|
||||
}
|
||||
|
||||
type fakeNetError struct {
|
||||
timeout bool
|
||||
}
|
||||
|
||||
func (f fakeNetError) Error() string { return "network error" }
|
||||
func (f fakeNetError) Timeout() bool { return f.timeout }
|
||||
func (f fakeNetError) Temporary() bool { return f.timeout }
|
||||
Reference in New Issue
Block a user