Skip to content

Commit

Permalink
tests: apply a couple suggested changes from review.
Browse files Browse the repository at this point in the history
Signed-off-by: Jiayin Mao <jiayin.mao@datadoghq.com>
  • Loading branch information
jmao-dd committed Jan 25, 2025
1 parent 2c7d981 commit ba4ee2d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/e2e/runtime_reconfiguration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/stretchr/testify/require"
"go.etcd.io/etcd/server/v3/etcdserver"

"go.etcd.io/etcd/tests/v3/framework/e2e"
)

Expand Down Expand Up @@ -179,11 +178,14 @@ func addMemberAsLearnerAndPromote(ctx context.Context, t *testing.T, epc *e2e.Et
id, err := epc.StartNewProc(ctx, nil, t, true /* addAsLearner */)
require.NoError(t, err)
_, err = epc.Etcdctl(e2e.WithEndpoints(endpoints)).MemberPromote(ctx, id)
attempt := 1
for err != nil && (attempt < 4) && strings.Contains(err.Error(), "can only promote a learner member which is in sync with leader") {
t.Logf("Learner is not ready yet, retry for the %v time", attempt)
time.Sleep(100 * time.Duration(attempt) * time.Millisecond)

attempt := 0
for attempt < 3 {
_, err = epc.Etcdctl(e2e.WithEndpoints(endpoints)).MemberPromote(ctx, id)
if err == nil || !strings.Contains(err.Error(), "can only promote a learner member which is in sync with leader") {
break
}
time.Sleep(100 * time.Millisecond)
attempt++
}
require.NoError(t, err)
Expand Down

0 comments on commit ba4ee2d

Please sign in to comment.