mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #17730 from serathius/robustness-no-failpoint
Make no failpoint error more readable
This commit is contained in:
commit
0be1976986
@ -54,7 +54,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func PickRandom(t *testing.T, clus *e2e.EtcdProcessCluster) Failpoint {
|
||||
func PickRandom(clus *e2e.EtcdProcessCluster) (Failpoint, error) {
|
||||
availableFailpoints := make([]Failpoint, 0, len(allFailpoints))
|
||||
for _, failpoint := range allFailpoints {
|
||||
err := Validate(clus, failpoint)
|
||||
@ -64,10 +64,9 @@ func PickRandom(t *testing.T, clus *e2e.EtcdProcessCluster) Failpoint {
|
||||
availableFailpoints = append(availableFailpoints, failpoint)
|
||||
}
|
||||
if len(availableFailpoints) == 0 {
|
||||
t.Errorf("No available failpoints")
|
||||
return nil
|
||||
return nil, fmt.Errorf("no available failpoints")
|
||||
}
|
||||
return availableFailpoints[rand.Int()%len(availableFailpoints)]
|
||||
return availableFailpoints[rand.Int()%len(availableFailpoints)], nil
|
||||
}
|
||||
|
||||
func Validate(clus *e2e.EtcdProcessCluster, failpoint Failpoint) error {
|
||||
|
@ -73,13 +73,15 @@ func testRobustness(ctx context.Context, t *testing.T, lg *zap.Logger, s testSce
|
||||
defer report.Cluster.Close()
|
||||
|
||||
if s.failpoint == nil {
|
||||
s.failpoint = failpoint.PickRandom(t, report.Cluster)
|
||||
} else {
|
||||
err = failpoint.Validate(report.Cluster, s.failpoint)
|
||||
s.failpoint, err = failpoint.PickRandom(report.Cluster)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
err = failpoint.Validate(report.Cluster, s.failpoint)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// t.Failed() returns false during panicking. We need to forcibly
|
||||
// save data on panicking.
|
||||
|
Loading…
x
Reference in New Issue
Block a user