Document and demonstrate execution controls
This commit is contained in:
@@ -79,3 +79,22 @@ func TestPreparedExecutionRespectsCallerDeadline(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestPreparedExecutionDoesNotTimePreparation(t *testing.T) {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
release := make(chan struct{})
|
||||
reader := &capacityArtifactReader{entered: make(chan struct{}, 1), release: release}
|
||||
engine := newBackendCapacityEngine(t, newCapacityGateClient(closedCapacityChannel(), 1), 1, capacityInt(0), reader)
|
||||
req := capacityInputRequest("http://example.invalid/v1")
|
||||
req.OperationTimeout = time.Second
|
||||
go func() { time.Sleep(2 * time.Second); close(release) }()
|
||||
start := time.Now()
|
||||
handle, err := engine.PrepareExecution(context.Background(), req)
|
||||
if err != nil || time.Since(start) != 2*time.Second {
|
||||
t.Fatalf("prepare elapsed=%v error=%v", time.Since(start), err)
|
||||
}
|
||||
if _, err = engine.RunPrepared(context.Background(), handle); err != nil {
|
||||
t.Fatalf("execution after preparation: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user