Skip to content

Commit

Permalink
do some experiments
Browse files Browse the repository at this point in the history
Signed-off-by: Boyang Lyu <[email protected]>
  • Loading branch information
JackL9u committed Aug 9, 2024
1 parent acec910 commit 1a1912a
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions tests/integrations/client/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ func (suite *httpClientTestSuite) SetupSuite() {
suite.endpoints = endpoints
suite.cluster = cluster

list := &api.ListServiceGCSafepoint{
ServiceGCSafepoints: []*endpoint.ServiceSafePoint{
{
ServiceID: "AAA",
ExpiredAt: time.Now().Unix() + 10,
SafePoint: 1,
},
{
ServiceID: "BBB",
ExpiredAt: time.Now().Unix() + 10,
SafePoint: 2,
},
{
ServiceID: "CCC",
ExpiredAt: time.Now().Unix() + 10,
SafePoint: 3,
},
},
GCSafePoint: 1,
MinServiceGcSafepoint: 1,
}

storage := suite.cluster.GetLeaderServer().GetServer().GetStorage()
for _, ssp := range list.ServiceGCSafepoints {
err := storage.SaveServiceGCSafePoint(ssp)
re.NoError(err)
}
storage.SaveGCSafePoint(1)

if suite.withServiceDiscovery {
// Run test with specific service discovery.
cli := setupCli(suite.ctx, re, suite.endpoints)
Expand Down Expand Up @@ -844,6 +873,13 @@ func (suite *httpClientTestSuite) TestGetGCSafePoint() {
ctx, cancel := context.WithCancel(suite.ctx)
defer cancel()

l, err := client.GetGCSafePoint(ctx)
re.NoError(err)

re.Equal(uint64(1), l.GCSafePoint)
re.Equal(uint64(1), l.MinServiceGcSafepoint)
re.Len(l.ServiceGCSafepoints, 3)

list := &api.ListServiceGCSafepoint{
ServiceGCSafepoints: []*endpoint.ServiceSafePoint{
{
Expand All @@ -866,20 +902,6 @@ func (suite *httpClientTestSuite) TestGetGCSafePoint() {
MinServiceGcSafepoint: 1,
}

storage := suite.cluster.GetLeaderServer().GetServer().GetStorage()
for _, ssp := range list.ServiceGCSafepoints {
err := storage.SaveServiceGCSafePoint(ssp)
re.NoError(err)
}
storage.SaveGCSafePoint(1)

l, err := client.GetGCSafePoint(ctx)
re.NoError(err)

re.Equal(uint64(1), l.GCSafePoint)
re.Equal(uint64(1), l.MinServiceGcSafepoint)
re.Len(l.ServiceGCSafepoints, 3)

for i, val := range l.ServiceGCSafepoints {
re.Equal(list.ServiceGCSafepoints[i].ServiceID, val.ServiceID)
re.Equal(list.ServiceGCSafepoints[i].SafePoint, val.SafePoint)
Expand Down

0 comments on commit 1a1912a

Please sign in to comment.