mirror of
https://github.com/fatedier/frp.git
synced 2026-04-05 08:39:17 +08:00
test/e2e: optimize e2e test time by replacing sleeps with TCP readiness checks (#5223)
Replace the fixed 500ms sleep after each frps startup in RunProcesses with a TCP dial-based readiness check that polls the server bind port. This reduces the e2e suite wall time from ~97s to ~43s. Also simplify the RunProcesses API to accept a single server template string instead of a slice, matching how every call site uses it.
This commit is contained in:
@@ -3,6 +3,8 @@ package features
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
@@ -25,7 +27,8 @@ var _ = ginkgo.Describe("[Feature: SSH Tunnel]", func() {
|
||||
sshTunnelGateway.bindPort = %d
|
||||
`, sshPort)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, nil)
|
||||
f.RunProcesses(serverConf, nil)
|
||||
framework.ExpectNoError(framework.WaitForTCPReady(net.JoinHostPort("127.0.0.1", strconv.Itoa(sshPort)), 5*time.Second))
|
||||
|
||||
localPort := f.PortByName(framework.TCPEchoServerPort)
|
||||
remotePort := f.AllocPort()
|
||||
@@ -49,7 +52,8 @@ var _ = ginkgo.Describe("[Feature: SSH Tunnel]", func() {
|
||||
sshTunnelGateway.bindPort = %d
|
||||
`, vhostPort, sshPort)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, nil)
|
||||
f.RunProcesses(serverConf, nil)
|
||||
framework.ExpectNoError(framework.WaitForTCPReady(net.JoinHostPort("127.0.0.1", strconv.Itoa(sshPort)), 5*time.Second))
|
||||
|
||||
localPort := f.PortByName(framework.HTTPSimpleServerPort)
|
||||
tc := ssh.NewTunnelClient(
|
||||
@@ -76,7 +80,8 @@ var _ = ginkgo.Describe("[Feature: SSH Tunnel]", func() {
|
||||
sshTunnelGateway.bindPort = %d
|
||||
`, vhostPort, sshPort)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, nil)
|
||||
f.RunProcesses(serverConf, nil)
|
||||
framework.ExpectNoError(framework.WaitForTCPReady(net.JoinHostPort("127.0.0.1", strconv.Itoa(sshPort)), 5*time.Second))
|
||||
|
||||
localPort := f.AllocPort()
|
||||
testDomain := "test.example.com"
|
||||
@@ -118,7 +123,8 @@ var _ = ginkgo.Describe("[Feature: SSH Tunnel]", func() {
|
||||
sshTunnelGateway.bindPort = %d
|
||||
`, tcpmuxPort, sshPort)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, nil)
|
||||
f.RunProcesses(serverConf, nil)
|
||||
framework.ExpectNoError(framework.WaitForTCPReady(net.JoinHostPort("127.0.0.1", strconv.Itoa(sshPort)), 5*time.Second))
|
||||
|
||||
localPort := f.AllocPort()
|
||||
testDomain := "test.example.com"
|
||||
@@ -173,7 +179,8 @@ var _ = ginkgo.Describe("[Feature: SSH Tunnel]", func() {
|
||||
bindPort = %d
|
||||
`, bindPort)
|
||||
|
||||
f.RunProcesses([]string{serverConf}, []string{visitorConf})
|
||||
f.RunProcesses(serverConf, []string{visitorConf})
|
||||
framework.ExpectNoError(framework.WaitForTCPReady(net.JoinHostPort("127.0.0.1", strconv.Itoa(sshPort)), 5*time.Second))
|
||||
|
||||
localPort := f.PortByName(framework.TCPEchoServerPort)
|
||||
tc := ssh.NewTunnelClient(
|
||||
|
||||
Reference in New Issue
Block a user