@@ -40,8 +40,9 @@ func ValidateAndReturnVisualize(t *testing.T, lg *zap.Logger, cfg Config, report
40
40
return results
41
41
}
42
42
43
- // TODO: Use requests from linearization for replay.
44
- replay := model .NewReplay (persistedRequests )
43
+ // Use linearization results from operations
44
+ linearizedRequests := getLinearizedRequests (linearizableOperations , reports , persistedRequests )
45
+ replay := model .NewReplay (linearizedRequests )
45
46
46
47
err = validateWatch (lg , cfg , reports , replay )
47
48
if err != nil {
@@ -54,6 +55,41 @@ func ValidateAndReturnVisualize(t *testing.T, lg *zap.Logger, cfg Config, report
54
55
return results
55
56
}
56
57
58
+ // getLinearizedRequests converts linearizable operations to a sequence of requests
59
+ // while preserving error responses from the client reports
60
+ func getLinearizedRequests (operations []porcupine.Operation , reports []report.ClientReport , persistedRequests []model.EtcdRequest ) []model.EtcdRequest {
61
+ result := make ([]model.EtcdRequest , 0 , len (persistedRequests ))
62
+
63
+ // Build map of failed operations from client reports
64
+ failedOps := make (map [int ]bool )
65
+ for _ , report := range reports {
66
+ for _ , op := range report .KeyValue {
67
+ response := op .Output .(model.MaybeEtcdResponse )
68
+ if response .Error != "" {
69
+ failedOps [op .ClientId ] = true
70
+ }
71
+ }
72
+ }
73
+
74
+ // Track processed operations
75
+ opIndex := 0
76
+
77
+ // Build sequence combining linearized operations and error responses
78
+ for i := range persistedRequests {
79
+ if failedOps [i ] {
80
+ // Keep failed operations in their original position
81
+ result = append (result , persistedRequests [i ])
82
+ } else if opIndex < len (operations ) {
83
+ // Use operations order for successful requests
84
+ originalIndex := operations [opIndex ].Input .(int )
85
+ result = append (result , persistedRequests [originalIndex ])
86
+ opIndex ++
87
+ }
88
+ }
89
+
90
+ return result
91
+ }
92
+
57
93
type Config struct {
58
94
ExpectRevisionUnique bool
59
95
}
0 commit comments