add error constants in validate pkg

Signed-off-by: Akshay Nanavare <nakshay303@gmail.com>
This commit is contained in:
Akshay Nanavare
2024-05-14 17:52:27 +05:30
parent d0ea231f8a
commit 8eb91d0e15
2 changed files with 13 additions and 7 deletions

View File

@ -15,6 +15,7 @@
package validate
import (
"errors"
"fmt"
"time"
@ -26,6 +27,11 @@ import (
"go.etcd.io/etcd/tests/v3/robustness/report"
)
var (
errRespNotMatched = errors.New("response didn't match expected")
errFutureRevRespRequested = errors.New("request about a future rev with response")
)
func validateLinearizableOperationsAndVisualize(lg *zap.Logger, operations []porcupine.Operation, timeout time.Duration) (result porcupine.CheckResult, visualize func(basepath string) error) {
lg.Info("Validating linearizable operations", zap.Duration("timeout", timeout))
start := time.Now()
@ -86,14 +92,14 @@ func validateSerializableRead(lg *zap.Logger, replay *model.EtcdReplay, request
return nil
}
lg.Error("Failed validating serializable operation", zap.Any("request", request), zap.Any("response", response))
return fmt.Errorf("request about a future rev with response")
return errFutureRevRespRequested
}
_, expectResp := state.Step(request)
if diff := cmp.Diff(response.EtcdResponse.Range, expectResp.Range); diff != "" {
lg.Error("Failed validating serializable operation", zap.Any("request", request), zap.String("diff", diff))
return fmt.Errorf("response didn't match expected")
return errRespNotMatched
}
return nil
}