File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,8 +95,9 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
9595 t .Cleanup (Shutdown )
9696
9797 var (
98- isDone atomic.Bool
99- wg sync.WaitGroup
98+ isDone atomic.Bool
99+ wg sync.WaitGroup
100+ transitionsWG sync.WaitGroup
100101 )
101102
102103 numThreads := 10
@@ -122,8 +123,10 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
122123
123124 // try all possible permutations of transition, transition every ms
124125 transitions := allPossibleTransitions (worker1Path , worker2Path )
126+ transitionsWG .Add (numThreads )
125127 for i := range numThreads {
126128 go func (thread * phpThread , start int ) {
129+ defer transitionsWG .Done ()
127130 for {
128131 for j := start ; j < len (transitions ); j ++ {
129132 if isDone .Load () {
@@ -158,6 +161,9 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
158161 // we are finished as soon as all 1000 requests are done
159162 wg .Wait ()
160163 isDone .Store (true )
164+ // wait for transition goroutines to exit before Shutdown to avoid them
165+ // racing with a subsequent test's initPHPThreads via mainThread.state
166+ transitionsWG .Wait ()
161167}
162168
163169func TestFinishBootingAWorkerScript (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments