MCPcopy
hub / github.com/gofiber/fiber / Test_App_Prefork_Master_Process

Function Test_App_Prefork_Master_Process

prefork_test.go:56–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func Test_App_Prefork_Master_Process(t *testing.T) {
57 enableTestPreforkMaster(t)
58
59 app := New()
60
61 // With dummy commands that exit immediately, fasthttp recovers children
62 // until RecoverThreshold is exceeded, then returns ErrOverRecovery.
63 // Use low threshold for fast test execution.
64 cfg := listenConfigDefault()
65 cfg.PreforkRecoverThreshold = 1
66 cfg.PreforkRecoverInterval = 10 * time.Millisecond
67 cfg.PreforkShutdownGracePeriod = 100 * time.Millisecond
68 err := app.prefork(":0", nil, &cfg)
69 require.ErrorIs(t, err, prefork.ErrOverRecovery)
70
71 // With invalid command, should get a start error immediately
72 // (error happens during initial spawning, before recovery loop)
73 dummyChildCmd.Store("invalid")
74
75 cfg = listenConfigDefault()
76 cfg.PreforkRecoverThreshold = 1
77 err = app.prefork("127.0.0.1:", nil, &cfg)
78 require.Error(t, err)
79
80 dummyChildCmd.Store("go")
81}
82
83func Test_App_Prefork_Child_Process_Never_Show_Startup_Message(t *testing.T) {
84 setupIsChild(t)

Callers

nothing calls this directly

Calls 6

enableTestPreforkMasterFunction · 0.85
listenConfigDefaultFunction · 0.85
preforkMethod · 0.80
StoreMethod · 0.80
NewFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected