Skip to content

Commit

Permalink
test: rollback the change in PR pull/14824
Browse files Browse the repository at this point in the history
The change did in etcd-io#14824 fixed
the test instead of the product code. It isn't correct. After we
fixed the product code in this PR, we can revert the change in
that PR.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
  • Loading branch information
ahrtr committed Nov 25, 2022
1 parent ff20197 commit a4fe7c9
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions tests/integration/corrupt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,13 @@ func TestPeriodicCheckDetectsCorruption(t *testing.T) {
time.Sleep(50 * time.Millisecond)
leader := clus.WaitLeader(t)

// Get sorted member IDs
members, err := cc.MemberList(ctx)
assert.NoError(t, err, "error on member list %v")

// NOTE: If the corrupted member has been elected as leader, the
// alarm will show the smaller member.
var expectedID = uint64(clus.Members[0].ID())
if leader == 0 {
for _, m := range members.Members {
if m.Name != clus.Members[0].Name {
expectedID = m.ID
break
}
}

}

err = clus.Members[leader].Server.CorruptionChecker().PeriodicCheck()
assert.NoError(t, err, "error on periodic check")
time.Sleep(50 * time.Millisecond)

alarmResponse, err := cc.AlarmList(ctx)
assert.NoError(t, err, "error on alarm list")
assert.Equal(t, []*etcdserverpb.AlarmMember{{Alarm: etcdserverpb.AlarmType_CORRUPT, MemberID: expectedID}}, alarmResponse.Alarms)
assert.Equal(t, []*etcdserverpb.AlarmMember{{Alarm: etcdserverpb.AlarmType_CORRUPT, MemberID: uint64(clus.Members[0].ID())}}, alarmResponse.Alarms)
}

func TestCompactHashCheck(t *testing.T) {
Expand Down Expand Up @@ -186,26 +169,9 @@ func TestCompactHashCheckDetectCorruption(t *testing.T) {
time.Sleep(50 * time.Millisecond)
leader := clus.WaitLeader(t)

// Get sorted member IDs
members, err := cc.MemberList(ctx)
assert.NoError(t, err, "error on member list %v")

// NOTE: If the corrupted member has been elected as leader, the
// alarm will show the smaller member.
var expectedID = uint64(clus.Members[0].ID())
if leader == 0 {
for _, m := range members.Members {
if m.Name != clus.Members[0].Name {
expectedID = m.ID
break
}
}

}

clus.Members[leader].Server.CorruptionChecker().CompactHashCheck()
time.Sleep(50 * time.Millisecond)
alarmResponse, err := cc.AlarmList(ctx)
assert.NoError(t, err, "error on alarm list")
assert.Equal(t, []*etcdserverpb.AlarmMember{{Alarm: etcdserverpb.AlarmType_CORRUPT, MemberID: expectedID}}, alarmResponse.Alarms)
assert.Equal(t, []*etcdserverpb.AlarmMember{{Alarm: etcdserverpb.AlarmType_CORRUPT, MemberID: uint64(clus.Members[0].ID())}}, alarmResponse.Alarms)
}

0 comments on commit a4fe7c9

Please sign in to comment.