From fdbe9d03421a7f2d8f1d641b2cb41584f26828a1 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Wed, 26 Apr 2023 17:41:03 +0800 Subject: [PATCH] Fix tsoKeyspaceGroupManagerTestSuite Signed-off-by: JmPotato --- pkg/keyspace/tso_keyspace_group.go | 12 +++++------- .../mcs/tso/keyspace_group_manager_test.go | 4 ++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/keyspace/tso_keyspace_group.go b/pkg/keyspace/tso_keyspace_group.go index b10db4766d4..36b45f885d6 100644 --- a/pkg/keyspace/tso_keyspace_group.go +++ b/pkg/keyspace/tso_keyspace_group.go @@ -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. @@ -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 } @@ -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(), diff --git a/tests/integrations/mcs/tso/keyspace_group_manager_test.go b/tests/integrations/mcs/tso/keyspace_group_manager_test.go index 9cd46ad2d41..38000c257ce 100644 --- a/tests/integrations/mcs/tso/keyspace_group_manager_test.go +++ b/tests/integrations/mcs/tso/keyspace_group_manager_test.go @@ -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) } }