feat(agent): 完成 HTTPS 自动端口、证书轮换与防火墙辅助并发布 v1.5.0
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAgentTunnelBindsLoopbackAndReleasesPort(t *testing.T) {
|
||||
@@ -23,8 +24,8 @@ func TestAgentTunnelBindsLoopbackAndReleasesPort(t *testing.T) {
|
||||
t.Fatal("隧道启动后本地端口应已被占用")
|
||||
}
|
||||
state, _ := tunnel.State()
|
||||
if state != "connected" {
|
||||
t.Fatalf("state=%q, want connected", state)
|
||||
if state != "connected" && state != "reconnecting" {
|
||||
t.Fatalf("state=%q, want connected 或 reconnecting", state)
|
||||
}
|
||||
tunnel.Stop()
|
||||
if listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", port)); err != nil {
|
||||
@@ -33,3 +34,20 @@ func TestAgentTunnelBindsLoopbackAndReleasesPort(t *testing.T) {
|
||||
_ = listener.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextTunnelBackoff(t *testing.T) {
|
||||
cases := []struct {
|
||||
in time.Duration
|
||||
want time.Duration
|
||||
}{
|
||||
{0, agentTunnelBackoffMin},
|
||||
{time.Second, 2 * time.Second},
|
||||
{40 * time.Second, agentTunnelBackoffMax},
|
||||
{agentTunnelBackoffMax, agentTunnelBackoffMax},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := nextTunnelBackoff(tc.in); got != tc.want {
|
||||
t.Fatalf("nextTunnelBackoff(%v) = %v, 期望 %v", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user