Skip to content

Commit

Permalink
fix get nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
dxyinme committed Dec 30, 2023
1 parent 9998bfe commit 600e2b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions driver/etcddriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func testFuncNewEtcdDriver(cfg clientv3.Config) driver.DriverV2 {

func TestEtcdDriver_GetNodes(t *testing.T) {
etcdsvr := integration.NewLazyCluster()
defer etcdsvr.Terminate()
N := 10
drvs := make([]driver.DriverV2, N)
for i := 0; i < N; i++ {
Expand All @@ -35,7 +34,7 @@ func TestEtcdDriver_GetNodes(t *testing.T) {
require.Nil(t, err)
drvs[i] = drv
}
<-time.After(5 * time.Second)
<-time.After(10 * time.Second)
for _, drv := range drvs {
nodes, err := drv.GetNodes(context.Background())
require.Nil(t, err)
Expand All @@ -45,12 +44,12 @@ func TestEtcdDriver_GetNodes(t *testing.T) {
for _, drv := range drvs {
drv.Stop(context.Background())
}
etcdsvr.Terminate()
}

func TestEtcdDriver_Stop(t *testing.T) {
var err error
etcdsvr := integration.NewLazyCluster()
defer etcdsvr.Terminate()

drv1 := testFuncNewEtcdDriver(clientv3.Config{
Endpoints: etcdsvr.EndpointsV3(),
Expand All @@ -67,7 +66,7 @@ func TestEtcdDriver_Stop(t *testing.T) {
require.Nil(t, err)

checkNodesFunc := func(drv driver.DriverV2, count int, timeout time.Duration) {
tick := time.Tick(8 * time.Second)
tick := time.Tick(5 * time.Second)
timeoutPoint := time.Now().Add(timeout)
for range tick {
if timeoutPoint.Before(time.Now()) {
Expand Down Expand Up @@ -97,4 +96,6 @@ func TestEtcdDriver_Stop(t *testing.T) {

drv2.Stop(context.Background())
drv1.Stop(context.Background())

etcdsvr.Terminate()
}

0 comments on commit 600e2b9

Please sign in to comment.