Test the 503 for a request waiting on a transcode stopped at a deadline
check / check (push) Waiting to run
check / check (push) Waiting to run
A request that waited for another request's transcode, stopped at that request's deadline, must get ErrProcessingTimedOut, which both image routes answer 503. Declares that error so the tests build. Also tests that Process, past its deadline before it starts, never reads its input. Model: opus-5-5
This commit is contained in:
@@ -88,3 +88,31 @@ func checkProcessStopsAtDeadline(
|
||||
t.Errorf("%d slots still held after Process() returned", held)
|
||||
}
|
||||
}
|
||||
|
||||
// inputNotToBeRead is a Process input that fails the test when it is read.
|
||||
type inputNotToBeRead struct {
|
||||
t *testing.T
|
||||
}
|
||||
|
||||
func (r inputNotToBeRead) Read([]byte) (int, error) {
|
||||
r.t.Error("Process read its input although its deadline had passed")
|
||||
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
||||
// TestProcessReadsNoInputOnceDeadlinePassed checks that Process, called with
|
||||
// a context whose deadline passed before it starts, gives its slot back
|
||||
// without reading its input. With a slot free, the select in acquireSlot
|
||||
// takes the slot or sees the ended context at random, so Process is called
|
||||
// many times.
|
||||
func TestProcessReadsNoInputOnceDeadlinePassed(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
ctx, cancel := context.WithDeadline(t.Context(),
|
||||
time.Now().Add(-time.Second))
|
||||
defer cancel()
|
||||
|
||||
for range 100 {
|
||||
checkProcessStopsAtDeadline(ctx, t, inputNotToBeRead{t: t})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user