Skip to content

Commit

Permalink
Fix tsoKeyspaceGroupManagerTestSuite
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Apr 26, 2023
1 parent e9b9ec1 commit fdbe9d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 5 additions & 7 deletions pkg/keyspace/tso_keyspace_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ func (m *GroupManager) Bootstrap() error {
m.groups[userKind].Put(group)
}

// Load all the keyspaces from the storage and assign them to the respective keyspace groups.
return m.patrolKeyspaceAssignmentLocked()
return nil
}

// Close closes the manager.
Expand All @@ -171,14 +170,10 @@ func (m *GroupManager) Close() {
m.wg.Wait()
}

// patrolKeyspaceAssignment is used to patrol all keyspaces and assign them to the keyspace groups.
func (m *GroupManager) patrolKeyspaceAssignment() error {
m.Lock()
defer m.Unlock()
return m.patrolKeyspaceAssignmentLocked()
}

// patrolKeyspaceAssignment is used to patrol all keyspaces and assign them to the keyspace groups.
func (m *GroupManager) patrolKeyspaceAssignmentLocked() error {
if m.patrolKeyspaceAssignmentOnce {
return nil
}
Expand Down Expand Up @@ -486,6 +481,9 @@ func (m *GroupManager) getKeyspaceConfigByKindLocked(userKind endpoint.UserKind)
return map[string]string{}, errors.Errorf("user kind %s not found", userKind)
}
kg := groups.Top()
if kg == nil {
return map[string]string{}, errors.Errorf("no keyspace group for user kind %s", userKind)
}
id := strconv.FormatUint(uint64(kg.ID), 10)
config := map[string]string{
UserKindKey: userKind.String(),
Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/mcs/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func (suite *tsoKeyspaceGroupManagerTestSuite) TearDownTest() {

func cleanupKeyspaceGroups(re *require.Assertions, server *tests.TestServer) {
for _, group := range handlersutil.MustLoadKeyspaceGroups(re, server, "0", "0") {
// Do not delete default keyspace group.
if group.ID == mcsutils.DefaultKeyspaceGroupID {
continue
}
handlersutil.MustDeleteKeyspaceGroup(re, server, group.ID)
}
}
Expand Down

0 comments on commit fdbe9d0

Please sign in to comment.