mirror of https://github.com/gofiber/fiber.git
🩹 Fix Prefork Test
parent
d66d6a9cd5
commit
9275592a51
12
prefork.go
12
prefork.go
|
@ -21,7 +21,7 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testPreforkMaster = false
|
testPreforkMaster = false
|
||||||
dummyChildCmd = "date"
|
dummyChildCmd = "go"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsChild determines if the current process is a result of Prefork
|
// IsChild determines if the current process is a result of Prefork
|
||||||
|
@ -89,11 +89,11 @@ func (app *App) prefork(addr string, tlsconfig ...*tls.Config) (err error) {
|
||||||
// When test prefork master,
|
// When test prefork master,
|
||||||
// just start the child process
|
// just start the child process
|
||||||
// a cmd on all os is best
|
// a cmd on all os is best
|
||||||
// if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
// cmd = exec.Command("cmd", "/C", dummyChildCmd)
|
cmd = exec.Command("cmd", "/C", dummyChildCmd, "version")
|
||||||
// } else {
|
} else {
|
||||||
// cmd = exec.Command(dummyChildCmd)
|
cmd = exec.Command(dummyChildCmd, "version")
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
|
@ -1,40 +1,48 @@
|
||||||
package fiber
|
package fiber
|
||||||
|
|
||||||
// func Test_App_Prefork_Child_Process(t *testing.T) {
|
import (
|
||||||
// utils.AssertEqual(t, nil, os.Setenv(envPreforkChildKey, envPreforkChildVal))
|
"os"
|
||||||
// defer os.Setenv(envPreforkChildKey, "")
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
// app := New()
|
utils "github.com/gofiber/utils"
|
||||||
// app.Settings.DisableStartupMessage = true
|
)
|
||||||
// app.init()
|
|
||||||
|
|
||||||
// err := app.prefork("invalid")
|
func Test_App_Prefork_Child_Process(t *testing.T) {
|
||||||
// utils.AssertEqual(t, false, err == nil)
|
utils.AssertEqual(t, nil, os.Setenv(envPreforkChildKey, envPreforkChildVal))
|
||||||
|
defer os.Setenv(envPreforkChildKey, "")
|
||||||
|
|
||||||
// go func() {
|
app := New()
|
||||||
// time.Sleep(1000 * time.Millisecond)
|
app.Settings.DisableStartupMessage = true
|
||||||
// utils.AssertEqual(t, nil, app.Shutdown())
|
app.init()
|
||||||
// }()
|
|
||||||
|
|
||||||
// utils.AssertEqual(t, nil, app.prefork("127.0.0.1:"))
|
err := app.prefork("invalid")
|
||||||
// }
|
utils.AssertEqual(t, false, err == nil)
|
||||||
|
|
||||||
// func Test_App_Prefork_Main_Process(t *testing.T) {
|
go func() {
|
||||||
// testPreforkMaster = true
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
utils.AssertEqual(t, nil, app.Shutdown())
|
||||||
|
}()
|
||||||
|
|
||||||
// app := New()
|
utils.AssertEqual(t, nil, app.prefork("127.0.0.1:"))
|
||||||
// app.Settings.DisableStartupMessage = true
|
}
|
||||||
// app.init()
|
|
||||||
|
|
||||||
// go func() {
|
func Test_App_Prefork_Main_Process(t *testing.T) {
|
||||||
// time.Sleep(1000 * time.Millisecond)
|
testPreforkMaster = true
|
||||||
// utils.AssertEqual(t, nil, app.Shutdown())
|
|
||||||
// }()
|
|
||||||
|
|
||||||
// utils.AssertEqual(t, nil, app.prefork("127.0.0.1:"))
|
app := New()
|
||||||
|
app.Settings.DisableStartupMessage = true
|
||||||
|
app.init()
|
||||||
|
|
||||||
// dummyChildCmd = "invalid"
|
go func() {
|
||||||
|
time.Sleep(1000 * time.Millisecond)
|
||||||
|
utils.AssertEqual(t, nil, app.Shutdown())
|
||||||
|
}()
|
||||||
|
|
||||||
// err := app.prefork("127.0.0.1:")
|
utils.AssertEqual(t, nil, app.prefork("127.0.0.1:"))
|
||||||
// utils.AssertEqual(t, false, err == nil)
|
|
||||||
// }
|
dummyChildCmd = "invalid"
|
||||||
|
|
||||||
|
err := app.prefork("127.0.0.1:")
|
||||||
|
utils.AssertEqual(t, false, err == nil)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue