MCPcopy Index your code
hub / github.com/php/frankenphp / TestTransitionAThreadBetween2DifferentWorkers

Function TestTransitionAThreadBetween2DifferentWorkers

phpmainthread_test.go:66–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestTransitionAThreadBetween2DifferentWorkers(t *testing.T) {
67 setupGlobals(t)
68
69 _, err := initPHPThreads(1, 1, nil)
70 assert.NoError(t, err)
71 firstWorker := getDummyWorker(t, "transition-worker-1.php")
72 secondWorker := getDummyWorker(t, "transition-worker-2.php")
73
74 // convert to first worker thread
75 convertToWorkerThread(phpThreads[0], firstWorker)
76 firstHandler := phpThreads[0].handler.(*workerThread)
77 assert.Same(t, firstWorker, firstHandler.worker)
78 assert.Len(t, firstWorker.threads, 1)
79 assert.Len(t, secondWorker.threads, 0)
80
81 // convert to second worker thread
82 convertToWorkerThread(phpThreads[0], secondWorker)
83 secondHandler := phpThreads[0].handler.(*workerThread)
84 assert.Same(t, secondWorker, secondHandler.worker)
85 assert.Len(t, firstWorker.threads, 0)
86 assert.Len(t, secondWorker.threads, 1)
87
88 drainPHPThreads()
89 assert.Nil(t, phpThreads)
90}
91
92// try all possible handler transitions
93// takes around 200ms and is supposed to force race conditions

Callers

nothing calls this directly

Calls 5

setupGlobalsFunction · 0.85
initPHPThreadsFunction · 0.85
getDummyWorkerFunction · 0.85
convertToWorkerThreadFunction · 0.85
drainPHPThreadsFunction · 0.85

Tested by

no test coverage detected