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

Function TestScaleAWorkerThreadUpAndDown

scaling_test.go:33–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestScaleAWorkerThreadUpAndDown(t *testing.T) {
34 t.Cleanup(Shutdown)
35
36 workerName := "worker1"
37 workerPath := filepath.Join(testDataPath, "transition-worker-1.php")
38 assert.NoError(t, Init(
39 WithNumThreads(2),
40 WithMaxThreads(3),
41 WithWorkers(workerName, workerPath, 1,
42 WithWorkerEnv(map[string]string{}),
43 WithWorkerWatchMode([]string{}),
44 WithWorkerMaxFailures(0),
45 ),
46 ))
47
48 autoScaledThread := phpThreads[2]
49
50 // scale up
51 scaleWorkerThread(workersByPath[workerPath], mainThread.done, mainThread.state)
52 assert.Equal(t, state.Ready, autoScaledThread.state.Get())
53
54 // on down-scale, the thread will be marked as inactive
55 setLongWaitTime(t, autoScaledThread)
56 deactivateThreads()
57 assert.IsType(t, &inactiveThread{}, autoScaledThread.handler)
58}
59
60func TestMaxIdleTimePreventsEarlyDeactivation(t *testing.T) {
61 t.Cleanup(Shutdown)

Callers

nothing calls this directly

Calls 11

InitFunction · 0.85
WithNumThreadsFunction · 0.85
WithMaxThreadsFunction · 0.85
WithWorkersFunction · 0.85
WithWorkerEnvFunction · 0.85
WithWorkerWatchModeFunction · 0.85
WithWorkerMaxFailuresFunction · 0.85
scaleWorkerThreadFunction · 0.85
setLongWaitTimeFunction · 0.85
deactivateThreadsFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected