xtcp.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package basic
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/onsi/ginkgo/v2"
  6. "github.com/fatedier/frp/test/e2e/framework"
  7. "github.com/fatedier/frp/test/e2e/framework/consts"
  8. "github.com/fatedier/frp/test/e2e/pkg/port"
  9. "github.com/fatedier/frp/test/e2e/pkg/request"
  10. )
  11. var _ = ginkgo.Describe("[Feature: XTCP]", func() {
  12. f := framework.NewDefaultFramework()
  13. ginkgo.It("Fallback To STCP", func() {
  14. serverConf := consts.LegacyDefaultServerConfig
  15. clientConf := consts.LegacyDefaultClientConfig
  16. bindPortName := port.GenName("XTCP")
  17. clientConf += fmt.Sprintf(`
  18. [foo]
  19. type = stcp
  20. local_port = {{ .%s }}
  21. [foo-visitor]
  22. type = stcp
  23. role = visitor
  24. server_name = foo
  25. bind_port = -1
  26. [bar-visitor]
  27. type = xtcp
  28. role = visitor
  29. server_name = bar
  30. bind_port = {{ .%s }}
  31. keep_tunnel_open = true
  32. fallback_to = foo-visitor
  33. fallback_timeout_ms = 200
  34. `, framework.TCPEchoServerPort, bindPortName)
  35. f.RunProcesses([]string{serverConf}, []string{clientConf})
  36. framework.NewRequestExpect(f).
  37. RequestModify(func(r *request.Request) {
  38. r.Timeout(time.Second)
  39. }).
  40. PortName(bindPortName).
  41. Ensure()
  42. })
  43. })