(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func 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 | |
| 60 | func TestMaxIdleTimePreventsEarlyDeactivation(t *testing.T) { |
| 61 | t.Cleanup(Shutdown) |
nothing calls this directly
no test coverage detected