From a32880a798980b529cc0d558137e3d39f4f8199c Mon Sep 17 00:00:00 2001 From: husharp Date: Fri, 14 Jul 2023 10:25:42 +0800 Subject: [PATCH] make static happy Signed-off-by: husharp --- client/Makefile | 7 +++++-- client/errs/errno.go | 4 +++- client/resource_group/controller/controller.go | 3 +-- client/resource_group/controller/limiter.go | 2 ++ client/resource_group/controller/testutil.go | 3 ++- tests/integrations/client/Makefile | 7 +++++-- tests/integrations/mcs/Makefile | 7 +++++-- tests/integrations/mcs/tso/proxy_test.go | 18 +++++++++--------- tests/integrations/tso/Makefile | 7 +++++-- 9 files changed, 37 insertions(+), 21 deletions(-) diff --git a/client/Makefile b/client/Makefile index 2916ed444a2..fd34ef157bf 100644 --- a/client/Makefile +++ b/client/Makefile @@ -31,9 +31,12 @@ install-tools: cd .. && $(MAKE) install-tools static: install-tools + @ echo "gofmt ..." @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' - @ golangci-lint run -c ../.golangci.yml ./... - @ revive -formatter friendly -config ../revive.toml . + @ echo "golangci-lint ..." + @ golangci-lint run -c ../.golangci.yml --verbose ./... + @ echo "revive ..." + @ revive -formatter friendly -config ../revive.toml ./... tidy: @ go mod tidy diff --git a/client/errs/errno.go b/client/errs/errno.go index 98fe9451d1e..646af81929d 100644 --- a/client/errs/errno.go +++ b/client/errs/errno.go @@ -32,7 +32,8 @@ const ( // NotServedErr indicates an tso node/pod received the requests for the keyspace groups which are not served by it. // Note: keep the same as the ones defined on the server side, because the client side checks if an error message // contains this string to judge whether the leader is changed. - NotServedErr = "is not served" + NotServedErr = "is not served" + // RetryTimeoutErr indicates the server is busy. RetryTimeoutErr = "retry timeout" ) @@ -91,6 +92,7 @@ var ( ErrClientResourceGroupThrottled = errors.Normalize("exceeded resource group quota limitation", errors.RFCCodeText("PD:client:ErrClientResourceGroupThrottled")) ) +// ErrClientGetResourceGroup is the error type for getting resource group. type ErrClientGetResourceGroup struct { ResourceGroupName string Cause string diff --git a/client/resource_group/controller/controller.go b/client/resource_group/controller/controller.go index cc4595f7e42..460a148e510 100755 --- a/client/resource_group/controller/controller.go +++ b/client/resource_group/controller/controller.go @@ -1118,9 +1118,8 @@ func (gc *groupCostController) onRequestWait( sub(gc.mu.consumption, delta) gc.mu.Unlock() return nil, nil, err - } else { - gc.successfulRequestDuration.Observe(d.Seconds()) } + gc.successfulRequestDuration.Observe(d.Seconds()) } gc.mu.Lock() diff --git a/client/resource_group/controller/limiter.go b/client/resource_group/controller/limiter.go index a8038c6d8e5..f89ab17514c 100644 --- a/client/resource_group/controller/limiter.go +++ b/client/resource_group/controller/limiter.go @@ -285,6 +285,7 @@ type tokenBucketReconfigureArgs struct { NotifyThreshold float64 } +// LimiterOption configures Limiter. type LimiterOption func(*Limiter) func resetLowProcess() func(*Limiter) { @@ -386,6 +387,7 @@ func (lim *Limiter) reserveN(now time.Time, n float64, maxFutureReserve time.Dur return r } +// ResetRemainingNotifyTimes resets the remaining notify times to 3. func (lim *Limiter) ResetRemainingNotifyTimes() { lim.mu.Lock() defer lim.mu.Unlock() diff --git a/client/resource_group/controller/testutil.go b/client/resource_group/controller/testutil.go index 81dc8a154b0..4df8c9bba0d 100644 --- a/client/resource_group/controller/testutil.go +++ b/client/resource_group/controller/testutil.go @@ -51,7 +51,7 @@ func (tri *TestRequestInfo) StoreID() uint64 { return tri.storeID } -// ReplicaNums implements the RequestInfo interface. +// ReplicaNumber implements the RequestInfo interface. func (tri *TestRequestInfo) ReplicaNumber() int64 { return 1 } @@ -63,6 +63,7 @@ type TestResponseInfo struct { succeed bool } +// NewTestResponseInfo creates a new TestResponseInfo. func NewTestResponseInfo(readBytes uint64, kvCPU time.Duration, succeed bool) *TestResponseInfo { return &TestResponseInfo{ readBytes: readBytes, diff --git a/tests/integrations/client/Makefile b/tests/integrations/client/Makefile index 71f6297270c..2d0cf748599 100644 --- a/tests/integrations/client/Makefile +++ b/tests/integrations/client/Makefile @@ -18,9 +18,12 @@ PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) static: install-tools + @ echo "gofmt ..." @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' - @ golangci-lint run ./... - @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . + @ echo "golangci-lint ..." + @ golangci-lint run -c $(ROOT_PATH)/.golangci.yml --verbose ./... + @ echo "revive ..." + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml ./... tidy: @ go mod tidy diff --git a/tests/integrations/mcs/Makefile b/tests/integrations/mcs/Makefile index 2628ea9e437..11862fc9e6c 100644 --- a/tests/integrations/mcs/Makefile +++ b/tests/integrations/mcs/Makefile @@ -18,9 +18,12 @@ PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) static: install-tools + @ echo "gofmt ..." @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' - @ golangci-lint run ./... - @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . + @ echo "golangci-lint ..." + @ golangci-lint run -c $(ROOT_PATH)/.golangci.yml --verbose ./... + @ echo "revive ..." + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml ./... tidy: @ go mod tidy diff --git a/tests/integrations/mcs/tso/proxy_test.go b/tests/integrations/mcs/tso/proxy_test.go index 45646dfa48e..625a702ad39 100644 --- a/tests/integrations/mcs/tso/proxy_test.go +++ b/tests/integrations/mcs/tso/proxy_test.go @@ -79,7 +79,7 @@ func (s *tsoProxyTestSuite) SetupSuite() { } // Create some TSO client streams with different context. - s.streams, s.cleanupFuncs = createTSOStreams(re, s.ctx, s.backendEndpoints, 200) + s.streams, s.cleanupFuncs = createTSOStreams(s.ctx, re, s.backendEndpoints, 200) } func (s *tsoProxyTestSuite) TearDownSuite() { @@ -107,7 +107,7 @@ func (s *tsoProxyTestSuite) TestTSOProxyWorksWithCancellation() { go func() { defer wg.Done() for i := 0; i < 3; i++ { - streams, cleanupFuncs := createTSOStreams(re, s.ctx, s.backendEndpoints, 10) + streams, cleanupFuncs := createTSOStreams(s.ctx, re, s.backendEndpoints, 10) for j := 0; j < 10; j++ { s.verifyTSOProxy(s.ctx, streams, cleanupFuncs, 10, true) } @@ -148,7 +148,7 @@ func TestTSOProxyStress(t *testing.T) { log.Info("start a new round of stress test", zap.Int("round-id", i), zap.Int("clients-count", len(streams)+clientsIncr)) streamsTemp, cleanupFuncsTemp := - createTSOStreams(re, s.ctx, s.backendEndpoints, clientsIncr) + createTSOStreams(s.ctx, re, s.backendEndpoints, clientsIncr) streams = append(streams, streamsTemp...) cleanupFuncs = append(cleanupFuncs, cleanupFuncsTemp...) s.verifyTSOProxy(ctxTimeout, streams, cleanupFuncs, 50, false) @@ -201,7 +201,7 @@ func (s *tsoProxyTestSuite) TestTSOProxyRecvFromClientTimeout() { // Enable the failpoint to make the TSO Proxy's grpc stream timeout on the server side to be 1 second. re.NoError(failpoint.Enable("github.com/tikv/pd/server/tsoProxyRecvFromClientTimeout", `return(1)`)) - streams, cleanupFuncs := createTSOStreams(re, s.ctx, s.backendEndpoints, 1) + streams, cleanupFuncs := createTSOStreams(s.ctx, re, s.backendEndpoints, 1) // Sleep 2 seconds to make the TSO Proxy's grpc stream timeout on the server side. time.Sleep(2 * time.Second) err := streams[0].Send(s.defaultReq) @@ -220,7 +220,7 @@ func (s *tsoProxyTestSuite) TestTSOProxyFailToSendToClient() { // Enable the failpoint to make the TSO Proxy's grpc stream timeout on the server side to be 1 second. re.NoError(failpoint.Enable("github.com/tikv/pd/server/tsoProxyFailToSendToClient", `return(true)`)) - streams, cleanupFuncs := createTSOStreams(re, s.ctx, s.backendEndpoints, 1) + streams, cleanupFuncs := createTSOStreams(s.ctx, re, s.backendEndpoints, 1) err := streams[0].Send(s.defaultReq) re.NoError(err) _, err = streams[0].Recv() @@ -238,7 +238,7 @@ func (s *tsoProxyTestSuite) TestTSOProxySendToTSOTimeout() { // Enable the failpoint to make the TSO Proxy's grpc stream timeout on the server side to be 1 second. re.NoError(failpoint.Enable("github.com/tikv/pd/server/tsoProxySendToTSOTimeout", `return(true)`)) - streams, cleanupFuncs := createTSOStreams(re, s.ctx, s.backendEndpoints, 1) + streams, cleanupFuncs := createTSOStreams(s.ctx, re, s.backendEndpoints, 1) err := streams[0].Send(s.defaultReq) re.NoError(err) _, err = streams[0].Recv() @@ -256,7 +256,7 @@ func (s *tsoProxyTestSuite) TestTSOProxyRecvFromTSOTimeout() { // Enable the failpoint to make the TSO Proxy's grpc stream timeout on the server side to be 1 second. re.NoError(failpoint.Enable("github.com/tikv/pd/server/tsoProxyRecvFromTSOTimeout", `return(true)`)) - streams, cleanupFuncs := createTSOStreams(re, s.ctx, s.backendEndpoints, 1) + streams, cleanupFuncs := createTSOStreams(s.ctx, re, s.backendEndpoints, 1) err := streams[0].Send(s.defaultReq) re.NoError(err) _, err = streams[0].Recv() @@ -369,7 +369,7 @@ func (s *tsoProxyTestSuite) generateRequests(requestsPerClient int) []*pdpb.TsoR // createTSOStreams creates multiple TSO client streams, and each stream uses a different gRPC connection // to simulate multiple clients. func createTSOStreams( - re *require.Assertions, ctx context.Context, + ctx context.Context, re *require.Assertions, backendEndpoints string, clientCount int, ) ([]pdpb.PD_TsoClient, []testutil.CleanupFunc) { cleanupFuncs := make([]testutil.CleanupFunc, clientCount) @@ -475,7 +475,7 @@ func benchmarkTSOProxyNClients(clientCount int, b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - streams, cleanupFuncs := createTSOStreams(re, ctx, suite.backendEndpoints, clientCount) + streams, cleanupFuncs := createTSOStreams(ctx, re, suite.backendEndpoints, clientCount) // Benchmark TSO proxy b.ResetTimer() diff --git a/tests/integrations/tso/Makefile b/tests/integrations/tso/Makefile index 38f5cfa164a..25896ca50e4 100644 --- a/tests/integrations/tso/Makefile +++ b/tests/integrations/tso/Makefile @@ -18,9 +18,12 @@ PATH := $(GO_TOOLS_BIN_PATH):$(PATH) SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash) static: install-tools + @ echo "gofmt ..." @ gofmt -s -l -d . 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }' - @ golangci-lint run ./... - @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml . + @ echo "golangci-lint ..." + @ golangci-lint run -c $(ROOT_PATH)/.golangci.yml --verbose ./... + @ echo "revive ..." + @ revive -formatter friendly -config $(ROOT_PATH)/revive.toml ./... tidy: @ go mod tidy