Retain cancellation at the final readiness handoff
This commit is contained in:
@@ -39,10 +39,14 @@ func RunSmokeChecksObserved(ctx context.Context, engine *promptkit.Engine, targe
|
||||
observation := SmokeObservation{Kind: kind, ProfileID: profile, BackendID: backend, Bindings: bindings, Report: report}
|
||||
observation.Applicable, observation.Err = evaluateSmoke(kind, report, err)
|
||||
observations = append(observations, observation)
|
||||
operationErr := observation.Err
|
||||
if observe != nil {
|
||||
return errors.Join(observation.Err, observe(observation))
|
||||
operationErr = errors.Join(operationErr, observe(observation))
|
||||
}
|
||||
return observation.Err
|
||||
if ctxErr := ctx.Err(); ctxErr != nil && !errors.Is(operationErr, ctxErr) {
|
||||
operationErr = errors.Join(operationErr, ctxErr)
|
||||
}
|
||||
return operationErr
|
||||
}
|
||||
for _, target := range targets.Access {
|
||||
for _, kind := range []promptkit.SmokeTestKind{promptkit.SmokeTestReachability, promptkit.SmokeTestAuthentication} {
|
||||
|
||||
@@ -136,3 +136,17 @@ func TestSmokeRetainsTerminalObserverAndDiagnosticErrors(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSmokeRetainsCancellationDuringTerminalObservation(t *testing.T) {
|
||||
input := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("smoke", map[string]any{"profiles": []any{map[string]any{"id": "profile", "endpoint": "http://example.invalid/v1", "model": "fixture"}}})}
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &input}}, promptkit.WithBundledOpenRouter(false), promptkit.WithLLMClient(smokeResultClient{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
observations, err := RunSmokeChecksObserved(ctx, engine, Targets{Profiles: []ProfileTarget{{ID: "profile"}}}, nil, nil, func(SmokeObservation) error { cancel(); return nil })
|
||||
if !errors.Is(err, context.Canceled) || len(observations) != 1 || observations[0].Err != nil {
|
||||
t.Fatalf("observations=%+v error=%v", observations, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user