Test a fetch whose context ends waiting for a shared connection
check / check (push) Successful in 9m30s
check / check (push) Successful in 9m30s
A fetch from a host with nothing open waits for the connection shared by all hosts, and its context ends long before the wait timeout; once every response is closed, no semaphore may be left in hostSems. Model: opus-5-5
This commit is contained in:
@@ -153,9 +153,11 @@ func TestFetchRemovesIdleHostSemaphores(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestFetchRemovesHostSemaphoreWhenNoConnection checks that a fetch that
|
// TestFetchRemovesHostSemaphoreWhenNoConnection checks that a fetch that
|
||||||
// ends without a connection leaves no semaphore behind, both when it is
|
// ends without a connection leaves no semaphore behind: when it is refused
|
||||||
// refused after waiting for a connection shared by all hosts and when its
|
// after waiting for a connection shared by all hosts, when its context ends
|
||||||
// context ends while it waits for its host's slot.
|
// while it waits for its host's slot, and when its context ends while it
|
||||||
|
// waits for a connection shared by all hosts, long before the 10 second
|
||||||
|
// wait timeout.
|
||||||
func TestFetchRemovesHostSemaphoreWhenNoConnection(t *testing.T) {
|
func TestFetchRemovesHostSemaphoreWhenNoConnection(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@@ -188,6 +190,18 @@ func TestFetchRemovesHostSemaphoreWhenNoConnection(t *testing.T) {
|
|||||||
"want context.DeadlineExceeded", err)
|
"want context.DeadlineExceeded", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Back to the 10 second wait, so the next fetch's context ends first.
|
||||||
|
f.connectionWaitTimeout = ConnectionWaitTimeout
|
||||||
|
|
||||||
|
ctx, cancel = context.WithTimeout(t.Context(), 100*time.Millisecond)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, err = f.Fetch(ctx, imageURLOnPort(83))
|
||||||
|
if !errors.Is(err, context.DeadlineExceeded) {
|
||||||
|
t.Fatalf("Fetch() from a host with nothing open: error = %v, "+
|
||||||
|
"want context.DeadlineExceeded", err)
|
||||||
|
}
|
||||||
|
|
||||||
err = open.Content.Close()
|
err = open.Content.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("close first body: %v", err)
|
t.Fatalf("close first body: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user