Skip to content

Commit caaf1f0

Browse files
committed
WIP: add member id to client watch reponses, add validateWatchSequential to check memberID in events
Signed-off-by: ah8ad3 <[email protected]> Signed-off-by: ah8ad3 <[email protected]> - Signed-off-by: ah8ad3 <[email protected]>
1 parent 9314ef7 commit caaf1f0

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

tests/robustness/client/client.go

+1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ func ToWatchResponse(r clientv3.WatchResponse, baseTime time.Time) model.WatchRe
316316
}
317317
resp.IsProgressNotify = r.IsProgressNotify()
318318
resp.Revision = r.Header.Revision
319+
resp.MemberId = r.Header.MemberId
319320
err := r.Err()
320321
if err != nil {
321322
resp.Error = r.Err().Error()

tests/robustness/main_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func testRobustness(ctx context.Context, t *testing.T, lg *zap.Logger, s testSce
9696

9797
watchProgressNotifyEnabled := r.Cluster.Cfg.ServerConfig.ExperimentalWatchProgressNotifyInterval != 0
9898
validateGotAtLeastOneProgressNotify(t, r.Client, s.watch.requestProgress || watchProgressNotifyEnabled)
99+
validateWatchSequential(t, r.Client)
99100
validateConfig := validate.Config{ExpectRevisionUnique: s.traffic.ExpectUniqueRevision()}
100101
r.Visualize = validate.ValidateAndReturnVisualize(t, lg, validateConfig, r.Client, persistedRequests, 5*time.Minute)
101102

tests/robustness/model/watch.go

+1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ type WatchResponse struct {
2626
IsProgressNotify bool
2727
Revision int64
2828
Time time.Duration
29+
MemberId uint64
2930
Error string
3031
}

tests/robustness/watch.go

+24
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,27 @@ external:
143143
t.Errorf("Progress notify does not match, expect: %v, got: %v", expectProgressNotify, gotProgressNotify)
144144
}
145145
}
146+
147+
func validateWatchSequential(t *testing.T, reports []report.ClientReport) {
148+
for _, r := range reports {
149+
for _, op := range r.Watch {
150+
if op.Request.Revision != 0 {
151+
continue
152+
}
153+
lastEventRevision := make(map[uint64]int64)
154+
for _, resp := range op.Responses {
155+
if len(resp.Events) == 0 {
156+
continue
157+
}
158+
if _, ok := lastEventRevision[resp.MemberId]; !ok {
159+
lastEventRevision[resp.MemberId] = 1
160+
}
161+
firstEventRevision := resp.Events[0].Revision
162+
if firstEventRevision < lastEventRevision[resp.MemberId] {
163+
t.Errorf("Error watch sequential, expect: %v or higher, got: %v, member id: %v", lastEventRevision[resp.MemberId], firstEventRevision, resp.MemberId)
164+
}
165+
lastEventRevision[resp.MemberId] = resp.Events[len(resp.Events)-1].Revision
166+
}
167+
}
168+
}
169+
}

0 commit comments

Comments
 (0)