Skip to content

Commit

Permalink
make static happy
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Jul 14, 2023
1 parent 42ce6a1 commit a32880a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 21 deletions.
7 changes: 5 additions & 2 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion client/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions client/resource_group/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions client/resource_group/controller/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ type tokenBucketReconfigureArgs struct {
NotifyThreshold float64
}

// LimiterOption configures Limiter.
type LimiterOption func(*Limiter)

func resetLowProcess() func(*Limiter) {
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion client/resource_group/controller/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions tests/integrations/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions tests/integrations/mcs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions tests/integrations/mcs/tso/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions tests/integrations/tso/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a32880a

Please sign in to comment.