Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed Oct 29, 2024
1 parent de79e49 commit 5c43913
Showing 1 changed file with 33 additions and 13 deletions.
46 changes: 33 additions & 13 deletions pkg/tso/keyspace_group_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1223,41 +1223,61 @@ func waitForPrimariesServing(
func (suite *keyspaceGroupManagerTestSuite) TestRegisterAllocatorConflict() {
re := suite.Require()

kgm := suite.newKeyspaceGroupManager(0, suite.ClusterID, suite.cfg)
re.NotNil(kgm)
defer kgm.Close()
kgm.Initialize()
participant, err := kgm.GetElectionMember(0, 0)
re.NoError(err)

legacySvcRootPath := keypath.LegacyRootPath(suite.ClusterID)
allocatorKeyPrefix := keypath.GlobalTSOAllocatorsPrefix(suite.ClusterID)
legacySvcStorage := endpoint.NewStorageEndpoint(kv.NewEtcdKVBase(suite.etcdClient, legacySvcRootPath), nil)
member := member.NewMember(suite.servers[0], suite.etcdClient, uint64(suite.servers[0].Server.ID()))
am := NewAllocatorManager(suite.ctx, suite.etcdClient, constant.DefaultKeyspaceGroupID, member, legacySvcRootPath, legacySvcStorage, kgm.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "pd"))
m := member.NewMember(suite.servers[0], suite.etcdClient, uint64(suite.servers[0].Server.ID()))
am := NewAllocatorManager(suite.ctx, suite.etcdClient, constant.DefaultKeyspaceGroupID, m, legacySvcRootPath, legacySvcStorage, suite.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "pd"))
gta := NewGlobalTSOAllocator(suite.ctx, am)
err = gta.Initialize(0)
err := gta.Initialize(0)
re.NoError(err)

kam := NewAllocatorManager(kgm.ctx, kgm.etcdClient, constant.DefaultKeyspaceGroupID, participant, kgm.legacySvcRootPath, kgm.legacySvcStorage, kgm.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "tso", fmt.Sprintf("keyspace_group_%d", constant.DefaultKeyspaceGroupID)))
kgta := NewGlobalTSOAllocator(suite.ctx, kam)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()

kgm := suite.newKeyspaceGroupManager(0, suite.ClusterID, suite.cfg)
re.NotNil(kgm)
defer kgm.Close()
kgm.Initialize()
participant, err := kgm.GetElectionMember(0, 0)
re.NoError(err)
kam := NewAllocatorManager(kgm.ctx, kgm.etcdClient, constant.DefaultKeyspaceGroupID, participant, kgm.legacySvcRootPath, kgm.legacySvcStorage, kgm.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "tso", fmt.Sprintf("keyspace_group_%d", constant.DefaultKeyspaceGroupID)))
kgta := NewGlobalTSOAllocator(suite.ctx, kam)
err = kgta.Initialize(0)
re.NoError(err)
kgta.Reset()
}()

gta.Reset()
wg.Wait()

kgm := suite.newKeyspaceGroupManager(0, suite.ClusterID, suite.cfg)
re.NotNil(kgm)
defer kgm.Close()
kgm.Initialize()
participant, err := kgm.GetElectionMember(0, 0)
re.NoError(err)
kam := NewAllocatorManager(kgm.ctx, kgm.etcdClient, constant.DefaultKeyspaceGroupID, participant, kgm.legacySvcRootPath, kgm.legacySvcStorage, kgm.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "tso", fmt.Sprintf("keyspace_group_%d", constant.DefaultKeyspaceGroupID)))
kgta := NewGlobalTSOAllocator(suite.ctx, kam)
err = kgta.Initialize(0)
re.NoError(err)

var wg1 sync.WaitGroup
wg1.Add(1)
go func() {
defer wg1.Done()
err = gta.Initialize(0)

legacySvcRootPath := keypath.LegacyRootPath(suite.ClusterID)
allocatorKeyPrefix := keypath.GlobalTSOAllocatorsPrefix(suite.ClusterID)
legacySvcStorage := endpoint.NewStorageEndpoint(kv.NewEtcdKVBase(suite.etcdClient, legacySvcRootPath), nil)
m := member.NewMember(suite.servers[0], suite.etcdClient, uint64(suite.servers[0].Server.ID()))
am := NewAllocatorManager(suite.ctx, suite.etcdClient, constant.DefaultKeyspaceGroupID, m, legacySvcRootPath, legacySvcStorage, suite.cfg, allocatorKeyPrefix, path.Join(allocatorKeyPrefix, "pd"))
gta := NewGlobalTSOAllocator(suite.ctx, am)
err := gta.Initialize(0)
re.NoError(err)
gta.Reset()
}()
kgta.Reset()
wg1.Wait()
Expand Down

0 comments on commit 5c43913

Please sign in to comment.