Skip to content

Commit 6cf8729

Browse files
committed
Revert "Disable robustness test detection of etcd-io#18089 to allow detecting other issues"
This reverts commit 4fe227c. Signed-off-by: Wei Fu <[email protected]>
1 parent 62e4433 commit 6cf8729

File tree

3 files changed

+9
-95
lines changed

3 files changed

+9
-95
lines changed

tests/robustness/model/replay.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ func NewReplay(persistedRequests []EtcdRequest) *EtcdReplay {
3636
state = newState
3737
}
3838
return &EtcdReplay{
39-
Requests: persistedRequests,
4039
revisionToEtcdState: revisionToEtcdState,
41-
events: events,
40+
Events: events,
4241
}
4342
}
4443

4544
type EtcdReplay struct {
46-
Requests []EtcdRequest
4745
revisionToEtcdState []EtcdState
48-
events []PersistedEvent
46+
Events []PersistedEvent
4947
}
5048

5149
func (r *EtcdReplay) StateForRevision(revision int64) (EtcdState, error) {
@@ -56,7 +54,7 @@ func (r *EtcdReplay) StateForRevision(revision int64) (EtcdState, error) {
5654
}
5755

5856
func (r *EtcdReplay) EventsForWatch(watch WatchRequest) (events []PersistedEvent) {
59-
for _, e := range r.events {
57+
for _, e := range r.Events {
6058
if e.Revision < watch.Revision || !e.Match(watch) {
6159
continue
6260
}

tests/robustness/validate/validate_test.go

-37
Original file line numberDiff line numberDiff line change
@@ -1331,34 +1331,6 @@ func TestValidateWatch(t *testing.T) {
13311331
putRequest("c", "3"),
13321332
},
13331333
},
1334-
{
1335-
name: "Reliable - issue #18089 - pass",
1336-
reports: []report.ClientReport{
1337-
{
1338-
Watch: []model.WatchOperation{
1339-
{
1340-
Request: model.WatchRequest{
1341-
WithPrefix: true,
1342-
Revision: 3,
1343-
},
1344-
Responses: []model.WatchResponse{
1345-
{
1346-
Events: []model.WatchEvent{
1347-
putWatchEvent("b", "2", 4, true),
1348-
},
1349-
},
1350-
},
1351-
},
1352-
},
1353-
},
1354-
},
1355-
persistedRequests: []model.EtcdRequest{
1356-
putRequest("a", "1"),
1357-
deleteRequest("a"),
1358-
putRequest("b", "2"),
1359-
compactRequest(3),
1360-
},
1361-
},
13621334
{
13631335
name: "Resumable - watch revision from middle event - pass",
13641336
reports: []report.ClientReport{
@@ -1987,12 +1959,3 @@ func deleteRequest(key string) model.EtcdRequest {
19871959
Defragment: nil,
19881960
}
19891961
}
1990-
1991-
func compactRequest(revision int64) model.EtcdRequest {
1992-
return model.EtcdRequest{
1993-
Type: model.Compact,
1994-
Compact: &model.CompactRequest{
1995-
Revision: revision,
1996-
},
1997-
}
1998-
}

tests/robustness/validate/watch.go

+6-53
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ func validateReliable(lg *zap.Logger, replay *model.EtcdReplay, report report.Cl
205205
gotEvents = append(gotEvents, event.PersistedEvent)
206206
}
207207
}
208-
// TODO(https://github.com/etcd-io/etcd/issues/18089): Remove when bug is fixed
209-
detected, newWantEvents := checkIssue18089(lg, report.ClientID, wantEvents, gotEvents, replay)
210-
if detected {
211-
wantEvents = newWantEvents
212-
}
213208
if diff := cmp.Diff(wantEvents, gotEvents, cmpopts.IgnoreFields(model.PersistedEvent{}, "IsCreate")); diff != "" {
214209
lg.Error("Broke watch guarantee", zap.String("guarantee", "reliable"), zap.Int("client", report.ClientID), zap.String("diff", diff))
215210
err = errBrokeReliable
@@ -223,22 +218,18 @@ func validateResumable(lg *zap.Logger, replay *model.EtcdReplay, report report.C
223218
if watch.Request.Revision == 0 {
224219
continue
225220
}
226-
wantEvents := replay.EventsForWatch(watch.Request)
221+
events := replay.EventsForWatch(watch.Request)
227222
index := 0
228-
for index < len(wantEvents) && (wantEvents[index].Revision < watch.Request.Revision || !wantEvents[index].Match(watch.Request)) {
223+
for index < len(events) && (events[index].Revision < watch.Request.Revision || !events[index].Match(watch.Request)) {
229224
index++
230225
}
231-
if index == len(wantEvents) {
226+
if index == len(events) {
232227
continue
233228
}
234-
gotFirstEvent := firstWatchEvent(watch)
229+
firstEvent := firstWatchEvent(watch)
235230
// If watch is resumable, first event it gets should the first event that happened after the requested revision.
236-
if gotFirstEvent != nil && wantEvents[index] != gotFirstEvent.PersistedEvent {
237-
// TODO(https://github.com/etcd-io/etcd/issues/18089): Remove when bug is fixed
238-
if detected, _ := checkIssue18089(lg, report.ClientID, wantEvents, []model.PersistedEvent{gotFirstEvent.PersistedEvent}, replay); detected {
239-
continue
240-
}
241-
lg.Error("Broke watch guarantee", zap.String("guarantee", "resumable"), zap.Int("client", report.ClientID), zap.Any("request", watch.Request), zap.Any("got-event", *gotFirstEvent), zap.Any("want-event", wantEvents[index]))
231+
if firstEvent != nil && events[index] != firstEvent.PersistedEvent {
232+
lg.Error("Broke watch guarantee", zap.String("guarantee", "resumable"), zap.Int("client", report.ClientID), zap.Any("request", watch.Request), zap.Any("got-event", *firstEvent), zap.Any("want-event", events[index]))
242233
err = errBrokeResumable
243234
}
244235
}
@@ -341,41 +332,3 @@ func firstWatchEvent(op model.WatchOperation) *model.WatchEvent {
341332
}
342333
return nil
343334
}
344-
345-
func checkIssue18089(lg *zap.Logger, clientID int, want, got []model.PersistedEvent, replay *model.EtcdReplay) (bool, []model.PersistedEvent) {
346-
type keyRevision struct {
347-
Key string
348-
Revision int64
349-
}
350-
gotKeyRevision := map[keyRevision]struct{}{}
351-
for _, event := range got {
352-
gotKeyRevision[keyRevision{
353-
Key: event.Key,
354-
Revision: event.Revision,
355-
}] = struct{}{}
356-
}
357-
newWant := []model.PersistedEvent{}
358-
issueDetected := false
359-
for _, event := range want {
360-
_, found := gotKeyRevision[keyRevision{
361-
Key: event.Key,
362-
Revision: event.Revision,
363-
}]
364-
if !found && event.Type == model.DeleteOperation && matchingCompaction(event.Revision, replay) {
365-
issueDetected = true
366-
lg.Info("Detected issue 18089 still present, missing delete watch event for a compacted revision", zap.Int("client", clientID), zap.Any("missing-event", event))
367-
continue
368-
}
369-
newWant = append(newWant, event)
370-
}
371-
return issueDetected, newWant
372-
}
373-
374-
func matchingCompaction(revision int64, replay *model.EtcdReplay) bool {
375-
for _, req := range replay.Requests {
376-
if req.Type == model.Compact && req.Compact.Revision == revision {
377-
return true
378-
}
379-
}
380-
return false
381-
}

0 commit comments

Comments
 (0)