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

Function TestTracker_Concurrent

pkg/tools/lifecycle/state_test.go:127–146  ·  view source on GitHub ↗

TestTracker_Concurrent ensures the tracker is safe for concurrent use (smoke test under the race detector). It does not verify ordering.

(t *testing.T)

Source from the content-addressed store, hash-verified

125// TestTracker_Concurrent ensures the tracker is safe for concurrent use
126// (smoke test under the race detector). It does not verify ordering.
127func TestTracker_Concurrent(t *testing.T) {
128 t.Parallel()
129
130 tr := lifecycle.NewTracker()
131 const n = 100
132 done := make(chan struct{})
133 for range n {
134 go func() {
135 tr.Set(lifecycle.StateStarting)
136 tr.Set(lifecycle.StateReady)
137 tr.Fail(lifecycle.StateRestarting, errors.New("boom"))
138 tr.IncRestarts()
139 _ = tr.Snapshot()
140 done <- struct{}{}
141 }()
142 }
143 for range n {
144 <-done
145 }
146}
147
148// TestErrors_AreDistinct ensures sentinels do not alias each other,
149// guarding against accidental var x = y refactors.

Callers

nothing calls this directly

Calls 6

SetMethod · 0.95
FailMethod · 0.95
IncRestartsMethod · 0.95
SnapshotMethod · 0.95
NewTrackerFunction · 0.92
NewMethod · 0.45

Tested by

no test coverage detected