Skip to content

Commit

Permalink
fix golang lint
Browse files Browse the repository at this point in the history
Signed-off-by: haojinming <[email protected]>
  • Loading branch information
haojinming committed Oct 20, 2022
1 parent 0c27830 commit 459b35d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions br/pkg/restore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (rc *Client) setSpeedLimit(ctx context.Context, rateLimit uint64) error {
return nil
}

func (rc *Client) resetSpeedLimit(ctx context.Context) error {
func (rc *Client) resetSpeedLimit(ctx context.Context) {
if rc.hasSpeedLimited {
var resetErr error
for retry := 0; retry < resetSpeedLimitRetryTimes; retry++ {
Expand All @@ -258,7 +258,6 @@ func (rc *Client) resetSpeedLimit(ctx context.Context) error {
}
}
rc.hasSpeedLimited = false
return nil
}

// RestoreRaw tries to restore raw keys in the specified range.
Expand Down
11 changes: 4 additions & 7 deletions br/pkg/restore/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,14 @@ func (r *RecordStores) toString() string {

var recordStores RecordStores

const (
WORKING_TIME = 10
)
const workingTime = 10

func (fakeImportCli FakeImporterClient) SetDownloadSpeedLimit(
ctx context.Context,
storeID uint64,
req *import_sstpb.SetDownloadSpeedLimitRequest,
) (*import_sstpb.SetDownloadSpeedLimitResponse, error) {
time.Sleep(WORKING_TIME * time.Millisecond) // simulate doing 100 ms work
time.Sleep(workingTime * time.Millisecond) // simulate doing 100 ms work
recordStores.put(storeID, req.SpeedLimit)
return nil, nil
}
Expand Down Expand Up @@ -123,7 +121,7 @@ func TestSetSpeedLimit(t *testing.T) {
t.Logf("Total Cost: %v\n", cost)
t.Logf("Has Communicated: %v\n", recordStores.toString())

serialCost := time.Duration(len(mockStores)*WORKING_TIME) * time.Millisecond
serialCost := time.Duration(len(mockStores)*workingTime) * time.Millisecond
require.LessOrEqual(t, serialCost, cost)
require.Equal(t, len(mockStores), recordStores.len())
for i := 0; i < len(mockStores); i++ {
Expand All @@ -132,9 +130,8 @@ func TestSetSpeedLimit(t *testing.T) {

recordStores = NewRecordStores()
start = time.Now()
err = client.resetSpeedLimit(ctx)
client.resetSpeedLimit(ctx)
cost = time.Since(start)
require.NoError(t, err)
require.LessOrEqual(t, serialCost, cost)
require.Equal(t, len(mockStores), recordStores.len())
for i := 0; i < len(mockStores); i++ {
Expand Down

0 comments on commit 459b35d

Please sign in to comment.