Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ystaticy committed Mar 29, 2024
1 parent 1c73638 commit 3d31854
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ type Client interface {
DeleteOperators(context.Context) error

/* Keyspace interface */

// UpdateKeyspaceGCManagementType update the `gc_management_type` in keyspace meta config.
// If `gc_management_type` is `global_gc`, it means the current keyspace requires a tidb without 'keyspace-name'
// configured to run a global gc worker to compute a global gc safe point.
// If `gc_management_type` is `keyspace_level_gc` it means the current keyspace can compute gc safe point by its own.
UpdateKeyspaceGCManagementType(ctx context.Context, keyspaceName string, keyspaceGCManagementType *KeyspaceGCManagementTypeConfig) error
GetKeyspaceMetaByName(ctx context.Context, keyspaceName string) (*keyspacepb.KeyspaceMeta, error)

Expand Down
5 changes: 4 additions & 1 deletion client/http/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,10 @@ type MicroServiceMember struct {
StartTimestamp int64 `json:"start-timestamp"`
}

// KeyspaceGCManagementType represents parameters needed to modify the safe point version.
// KeyspaceGCManagementType represents parameters needed to modify the gc management type.
// If `gc_management_type` is `global_gc`, it means the current keyspace requires a tidb without 'keyspace-name'
// configured to run a global gc worker to compute a global gc safe point.
// If `gc_management_type` is `keyspace_level_gc` it means the current keyspace can compute gc safe point by its own.
type KeyspaceGCManagementType struct {
GCManagementType string `json:"gc_management_type,omitempty"`
}
Expand Down
14 changes: 8 additions & 6 deletions tests/integrations/client/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,20 +784,20 @@ func (suite *httpClientTestSuite) TestRedirectWithMetrics() {
c.Close()
}

func (suite *httpClientTestSuite) TestUpdateKeyspaceSafePointVersion() {
suite.RunTestInTwoModes(suite.checkUpdateKeyspaceSafePointVersion)
func (suite *httpClientTestSuite) TestUpdateKeyspaceGCManagementType() {
suite.RunTestInTwoModes(suite.checkUpdateKeyspaceGCManagementType)
}

func (suite *httpClientTestSuite) checkUpdateKeyspaceSafePointVersion(mode mode, client pd.Client) {
func (suite *httpClientTestSuite) checkUpdateKeyspaceGCManagementType(mode mode, client pd.Client) {
re := suite.Require()
env := suite.env[mode]

keyspaceName := "DEFAULT"
gcManagementType := "keysapce_level_gc"
expectGCManagementType := "keysapce_level_gc"

keyspaceSafePointVersionConfig := pd.KeyspaceGCManagementTypeConfig{
Config: pd.KeyspaceGCManagementType{
GCManagementType: gcManagementType,
GCManagementType: expectGCManagementType,
},
}
err := client.UpdateKeyspaceGCManagementType(env.ctx, keyspaceName, &keyspaceSafePointVersionConfig)
Expand All @@ -806,6 +806,8 @@ func (suite *httpClientTestSuite) checkUpdateKeyspaceSafePointVersion(mode mode,
keyspaceMetaRes, err := client.GetKeyspaceMetaByName(env.ctx, keyspaceName)
re.NoError(err)
val, ok := keyspaceMetaRes.Config["gc_management_type"]

// Check it can get expect key and value in keyspace meta config.
re.True(ok)
re.Equal(gcManagementType, val)
re.Equal(expectGCManagementType, val)
}

0 comments on commit 3d31854

Please sign in to comment.