more e2e tests (#1845)

This commit is contained in:
fatedier
2020-09-07 14:57:23 +08:00
committed by GitHub
parent 268afb3438
commit c9fe23eb10
21 changed files with 617 additions and 51 deletions

View File

@ -6,8 +6,46 @@ import (
"github.com/fatedier/frp/test/e2e/pkg/request"
)
func ExpectTCPReuqest(port int, in, out []byte, timeout time.Duration) {
res, err := request.SendTCPRequest(port, in, timeout)
ExpectNoError(err)
ExpectEqual(string(out), res)
func ExpectRequest(protocol string, port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
switch protocol {
case "tcp":
ExpectTCPRequest(port, in, out, timeout, explain...)
case "udp":
ExpectUDPRequest(port, in, out, timeout, explain...)
default:
Failf("ExpectRequest not support protocol: %s", protocol)
}
}
func ExpectRequestError(protocol string, port int, in []byte, timeout time.Duration, explain ...interface{}) {
switch protocol {
case "tcp":
ExpectTCPRequestError(port, in, timeout, explain...)
case "udp":
ExpectUDPRequestError(port, in, timeout, explain...)
default:
Failf("ExpectRequestError not support protocol: %s", protocol)
}
}
func ExpectTCPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
res, err := request.SendTCPRequest(port, in, timeout)
ExpectNoError(err, explain...)
ExpectEqual(string(out), res, explain...)
}
func ExpectTCPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
_, err := request.SendTCPRequest(port, in, timeout)
ExpectError(err, explain...)
}
func ExpectUDPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
res, err := request.SendUDPRequest(port, in, timeout)
ExpectNoError(err, explain...)
ExpectEqual(string(out), res, explain...)
}
func ExpectUDPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
_, err := request.SendUDPRequest(port, in, timeout)
ExpectError(err, explain...)
}