mirror of https://github.com/fatedier/frp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.7 KiB
65 lines
1.7 KiB
3 years ago
|
package features
|
||
3 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
|
||
2 years ago
|
"github.com/onsi/ginkgo/v2"
|
||
3 years ago
|
|
||
2 years ago
|
"github.com/fatedier/frp/test/e2e/framework"
|
||
3 years ago
|
)
|
||
|
|
||
2 years ago
|
var _ = ginkgo.Describe("[Feature: Chaos]", func() {
|
||
3 years ago
|
f := framework.NewDefaultFramework()
|
||
|
|
||
2 years ago
|
ginkgo.It("reconnect after frps restart", func() {
|
||
3 years ago
|
serverPort := f.AllocPort()
|
||
|
serverConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
|
||
1 year ago
|
bindAddr = "0.0.0.0"
|
||
|
bindPort = %d
|
||
3 years ago
|
`, serverPort))
|
||
|
|
||
|
remotePort := f.AllocPort()
|
||
|
clientConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
|
||
1 year ago
|
serverPort = %d
|
||
|
log.level = "trace"
|
||
|
|
||
|
[[proxies]]
|
||
|
name = "tcp"
|
||
|
type = "tcp"
|
||
|
localPort = %d
|
||
|
remotePort = %d
|
||
3 years ago
|
`, serverPort, f.PortByName(framework.TCPEchoServerPort), remotePort))
|
||
|
|
||
|
// 1. start frps and frpc, expect request success
|
||
|
ps, _, err := f.RunFrps("-c", serverConfigPath)
|
||
|
framework.ExpectNoError(err)
|
||
|
|
||
|
pc, _, err := f.RunFrpc("-c", clientConfigPath)
|
||
|
framework.ExpectNoError(err)
|
||
|
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||
|
|
||
|
// 2. stop frps, expect request failed
|
||
2 years ago
|
_ = ps.Stop()
|
||
3 years ago
|
time.Sleep(200 * time.Millisecond)
|
||
|
framework.NewRequestExpect(f).Port(remotePort).ExpectError(true).Ensure()
|
||
|
|
||
|
// 3. restart frps, expect request success
|
||
|
_, _, err = f.RunFrps("-c", serverConfigPath)
|
||
|
framework.ExpectNoError(err)
|
||
|
time.Sleep(2 * time.Second)
|
||
|
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||
|
|
||
|
// 4. stop frpc, expect request failed
|
||
2 years ago
|
_ = pc.Stop()
|
||
3 years ago
|
time.Sleep(200 * time.Millisecond)
|
||
|
framework.NewRequestExpect(f).Port(remotePort).ExpectError(true).Ensure()
|
||
|
|
||
|
// 5. restart frpc, expect request success
|
||
|
_, _, err = f.RunFrpc("-c", clientConfigPath)
|
||
|
framework.ExpectNoError(err)
|
||
|
time.Sleep(time.Second)
|
||
|
framework.NewRequestExpect(f).Port(remotePort).Ensure()
|
||
|
})
|
||
|
})
|