MCPcopy
hub / github.com/docker/docker-agent / TestModelOverride_ConcurrentAccess

Function TestModelOverride_ConcurrentAccess

pkg/agent/agent_test.go:532–564  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

530}
531
532func TestModelOverride_ConcurrentAccess(t *testing.T) {
533 t.Parallel()
534
535 defaultModel := &mockProvider{id: modelsdev.NewID("default", "x")}
536 overrideModel := &mockProvider{id: modelsdev.NewID("override", "x")}
537
538 a := New("root", "test", WithModel(defaultModel))
539
540 // Run concurrent reads and writes
541 done := make(chan bool)
542
543 // Writer goroutine
544 go func() {
545 for range 100 {
546 a.SetModelOverride(overrideModel)
547 a.SetModelOverride(nil)
548 }
549 done <- true
550 }()
551
552 // Reader goroutine
553 go func() {
554 for range 100 {
555 _ = a.Model(t.Context())
556 _ = a.HasModelOverride()
557 }
558 done <- true
559 }()
560
561 <-done
562 <-done
563 // If we got here without a race condition panic, the test passes
564}
565
566// TestAgentReProbeRecoveryDoesNotEmitNotice verifies the full retry
567// lifecycle: turn 1 fails → warning emitted; turn 2 succeeds → tools

Callers

nothing calls this directly

Calls 7

NewIDFunction · 0.92
SetModelOverrideMethod · 0.80
ModelMethod · 0.80
ContextMethod · 0.80
HasModelOverrideMethod · 0.80
NewFunction · 0.70
WithModelFunction · 0.70

Tested by

no test coverage detected