mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #15789 from ahrtr/save_data_20230427
test: forcibly save data on panicking
This commit is contained in:
commit
cd24847086
@ -211,8 +211,12 @@ func testRobustness(ctx context.Context, t *testing.T, lg *zap.Logger, config e2
|
||||
}
|
||||
defer r.clus.Close()
|
||||
|
||||
// t.Failed() returns false during panicking. We need to forcibly
|
||||
// save data on panicking.
|
||||
// Refer to: https://github.com/golang/go/issues/49929
|
||||
panicked := true
|
||||
defer func() {
|
||||
r.Report(t)
|
||||
r.Report(t, panicked)
|
||||
}()
|
||||
r.operations, r.responses = runScenario(ctx, t, lg, r.clus, *traffic, failpoint)
|
||||
forcestopCluster(r.clus)
|
||||
@ -225,6 +229,8 @@ func testRobustness(ctx context.Context, t *testing.T, lg *zap.Logger, config e2
|
||||
|
||||
r.patchedOperations = patchOperationBasedOnWatchEvents(r.operations, longestHistory(r.events))
|
||||
r.visualizeHistory = model.ValidateOperationHistoryAndReturnVisualize(t, lg, r.patchedOperations)
|
||||
|
||||
panicked = false
|
||||
}
|
||||
|
||||
func runScenario(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster, traffic trafficConfig, failpoint FailpointConfig) (operations []porcupine.Operation, responses [][]watchResponse) {
|
||||
|
@ -61,9 +61,9 @@ func testResultsDirectory(t *testing.T) string {
|
||||
return path
|
||||
}
|
||||
|
||||
func (r *report) Report(t *testing.T) {
|
||||
func (r *report) Report(t *testing.T, force bool) {
|
||||
path := testResultsDirectory(t)
|
||||
if t.Failed() {
|
||||
if t.Failed() || force {
|
||||
for i, member := range r.clus.Procs {
|
||||
memberDataDir := filepath.Join(path, member.Config().Name)
|
||||
persistMemberDataDir(t, r.lg, member, memberDataDir)
|
||||
|
Loading…
x
Reference in New Issue
Block a user