Skip to content

Commit

Permalink
Merge pull request #18008 from akshaynanavare/add-error-constants
Browse files Browse the repository at this point in the history
add error constants in validate pkg
  • Loading branch information
serathius committed May 15, 2024
2 parents 22c40e1 + 8eb91d0 commit a2ce035
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions tests/robustness/validate/operations.go
Expand Up @@ -15,6 +15,7 @@
package validate

import (
"errors"
"fmt"
"time"

Expand All @@ -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()
Expand Down Expand Up @@ -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
}
10 changes: 5 additions & 5 deletions tests/robustness/validate/operations_test.go
Expand Up @@ -121,7 +121,7 @@ func TestValidateSerializableOperations(t *testing.T) {
),
},
},
expectError: "response didn't match expected",
expectError: errRespNotMatched.Error(),
},
{
name: "Invalid count",
Expand All @@ -136,7 +136,7 @@ func TestValidateSerializableOperations(t *testing.T) {
Output: rangeResponse(1),
},
},
expectError: "response didn't match expected",
expectError: errRespNotMatched.Error(),
},
{
name: "Invalid keys",
Expand All @@ -153,7 +153,7 @@ func TestValidateSerializableOperations(t *testing.T) {
),
},
},
expectError: "response didn't match expected",
expectError: errRespNotMatched.Error(),
},
{
name: "Invalid revision",
Expand All @@ -171,7 +171,7 @@ func TestValidateSerializableOperations(t *testing.T) {
),
},
},
expectError: "response didn't match expected",
expectError: errRespNotMatched.Error(),
},
{
name: "Error",
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestValidateSerializableOperations(t *testing.T) {
Output: rangeResponse(0),
},
},
expectError: "request about a future rev with response",
expectError: errFutureRevRespRequested.Error(),
},
{
name: "Future rev failure",
Expand Down

0 comments on commit a2ce035

Please sign in to comment.