-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor fanout logic of cse region client
Signed-off-by: iosmanthus <[email protected]>
- Loading branch information
1 parent
2e8d7a2
commit 97cea40
Showing
10 changed files
with
454 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package tikv_test | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
"github.com/tikv/client-go/v2/tikv" | ||
pd "github.com/tikv/pd/client" | ||
) | ||
|
||
// TODO(iosmanthus): refactor this suite as a unit test. | ||
func TestCSE(t *testing.T) { | ||
if !*withCSE { | ||
t.Skip("skipping test; use -with-tikv flag to run this test") | ||
} | ||
suite.Run(t, new(cseSuite)) | ||
} | ||
|
||
type cseSuite struct { | ||
suite.Suite | ||
pdCli pd.Client | ||
} | ||
|
||
func (s *cseSuite) SetupTest() { | ||
pdCli, err := pd.NewClient(strings.Split(*pdAddrs, ","), pd.SecurityOption{}) | ||
s.Nil(err) | ||
pdCli, err = tikv.NewCSEClient(pdCli) | ||
s.Nil(err) | ||
s.pdCli = tikv.NewCodecPDClient(tikv.ModeTxn, pdCli) | ||
} | ||
|
||
func (s *cseSuite) TearDownTest() { | ||
s.pdCli.Close() | ||
} | ||
|
||
func (s *cseSuite) TestGetRegion() { | ||
key, err := hex.DecodeString("780000016d44444c5461626c65ff56657273696f6e00fe0000000000000073") | ||
s.Nil(err) | ||
currentRegion, err := s.pdCli.GetRegion(context.Background(), key) | ||
s.Nil(err) | ||
s.NotNil(currentRegion) | ||
s.LessOrEqual(currentRegion.Meta.StartKey, key) | ||
s.Less(key, currentRegion.Meta.EndKey) | ||
prevRegion, err := s.pdCli.GetPrevRegion(context.Background(), key) | ||
s.Nil(err) | ||
s.Equal(prevRegion.Meta.EndKey, currentRegion.Meta.StartKey) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.