mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-09 14:08:03 -05:00
fix(docker cmd): fix bug in docker cmd (#364)
This commit is contained in:
@@ -75,36 +75,36 @@ func free(t *testing.T) {
|
||||
}
|
||||
|
||||
type appAPI interface {
|
||||
WaitResult(timeout time.Duration, keyword string) bool
|
||||
WaitResult(t *testing.T, timeout time.Duration, keyword string) bool
|
||||
RunApp(waitResult func() bool)
|
||||
WaitExit()
|
||||
ExpectWithTimeout(parallel bool, timeout time.Duration, keyword string)
|
||||
ExpectWithTimeout(t *testing.T, parallel bool, timeout time.Duration, keyword string)
|
||||
}
|
||||
|
||||
func runBridgeApp(t *testing.T, args ...string) appAPI {
|
||||
args = append(args, "--log.debug", "--config", bridgeFile)
|
||||
return cmd.NewCmd(t, "bridge-test", args...)
|
||||
return cmd.NewCmd("bridge-test", args...)
|
||||
}
|
||||
|
||||
func runCoordinatorApp(t *testing.T, args ...string) appAPI {
|
||||
args = append(args, "--log.debug", "--config", coordinatorFile, "--ws", "--ws.port", strconv.Itoa(int(wsPort)))
|
||||
// start process
|
||||
return cmd.NewCmd(t, "coordinator-test", args...)
|
||||
return cmd.NewCmd("coordinator-test", args...)
|
||||
}
|
||||
|
||||
func runDBCliApp(t *testing.T, option, keyword string) {
|
||||
args := []string{option, "--config", dbFile}
|
||||
app := cmd.NewCmd(t, "db_cli-test", args...)
|
||||
app := cmd.NewCmd("db_cli-test", args...)
|
||||
defer app.WaitExit()
|
||||
|
||||
// Wait expect result.
|
||||
app.ExpectWithTimeout(true, time.Second*3, keyword)
|
||||
app.ExpectWithTimeout(t, true, time.Second*3, keyword)
|
||||
app.RunApp(nil)
|
||||
}
|
||||
|
||||
func runRollerApp(t *testing.T, args ...string) appAPI {
|
||||
args = append(args, "--log.debug", "--config", rollerFile)
|
||||
return cmd.NewCmd(t, "roller-test", args...)
|
||||
return cmd.NewCmd("roller-test", args...)
|
||||
}
|
||||
|
||||
func runSender(t *testing.T, endpoint string) *sender.Sender {
|
||||
|
||||
@@ -42,16 +42,16 @@ func testStartProcess(t *testing.T) {
|
||||
|
||||
// Start bridge process.
|
||||
bridgeCmd := runBridgeApp(t)
|
||||
bridgeCmd.RunApp(func() bool { return bridgeCmd.WaitResult(time.Second*20, "Start bridge successfully") })
|
||||
bridgeCmd.RunApp(func() bool { return bridgeCmd.WaitResult(t, time.Second*20, "Start bridge successfully") })
|
||||
|
||||
// Start coordinator process.
|
||||
coordinatorCmd := runCoordinatorApp(t, "--ws", "--ws.port", "8391")
|
||||
coordinatorCmd.RunApp(func() bool { return coordinatorCmd.WaitResult(time.Second*20, "Start coordinator successfully") })
|
||||
coordinatorCmd.RunApp(func() bool { return coordinatorCmd.WaitResult(t, time.Second*20, "Start coordinator successfully") })
|
||||
|
||||
// Start roller process.
|
||||
rollerCmd := runRollerApp(t)
|
||||
rollerCmd.ExpectWithTimeout(true, time.Second*60, "register to coordinator successfully!")
|
||||
rollerCmd.RunApp(func() bool { return rollerCmd.WaitResult(time.Second*40, "roller start successfully") })
|
||||
rollerCmd.ExpectWithTimeout(t, true, time.Second*60, "register to coordinator successfully!")
|
||||
rollerCmd.RunApp(func() bool { return rollerCmd.WaitResult(t, time.Second*40, "roller start successfully") })
|
||||
|
||||
rollerCmd.WaitExit()
|
||||
bridgeCmd.WaitExit()
|
||||
@@ -67,7 +67,7 @@ func testMonitorMetrics(t *testing.T) {
|
||||
port, _ := rand.Int(rand.Reader, big.NewInt(2000))
|
||||
svrPort := strconv.FormatInt(port.Int64()+50000, 10)
|
||||
bridgeCmd := runBridgeApp(t, "--metrics", "--metrics.addr", "localhost", "--metrics.port", svrPort)
|
||||
bridgeCmd.RunApp(func() bool { return bridgeCmd.WaitResult(time.Second*20, "Start bridge successfully") })
|
||||
bridgeCmd.RunApp(func() bool { return bridgeCmd.WaitResult(t, time.Second*20, "Start bridge successfully") })
|
||||
|
||||
// Get monitor metrics.
|
||||
resp, err := http.Get("http://localhost:" + svrPort)
|
||||
|
||||
Reference in New Issue
Block a user