2022-01-13 14:26:07 +08:00
|
|
|
package features
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2023-02-27 14:44:16 +08:00
|
|
|
"github.com/onsi/ginkgo/v2"
|
2022-01-13 14:26:07 +08:00
|
|
|
|
2022-08-29 01:02:53 +08:00
|
|
|
"github.com/fatedier/frp/test/e2e/framework"
|
2022-01-13 14:26:07 +08:00
|
|
|
)
|
|
|
|
|
2022-08-29 01:02:53 +08:00
|
|
|
var _ = ginkgo.Describe("[Feature: Heartbeat]", func() {
|
2022-01-13 14:26:07 +08:00
|
|
|
f := framework.NewDefaultFramework()
|
|
|
|
|
2022-08-29 01:02:53 +08:00
|
|
|
ginkgo.It("disable application layer heartbeat", func() {
|
2022-01-13 14:26:07 +08:00
|
|
|
serverPort := f.AllocPort()
|
|
|
|
serverConf := fmt.Sprintf(`
|
2023-09-13 16:32:39 +08:00
|
|
|
bindAddr = "0.0.0.0"
|
|
|
|
bindPort = %d
|
|
|
|
transport.heartbeatTimeout = -1
|
|
|
|
transport.tcpMuxKeepaliveInterval = 2
|
2022-01-13 14:26:07 +08:00
|
|
|
`, serverPort)
|
|
|
|
|
|
|
|
remotePort := f.AllocPort()
|
|
|
|
clientConf := fmt.Sprintf(`
|
2023-09-13 16:32:39 +08:00
|
|
|
serverPort = %d
|
|
|
|
log.level = "trace"
|
|
|
|
transport.heartbeatInterval = -1
|
|
|
|
transport.heartbeatTimeout = -1
|
|
|
|
transport.tcpMuxKeepaliveInterval = 2
|
|
|
|
|
|
|
|
[[proxies]]
|
|
|
|
name = "tcp"
|
|
|
|
type = "tcp"
|
|
|
|
localPort = %d
|
|
|
|
remotePort = %d
|
2022-01-13 14:26:07 +08:00
|
|
|
`, serverPort, f.PortByName(framework.TCPEchoServerPort), remotePort)
|
|
|
|
|
|
|
|
// run frps and frpc
|
|
|
|
f.RunProcesses([]string{serverConf}, []string{clientConf})
|
|
|
|
|
|
|
|
framework.NewRequestExpect(f).Protocol("tcp").Port(remotePort).Ensure()
|
|
|
|
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
framework.NewRequestExpect(f).Protocol("tcp").Port(remotePort).Ensure()
|
|
|
|
})
|
|
|
|
})
|