mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add error constants in validate pkg
Signed-off-by: Akshay Nanavare <nakshay303@gmail.com>
This commit is contained in:
parent
d0ea231f8a
commit
8eb91d0e15
@ -15,6 +15,7 @@
|
|||||||
package validate
|
package validate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -26,6 +27,11 @@ import (
|
|||||||
"go.etcd.io/etcd/tests/v3/robustness/report"
|
"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) {
|
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))
|
lg.Info("Validating linearizable operations", zap.Duration("timeout", timeout))
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
@ -86,14 +92,14 @@ func validateSerializableRead(lg *zap.Logger, replay *model.EtcdReplay, request
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
lg.Error("Failed validating serializable operation", zap.Any("request", request), zap.Any("response", response))
|
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)
|
_, expectResp := state.Step(request)
|
||||||
|
|
||||||
if diff := cmp.Diff(response.EtcdResponse.Range, expectResp.Range); diff != "" {
|
if diff := cmp.Diff(response.EtcdResponse.Range, expectResp.Range); diff != "" {
|
||||||
lg.Error("Failed validating serializable operation", zap.Any("request", request), zap.String("diff", 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
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func TestValidateSerializableOperations(t *testing.T) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: "response didn't match expected",
|
expectError: errRespNotMatched.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid count",
|
name: "Invalid count",
|
||||||
@ -136,7 +136,7 @@ func TestValidateSerializableOperations(t *testing.T) {
|
|||||||
Output: rangeResponse(1),
|
Output: rangeResponse(1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: "response didn't match expected",
|
expectError: errRespNotMatched.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid keys",
|
name: "Invalid keys",
|
||||||
@ -153,7 +153,7 @@ func TestValidateSerializableOperations(t *testing.T) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: "response didn't match expected",
|
expectError: errRespNotMatched.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Invalid revision",
|
name: "Invalid revision",
|
||||||
@ -171,7 +171,7 @@ func TestValidateSerializableOperations(t *testing.T) {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: "response didn't match expected",
|
expectError: errRespNotMatched.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Error",
|
name: "Error",
|
||||||
@ -218,7 +218,7 @@ func TestValidateSerializableOperations(t *testing.T) {
|
|||||||
Output: rangeResponse(0),
|
Output: rangeResponse(0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectError: "request about a future rev with response",
|
expectError: errFutureRevRespRequested.Error(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Future rev failure",
|
name: "Future rev failure",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user