Skip to content

Commit 76aadef

Browse files
authored
Merge pull request #19169 from jmao-dd/jmao/robusttest-18089
Add Robustness test to reproduce issue 18089
2 parents 92673d1 + 7590a7e commit 76aadef

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

tests/robustness/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The purpose of these tests is to rigorously validate that etcd maintains its [KV
1919
| Duplicated watch event due to bug in TXN caching [#17247] | Jan 2024 | main branch | Robustness | Yes, prevented regression in v3.6 | |
2020
| Watch events lost during stream starvation [#17529] | Mar 2024 | v3.4 or earlier | User | Yes, after covering of slow watch | `make test-robustness-issue17529` |
2121
| Revision decreasing caused by crash during compaction [#17780] | Apr 2024 | v3.4 or earlier | Robustness | Yes, after covering compaction | |
22-
| Watch dropping an event when compacting on delete [#18089] | May 2024 | v3.4 or earlier | Robustness | Yes, after covering of compaction | |
22+
| Watch dropping an event when compacting on delete [#18089] | May 2024 | v3.4 or earlier | Robustness | Yes, after covering of compaction | `make test-robustness-issue18089` |
2323
| Inconsistency when reading compacted revision in TXN [#18667] | Oct 2024 | v3.4 or earlier | User | | |
2424

2525
[#13766]: https://github.com/etcd-io/etcd/issues/13766

tests/robustness/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var testRunner = framework.E2eTestRunner
4141

4242
var (
4343
WaitBeforeFailpoint = time.Second
44-
WaitJitter = traffic.CompactionPeriod
44+
WaitJitter = traffic.DefaultCompactionPeriod
4545
WaitAfterFailpoint = time.Second
4646
)
4747

tests/robustness/makefile.mk

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ test-robustness-issue17780: /tmp/etcd-v3.5.13-compactBeforeSetFinishedCompact/bi
4949
GO_TEST_FLAGS='-v --run=TestRobustnessRegression/Issue17780 --count 200 --failfast --bin-dir=/tmp/etcd-v3.5.13-compactBeforeSetFinishedCompact/bin' make test-robustness && \
5050
echo "Failed to reproduce" || echo "Successful reproduction"
5151

52+
.PHONY: test-robustness-issue18089
53+
test-robustness-issue18089: /tmp/etcd-v3.5.12-beforeSendWatchResponse/bin
54+
GO_TEST_FLAGS='-v -run=TestRobustnessRegression/Issue18089 -count 100 -failfast --bin-dir=/tmp/etcd-v3.5.12-beforeSendWatchResponse/bin' make test-robustness && \
55+
echo "Failed to reproduce" || echo "Successful reproduction"
56+
5257
# Failpoints
5358

5459
GOPATH = $(shell go env GOPATH)

tests/robustness/scenarios/scenarios.go

+10
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ func Regression(t *testing.T) []TestScenario {
224224
e2e.WithGoFailEnabled(true),
225225
),
226226
})
227+
scenarios = append(scenarios, TestScenario{
228+
Name: "Issue18089",
229+
Profile: traffic.LowTraffic.WithCompactionPeriod(100 * time.Millisecond), // Use frequent compaction for high reproduce rate
230+
Failpoint: failpoint.SleepBeforeSendWatchResponse,
231+
Traffic: traffic.EtcdDelete,
232+
Cluster: *e2e.NewConfig(
233+
e2e.WithClusterSize(1),
234+
e2e.WithGoFailEnabled(true),
235+
),
236+
})
227237
if v.Compare(version.V3_5) >= 0 {
228238
opts := []e2e.EPClusterOption{
229239
e2e.WithSnapshotCount(100),

tests/robustness/traffic/etcd.go

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ var (
6464
{Choice: Put, Weight: 40},
6565
},
6666
}
67+
EtcdDelete Traffic = etcdTraffic{
68+
keyCount: 10,
69+
largePutSize: 32769,
70+
leaseTTL: DefaultLeaseTTL,
71+
// Please keep the sum of weights equal 100.
72+
requests: []random.ChoiceWeight[etcdRequestType]{
73+
{Choice: Put, Weight: 50},
74+
{Choice: Delete, Weight: 50},
75+
},
76+
}
6777
)
6878

6979
type etcdTraffic struct {

tests/robustness/traffic/traffic.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import (
3333
)
3434

3535
var (
36-
DefaultLeaseTTL int64 = 7200
37-
RequestTimeout = 200 * time.Millisecond
38-
WatchTimeout = time.Second
39-
MultiOpTxnOpCount = 4
40-
CompactionPeriod = 200 * time.Millisecond
36+
DefaultLeaseTTL int64 = 7200
37+
RequestTimeout = 200 * time.Millisecond
38+
WatchTimeout = time.Second
39+
MultiOpTxnOpCount = 4
40+
DefaultCompactionPeriod = 200 * time.Millisecond
4141

4242
LowTraffic = Profile{
4343
MinimalQPS: 100,
@@ -97,7 +97,11 @@ func SimulateTraffic(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2
9797
defer wg.Done()
9898
defer c.Close()
9999

100-
RunCompactLoop(ctx, c, CompactionPeriod, finish)
100+
compactionPeriod := DefaultCompactionPeriod
101+
if profile.CompactPeriod != time.Duration(0) {
102+
compactionPeriod = profile.CompactPeriod
103+
}
104+
RunCompactLoop(ctx, c, compactionPeriod, finish)
101105
mux.Lock()
102106
reports = append(reports, c.Report())
103107
mux.Unlock()
@@ -177,13 +181,19 @@ type Profile struct {
177181
MaxNonUniqueRequestConcurrency int
178182
ClientCount int
179183
ForbidCompaction bool
184+
CompactPeriod time.Duration
180185
}
181186

182187
func (p Profile) WithoutCompaction() Profile {
183188
p.ForbidCompaction = true
184189
return p
185190
}
186191

192+
func (p Profile) WithCompactionPeriod(cp time.Duration) Profile {
193+
p.CompactPeriod = cp
194+
return p
195+
}
196+
187197
type Traffic interface {
188198
Run(ctx context.Context, c *client.RecordingClient, qpsLimiter *rate.Limiter, ids identity.Provider, lm identity.LeaseIDStorage, nonUniqueWriteLimiter ConcurrencyLimiter, finish <-chan struct{})
189199
ExpectUniqueRevision() bool

0 commit comments

Comments
 (0)