lint by golangci-lint (#3080)

This commit is contained in:
fatedier
2022-08-29 01:02:53 +08:00
committed by GitHub
parent f4e4fbea62
commit 9d077b02cf
122 changed files with 947 additions and 1331 deletions

View File

@@ -5,18 +5,18 @@ import (
"strings"
"time"
"github.com/onsi/ginkgo"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
"github.com/fatedier/frp/test/e2e/mock/server/streamserver"
"github.com/fatedier/frp/test/e2e/pkg/request"
. "github.com/onsi/ginkgo"
)
var _ = Describe("[Feature: Bandwidth Limit]", func() {
var _ = ginkgo.Describe("[Feature: Bandwidth Limit]", func() {
f := framework.NewDefaultFramework()
It("Proxy Bandwidth Limit", func() {
ginkgo.It("Proxy Bandwidth Limit", func() {
serverConf := consts.DefaultServerConfig
clientConf := consts.DefaultClientConfig
@@ -40,7 +40,7 @@ var _ = Describe("[Feature: Bandwidth Limit]", func() {
framework.NewRequestExpect(f).Port(remotePort).RequestModify(func(r *request.Request) {
r.Body([]byte(content)).Timeout(30 * time.Second)
}).ExpectResp([]byte(content)).Ensure()
duration := time.Now().Sub(start)
duration := time.Since(start)
framework.ExpectTrue(duration.Seconds() > 7, "100Kb with 10KB limit, want > 7 seconds, but got %d seconds", duration.Seconds())
})

View File

@@ -4,15 +4,15 @@ import (
"fmt"
"time"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo"
"github.com/fatedier/frp/test/e2e/framework"
)
var _ = Describe("[Feature: Chaos]", func() {
var _ = ginkgo.Describe("[Feature: Chaos]", func() {
f := framework.NewDefaultFramework()
It("reconnect after frps restart", func() {
ginkgo.It("reconnect after frps restart", func() {
serverPort := f.AllocPort()
serverConfigPath := f.GenerateConfigFile(fmt.Sprintf(`
[common]
@@ -41,7 +41,7 @@ var _ = Describe("[Feature: Chaos]", func() {
framework.NewRequestExpect(f).Port(remotePort).Ensure()
// 2. stop frps, expect request failed
ps.Stop()
_ = ps.Stop()
time.Sleep(200 * time.Millisecond)
framework.NewRequestExpect(f).Port(remotePort).ExpectError(true).Ensure()
@@ -52,7 +52,7 @@ var _ = Describe("[Feature: Chaos]", func() {
framework.NewRequestExpect(f).Port(remotePort).Ensure()
// 4. stop frpc, expect request failed
pc.Stop()
_ = pc.Stop()
time.Sleep(200 * time.Millisecond)
framework.NewRequestExpect(f).Port(remotePort).ExpectError(true).Ensure()

View File

@@ -6,16 +6,16 @@ import (
"sync"
"time"
"github.com/onsi/ginkgo"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
"github.com/fatedier/frp/test/e2e/mock/server/httpserver"
"github.com/fatedier/frp/test/e2e/mock/server/streamserver"
"github.com/fatedier/frp/test/e2e/pkg/request"
. "github.com/onsi/ginkgo"
)
var _ = Describe("[Feature: Group]", func() {
var _ = ginkgo.Describe("[Feature: Group]", func() {
f := framework.NewDefaultFramework()
newHTTPServer := func(port int, respContent string) *httpserver.Server {
@@ -60,8 +60,8 @@ var _ = Describe("[Feature: Group]", func() {
return results
}
Describe("Load Balancing", func() {
It("TCP", func() {
ginkgo.Describe("Load Balancing", func() {
ginkgo.It("TCP", func() {
serverConf := consts.DefaultServerConfig
clientConf := consts.DefaultClientConfig
@@ -112,8 +112,8 @@ var _ = Describe("[Feature: Group]", func() {
})
})
Describe("Health Check", func() {
It("TCP", func() {
ginkgo.Describe("Health Check", func() {
ginkgo.It("TCP", func() {
serverConf := consts.DefaultServerConfig
clientConf := consts.DefaultClientConfig
@@ -178,7 +178,7 @@ var _ = Describe("[Feature: Group]", func() {
framework.ExpectContainElements(results, []string{"foo", "bar"})
})
It("HTTP", func() {
ginkgo.It("HTTP", func() {
vhostPort := f.AllocPort()
serverConf := consts.DefaultServerConfig + fmt.Sprintf(`
vhost_http_port = %d

View File

@@ -4,15 +4,15 @@ import (
"fmt"
"time"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo"
"github.com/fatedier/frp/test/e2e/framework"
)
var _ = Describe("[Feature: Heartbeat]", func() {
var _ = ginkgo.Describe("[Feature: Heartbeat]", func() {
f := framework.NewDefaultFramework()
It("disable application layer heartbeat", func() {
ginkgo.It("disable application layer heartbeat", func() {
serverPort := f.AllocPort()
serverConf := fmt.Sprintf(`
[common]

View File

@@ -5,18 +5,18 @@ import (
"strings"
"time"
"github.com/onsi/ginkgo"
"github.com/fatedier/frp/pkg/util/log"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
"github.com/fatedier/frp/test/e2e/pkg/request"
. "github.com/onsi/ginkgo"
)
var _ = Describe("[Feature: Monitor]", func() {
var _ = ginkgo.Describe("[Feature: Monitor]", func() {
f := framework.NewDefaultFramework()
It("Prometheus metrics", func() {
ginkgo.It("Prometheus metrics", func() {
dashboardPort := f.AllocPort()
serverConf := consts.DefaultServerConfig + fmt.Sprintf(`
enable_prometheus = true

View File

@@ -6,6 +6,9 @@ import (
"net"
"net/http"
"github.com/onsi/ginkgo"
pp "github.com/pires/go-proxyproto"
"github.com/fatedier/frp/pkg/util/log"
"github.com/fatedier/frp/test/e2e/framework"
"github.com/fatedier/frp/test/e2e/framework/consts"
@@ -13,15 +16,12 @@ import (
"github.com/fatedier/frp/test/e2e/mock/server/streamserver"
"github.com/fatedier/frp/test/e2e/pkg/request"
"github.com/fatedier/frp/test/e2e/pkg/rpc"
. "github.com/onsi/ginkgo"
pp "github.com/pires/go-proxyproto"
)
var _ = Describe("[Feature: Real IP]", func() {
var _ = ginkgo.Describe("[Feature: Real IP]", func() {
f := framework.NewDefaultFramework()
It("HTTP X-Forwarded-For", func() {
ginkgo.It("HTTP X-Forwarded-For", func() {
vhostHTTPPort := f.AllocPort()
serverConf := consts.DefaultServerConfig + fmt.Sprintf(`
vhost_http_port = %d
@@ -31,7 +31,7 @@ var _ = Describe("[Feature: Real IP]", func() {
localServer := httpserver.New(
httpserver.WithBindPort(localPort),
httpserver.WithHandler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(req.Header.Get("X-Forwarded-For")))
_, _ = w.Write([]byte(req.Header.Get("X-Forwarded-For")))
})),
)
f.RunServer("", localServer)
@@ -52,11 +52,10 @@ var _ = Describe("[Feature: Real IP]", func() {
}).
ExpectResp([]byte("127.0.0.1")).
Ensure()
})
Describe("Proxy Protocol", func() {
It("TCP", func() {
ginkgo.Describe("Proxy Protocol", func() {
ginkgo.It("TCP", func() {
serverConf := consts.DefaultServerConfig
clientConf := consts.DefaultClientConfig
@@ -77,7 +76,7 @@ var _ = Describe("[Feature: Real IP]", func() {
}
buf := []byte(ppHeader.SourceAddr.String())
rpc.WriteBytes(c, buf)
_, _ = rpc.WriteBytes(c, buf)
}
}))
f.RunServer("", localServer)
@@ -106,7 +105,7 @@ var _ = Describe("[Feature: Real IP]", func() {
})
})
It("HTTP", func() {
ginkgo.It("HTTP", func() {
vhostHTTPPort := f.AllocPort()
serverConf := consts.DefaultServerConfig + fmt.Sprintf(`
vhost_http_port = %d