mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15179 from serathius/linearizability-deduplicate-scenarios
tests: Deduplicate cluster test scenarios
This commit is contained in:
commit
bfc361e2df
@ -43,6 +43,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
LowTrafficAllRequests = trafficConfig{
|
LowTrafficAllRequests = trafficConfig{
|
||||||
|
name: "LowTrafficAllRequests",
|
||||||
minimalQPS: 100,
|
minimalQPS: 100,
|
||||||
maximalQPS: 200,
|
maximalQPS: 200,
|
||||||
clientCount: 8,
|
clientCount: 8,
|
||||||
@ -55,24 +56,32 @@ var (
|
|||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
HighTrafficPut = trafficConfig{
|
HighTrafficPut = trafficConfig{
|
||||||
|
name: "HighTrafficPut",
|
||||||
minimalQPS: 200,
|
minimalQPS: 200,
|
||||||
maximalQPS: 1000,
|
maximalQPS: 1000,
|
||||||
clientCount: 12,
|
clientCount: 12,
|
||||||
traffic: readWriteSingleKey{keyCount: 4, leaseTTL: DefaultLeaseTTL, writes: []requestChance{{operation: Put, chance: 100}}},
|
traffic: readWriteSingleKey{keyCount: 4, leaseTTL: DefaultLeaseTTL, writes: []requestChance{{operation: Put, chance: 100}}},
|
||||||
}
|
}
|
||||||
|
defaultTraffic = LowTrafficAllRequests
|
||||||
|
trafficList = []trafficConfig{
|
||||||
|
LowTrafficAllRequests, HighTrafficPut,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLinearizability(t *testing.T) {
|
func TestLinearizability(t *testing.T) {
|
||||||
testRunner.BeforeTest(t)
|
testRunner.BeforeTest(t)
|
||||||
tcs := []struct {
|
type scenario struct {
|
||||||
name string
|
name string
|
||||||
failpoint Failpoint
|
failpoint Failpoint
|
||||||
config e2e.EtcdProcessClusterConfig
|
config e2e.EtcdProcessClusterConfig
|
||||||
traffic *trafficConfig
|
traffic *trafficConfig
|
||||||
}{
|
}
|
||||||
{
|
scenarios := []scenario{}
|
||||||
name: "ClusterOfSize1",
|
for _, traffic := range trafficList {
|
||||||
|
scenarios = append(scenarios, scenario{
|
||||||
|
name: "ClusterOfSize1/" + traffic.name,
|
||||||
failpoint: RandomFailpoint,
|
failpoint: RandomFailpoint,
|
||||||
|
traffic: &traffic,
|
||||||
config: *e2e.NewConfig(
|
config: *e2e.NewConfig(
|
||||||
e2e.WithClusterSize(1),
|
e2e.WithClusterSize(1),
|
||||||
e2e.WithSnapshotCount(100),
|
e2e.WithSnapshotCount(100),
|
||||||
@ -80,40 +89,20 @@ func TestLinearizability(t *testing.T) {
|
|||||||
e2e.WithGoFailEnabled(true),
|
e2e.WithGoFailEnabled(true),
|
||||||
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
||||||
),
|
),
|
||||||
},
|
})
|
||||||
{
|
scenarios = append(scenarios, scenario{
|
||||||
name: "ClusterOfSize3",
|
name: "ClusterOfSize3/" + traffic.name,
|
||||||
failpoint: RandomFailpoint,
|
failpoint: RandomFailpoint,
|
||||||
|
traffic: &traffic,
|
||||||
config: *e2e.NewConfig(
|
config: *e2e.NewConfig(
|
||||||
e2e.WithSnapshotCount(100),
|
e2e.WithSnapshotCount(100),
|
||||||
e2e.WithPeerProxy(true),
|
e2e.WithPeerProxy(true),
|
||||||
e2e.WithGoFailEnabled(true),
|
e2e.WithGoFailEnabled(true),
|
||||||
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
||||||
),
|
),
|
||||||
},
|
})
|
||||||
{
|
}
|
||||||
name: "HighTrafficClusterOfSize1",
|
scenarios = append(scenarios, []scenario{
|
||||||
failpoint: RandomFailpoint,
|
|
||||||
traffic: &HighTrafficPut,
|
|
||||||
config: *e2e.NewConfig(
|
|
||||||
e2e.WithClusterSize(1),
|
|
||||||
e2e.WithSnapshotCount(100),
|
|
||||||
e2e.WithPeerProxy(true),
|
|
||||||
e2e.WithGoFailEnabled(true),
|
|
||||||
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "HighTrafficClusterOfSize3",
|
|
||||||
failpoint: RandomFailpoint,
|
|
||||||
traffic: &HighTrafficPut,
|
|
||||||
config: *e2e.NewConfig(
|
|
||||||
e2e.WithSnapshotCount(100),
|
|
||||||
e2e.WithPeerProxy(true),
|
|
||||||
e2e.WithGoFailEnabled(true),
|
|
||||||
e2e.WithCompactionBatchLimit(100), // required for compactBeforeCommitBatch and compactAfterCommitBatch failpoints
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Issue14370",
|
name: "Issue14370",
|
||||||
failpoint: RaftBeforeSavePanic,
|
failpoint: RaftBeforeSavePanic,
|
||||||
@ -138,25 +127,25 @@ func TestLinearizability(t *testing.T) {
|
|||||||
e2e.WithSnapshotCount(100),
|
e2e.WithSnapshotCount(100),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
}
|
}...)
|
||||||
for _, tc := range tcs {
|
for _, scenario := range scenarios {
|
||||||
if tc.traffic == nil {
|
if scenario.traffic == nil {
|
||||||
tc.traffic = &LowTrafficAllRequests
|
scenario.traffic = &defaultTraffic
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(scenario.name, func(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
clus, err := e2e.NewEtcdProcessCluster(ctx, t, e2e.WithConfig(&tc.config))
|
clus, err := e2e.NewEtcdProcessCluster(ctx, t, e2e.WithConfig(&scenario.config))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer clus.Close()
|
defer clus.Close()
|
||||||
operations, events := testLinearizability(ctx, t, clus, FailpointConfig{
|
operations, events := testLinearizability(ctx, t, clus, FailpointConfig{
|
||||||
failpoint: tc.failpoint,
|
failpoint: scenario.failpoint,
|
||||||
count: 1,
|
count: 1,
|
||||||
retries: 3,
|
retries: 3,
|
||||||
waitBetweenTriggers: waitBetweenFailpointTriggers,
|
waitBetweenTriggers: waitBetweenFailpointTriggers,
|
||||||
}, *tc.traffic)
|
}, *scenario.traffic)
|
||||||
clus.Stop()
|
clus.Stop()
|
||||||
longestHistory, remainingEvents := pickLongestHistory(events)
|
longestHistory, remainingEvents := pickLongestHistory(events)
|
||||||
validateEventsMatch(t, longestHistory, remainingEvents)
|
validateEventsMatch(t, longestHistory, remainingEvents)
|
||||||
@ -354,6 +343,7 @@ func simulateTraffic(ctx context.Context, t *testing.T, clus *e2e.EtcdProcessClu
|
|||||||
}
|
}
|
||||||
|
|
||||||
type trafficConfig struct {
|
type trafficConfig struct {
|
||||||
|
name string
|
||||||
minimalQPS float64
|
minimalQPS float64
|
||||||
maximalQPS float64
|
maximalQPS float64
|
||||||
clientCount int
|
clientCount int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user