Skip to content

Commit

Permalink
pass unit test
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Aug 11, 2023
1 parent 53f8044 commit 9a5b924
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ require (
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/net v0.9.0
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions server/config/store_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,12 @@ func (s TiKVConfigSource) GetConfig(ctx context.Context, statusAddress string) (
}
resp, err := s.client.Do(req)
if err != nil {
cancel()
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
cancel()
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions server/config/store_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package config
import (
"crypto/tls"
"encoding/json"
"golang.org/x/net/context"
"net/http"
"testing"

Expand Down Expand Up @@ -63,15 +64,15 @@ func TestTiKVConfig(t *testing.T) {
func TestUpdateConfig(t *testing.T) {
re := require.New(t)
manager := NewTestStoreConfigManager([]string{"tidb.com"})
manager.ObserveConfig("tikv.com")
manager.ObserveConfig(context.Background(), "tikv.com")
re.Equal(uint64(144), manager.GetStoreConfig().GetRegionMaxSize())
re.NotEqual(raftStoreV2, manager.GetStoreConfig().GetRegionMaxSize())
manager.ObserveConfig("tidb.com")
manager.ObserveConfig(context.Background(), "tidb.com")
re.Equal(uint64(10), manager.GetStoreConfig().GetRegionMaxSize())
re.Equal(raftStoreV2, manager.GetStoreConfig().Engine)

// case2: the config should not update if config is same expect some ignore field.
c, err := manager.source.GetConfig("tidb.com")
c, err := manager.source.GetConfig(context.Background(), "tidb.com")
re.NoError(err)
re.True(manager.GetStoreConfig().Equal(c))

Expand Down

0 comments on commit 9a5b924

Please sign in to comment.