Skip to content

Commit a5ebc34

Browse files
committed
robustness: reproduce #20221
Targeting bug fix #20281 Signed-off-by: Chun-Hung Tseng <henrytseng@google.com>
1 parent 5793558 commit a5ebc34

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

tests/robustness/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ test-robustness-issue20221: /tmp/etcd-bc47e771-failpoints/bin
8080
GO_TEST_FLAGS='-v -run=TestRobustnessRegression/Issue20221 -count 100 -failfast --bin-dir=/tmp/etcd-bc47e771-failpoints/bin' $(TOPLEVEL_MAKE) test-robustness && \
8181
echo "Failed to reproduce" || echo "Successful reproduction"
8282

83+
.PHONY: test-robustness-issue20221-event
84+
test-robustness-issue20221-event: /tmp/etcd-44a094a2-failpoints/bin
85+
GO_TEST_FLAGS='-v -run=TestRobustnessRegression/Issue20221-event -count 100 -failfast --bin-dir=/tmp/etcd-44a094a2-failpoints/bin' $(TOPLEVEL_MAKE) test-robustness && \
86+
echo "Failed to reproduce" || echo "Successful reproduction"
87+
8388
# Etcd API usage by Kubernetes
8489

8590
.PHONY: k8s-coverage
@@ -144,6 +149,19 @@ $(GOPATH)/bin/gofail: $(REPOSITORY_ROOT)/tools/mod/go.mod $(REPOSITORY_ROOT)/too
144149
$(MAKE) gofail-enable; \
145150
$(MAKE) build;
146151

152+
/tmp/etcd-44a094a2-failpoints/bin: $(GOPATH)/bin/gofail
153+
rm -rf /tmp/etcd-44a094a2-failpoints/
154+
mkdir -p /tmp/etcd-44a094a2-failpoints/
155+
cd /tmp/etcd-44a094a2-failpoints/; \
156+
git init; \
157+
git remote add origin https://github.com/etcd-io/etcd.git; \
158+
git fetch --depth 1 origin 44a094a20a7a0ac16cf88c9f21b6ca90e9f85cf5; \
159+
git checkout FETCH_HEAD; \
160+
cp -r $(REPOSITORY_ROOT)/tests/robustness/patches/removeVerifyModRevision . && \
161+
patch --fuzz=0 server/storage/mvcc/watchable_store.go ./removeVerifyModRevision/watchable_store.patch && \
162+
$(MAKE) gofail-enable; \
163+
$(MAKE) build;
164+
147165
/tmp/etcd-release-3.6-failpoints/bin: $(GOPATH)/bin/gofail
148166
rm -rf /tmp/etcd-release-3.6-failpoints/
149167
mkdir -p /tmp/etcd-release-3.6-failpoints/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/server/storage/mvcc/watchable_store.go b/server/storage/mvcc/watchable_store.go
2+
index 1996ee6..ed9fe1c 100644
3+
--- a/server/storage/mvcc/watchable_store.go
4+
+++ b/server/storage/mvcc/watchable_store.go
5+
@@ -15,14 +15,12 @@
6+
package mvcc
7+
8+
import (
9+
- "fmt"
10+
"sync"
11+
"time"
12+
13+
"go.uber.org/zap"
14+
15+
"go.etcd.io/etcd/api/v3/mvccpb"
16+
- "go.etcd.io/etcd/client/pkg/v3/verify"
17+
clientv3 "go.etcd.io/etcd/client/v3"
18+
"go.etcd.io/etcd/pkg/v3/traceutil"
19+
"go.etcd.io/etcd/server/v3/lease"
20+
@@ -610,15 +608,6 @@ func (w *watcher) send(wr WatchResponse) bool {
21+
wr.Events = ne
22+
}
23+
24+
- verify.Verify(func() {
25+
- if w.startRev > 0 {
26+
- for _, ev := range wr.Events {
27+
- if ev.Kv.ModRevision < w.startRev {
28+
- panic(fmt.Sprintf("Event.ModRevision(%d) is less than the w.startRev(%d) for watchID: %d", ev.Kv.ModRevision, w.startRev, w.id))
29+
- }
30+
- }
31+
- }
32+
- })
33+
34+
// if all events are filtered out, we should send nothing.
35+
if !progressEvent && len(wr.Events) == 0 {

tests/robustness/scenarios/scenarios.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,31 @@ func Regression(t *testing.T) []TestScenario {
331331
e2e.WithSnapshotCatchUpEntries(10),
332332
),
333333
})
334+
clusterClientSwitchingInterval := 500 * time.Millisecond
335+
scenarios = append(scenarios, TestScenario{
336+
Name: "Issue20221-event",
337+
Failpoint: failpoint.BlackholeUntilSnapshot,
338+
Watch: client.WatchConfig{
339+
RequestProgress: true,
340+
},
341+
Profile: traffic.Profile{
342+
KeyValue: &traffic.KeyValueHigh,
343+
Watch: &traffic.Watch{
344+
MemberClientCount: 6,
345+
ClusterClientCount: 2,
346+
RevisionOffsetRange: traffic.Range{Min: 10, Max: 100},
347+
EndpointSwitchPeriod: &clusterClientSwitchingInterval,
348+
},
349+
},
350+
Traffic: traffic.EtcdPut,
351+
Cluster: *e2e.NewConfig(
352+
e2e.WithSnapshotCount(10),
353+
e2e.WithPeerProxy(true),
354+
e2e.WithIsPeerTLS(true),
355+
e2e.WithWatchProcessNotifyInterval(10*time.Millisecond),
356+
e2e.WithSnapshotCatchUpEntries(10),
357+
),
358+
})
334359
if v.Compare(version.V3_5) >= 0 {
335360
opts := []e2e.EPClusterOption{
336361
e2e.WithSnapshotCount(100),

0 commit comments

Comments
 (0)