From edfc963302a03f3967f8e5cd1b1c280bf6ae5120 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Wed, 15 Feb 2023 13:12:45 +0100 Subject: [PATCH] tests: Detect duplicate watch event Signed-off-by: Marek Siarkowicz --- tests/linearizability/watch.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/linearizability/watch.go b/tests/linearizability/watch.go index 0b00bc5ef..20b2a9de6 100644 --- a/tests/linearizability/watch.go +++ b/tests/linearizability/watch.go @@ -88,6 +88,12 @@ func validateMemberWatchResponses(t *testing.T, responses []watchResponse, expec lastHeadRevision int64 = 1 // The resp.Header.Revision in last watch response. lastProgressNotifyRevision int64 = 0 // The resp.Header.Revision in the last progress notify watch response. ) + type revisionKey struct { + revision int64 + key string + } + uniqueOperations := map[revisionKey]struct{}{} + for _, resp := range responses { if resp.Header.Revision < lastHeadRevision { t.Errorf("Server revision should never decrease, lastHeadRevision: %d, resp.Header.Revision: %d", @@ -105,6 +111,11 @@ func validateMemberWatchResponses(t *testing.T, responses []watchResponse, expec } for _, event := range resp.Events { + rk := revisionKey{key: string(event.Kv.Key), revision: event.Kv.ModRevision} + if _, found := uniqueOperations[rk]; found { + t.Errorf("BROKE: Within the:wq same revision key can only be modified once. Suspecting duplicate watch event. key: %q, revision: %d", rk.key, rk.revision) + } + uniqueOperations[rk] = struct{}{} if event.Kv.ModRevision <= lastProgressNotifyRevision { t.Errorf("BROKE: etcd will not send progress notification to a watcher until it has synced all events. So a watcher will never receive an event with a lower `ModRevision` than the last progressNotification's revision, eventRevision: %d, progressNotifyRevision: %d", event.Kv.ModRevision, lastProgressNotifyRevision) }