diff --git a/go.mod b/go.mod index 67ddfea9290..39d5ffda8d0 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( go.etcd.io/etcd/etcdutl/v3 v3.6.0-alpha.0 go.etcd.io/etcd/pkg/v3 v3.6.0-alpha.0 go.etcd.io/etcd/server/v3 v3.6.0-alpha.0 - go.etcd.io/etcd/tests/v3 v3.0.0-00010101000000-000000000000 + go.etcd.io/etcd/tests/v3 v3.5.17 go.etcd.io/raft/v3 v3.6.0-beta.0 go.uber.org/zap v1.27.0 golang.org/x/time v0.8.0 @@ -42,10 +42,12 @@ require ( require ( github.com/VividCortex/ewma v1.2.0 // indirect + github.com/anishathalye/porcupine v1.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/creack/pty v1.1.18 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/go-logr/logr v1.4.2 // indirect diff --git a/go.sum b/go.sum index ef78d8c5048..1fa4538f8fa 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= +github.com/anishathalye/porcupine v1.0.0 h1:93eF6d26IMDky+G4h8FcLuYp1oO+no8a//I7asq/oKI= +github.com/anishathalye/porcupine v1.0.0/go.mod h1:WM0SsFjWNl2Y4BqHr/E/ll2yY1GY1jqn+W7Z/84Zoog= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= @@ -22,6 +24,8 @@ github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03V github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= +github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/tests/go.mod b/tests/go.mod index 04e44721008..308a6a0eaea 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -16,7 +16,7 @@ replace ( ) require ( - github.com/anishathalye/porcupine v0.1.4 + github.com/anishathalye/porcupine v1.0.0 github.com/coreos/go-semver v0.3.1 github.com/golang/protobuf v1.5.4 github.com/google/go-cmp v0.6.0 diff --git a/tests/go.sum b/tests/go.sum index 64a0dfe72c3..1fa4538f8fa 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= -github.com/anishathalye/porcupine v0.1.4 h1:rRekB2jH1mbtLPEzuqyMHp4scU52Bcc1jgkPi1kWFQA= -github.com/anishathalye/porcupine v0.1.4/go.mod h1:/X9OQYnVb7DzfKCQVO4tI1Aq+o56UJW+RvN/5U4EuZA= +github.com/anishathalye/porcupine v1.0.0 h1:93eF6d26IMDky+G4h8FcLuYp1oO+no8a//I7asq/oKI= +github.com/anishathalye/porcupine v1.0.0/go.mod h1:WM0SsFjWNl2Y4BqHr/E/ll2yY1GY1jqn+W7Z/84Zoog= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E= diff --git a/tests/robustness/validate/operations.go b/tests/robustness/validate/operations.go index 9f39407ad81..7f241a310e3 100644 --- a/tests/robustness/validate/operations.go +++ b/tests/robustness/validate/operations.go @@ -32,10 +32,37 @@ var ( 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) { +type Results struct { + Info porcupine.LinearizationInfo + Model porcupine.Model + Lg *zap.Logger // TODO: Remove logger from struct and instead of making it an argument for Visualize +} + +func (r Results) Visualize(path string) error { + + r.Lg.Info("Saving visualization", zap.String("path", path)) + err := porcupine.VisualizePath(r.Model, r.Info, path) + if err != nil { + return fmt.Errorf("failed to visualize, err: %w", err) + } + return nil +} + +func validateLinearizableOperationsAndVisualize( + lg *zap.Logger, + operations []porcupine.Operation, + timeout time.Duration, +) (result porcupine.CheckResult, results Results) { lg.Info("Validating linearizable operations", zap.Duration("timeout", timeout)) start := time.Now() result, info := porcupine.CheckOperationsVerbose(model.NonDeterministicModel, operations, timeout) + + results = Results{ + Info: info, + Model: model.NonDeterministicModel, + Lg: lg, + } + switch result { case porcupine.Illegal: lg.Error("Linearization failed", zap.Duration("duration", time.Since(start))) @@ -46,14 +73,7 @@ func validateLinearizableOperationsAndVisualize(lg *zap.Logger, operations []por default: panic(fmt.Sprintf("Unknown Linearization result %s", result)) } - return result, func(path string) error { - lg.Info("Saving visualization", zap.String("path", path)) - err := porcupine.VisualizePath(model.NonDeterministicModel, info, path) - if err != nil { - return fmt.Errorf("failed to visualize, err: %w", err) - } - return nil - } + return result, results } func validateSerializableOperations(lg *zap.Logger, operations []porcupine.Operation, replay *model.EtcdReplay) (lastErr error) { diff --git a/tests/robustness/validate/validate.go b/tests/robustness/validate/validate.go index 5918ec0df83..a17fc2f467b 100644 --- a/tests/robustness/validate/validate.go +++ b/tests/robustness/validate/validate.go @@ -28,18 +28,18 @@ import ( "go.etcd.io/etcd/tests/v3/robustness/report" ) -// ValidateAndReturnVisualize returns visualize as porcupine.linearizationInfo used to generate visualization is private. -func ValidateAndReturnVisualize(t *testing.T, lg *zap.Logger, cfg Config, reports []report.ClientReport, persistedRequests []model.EtcdRequest, timeout time.Duration) (visualize func(basepath string) error) { +func ValidateAndReturnVisualize(t *testing.T, lg *zap.Logger, cfg Config, reports []report.ClientReport, persistedRequests []model.EtcdRequest, timeout time.Duration) Results { err := checkValidationAssumptions(reports, persistedRequests) require.NoErrorf(t, err, "Broken validation assumptions") linearizableOperations := patchLinearizableOperations(reports, persistedRequests) serializableOperations := filterSerializableOperations(reports) - linearizable, visualize := validateLinearizableOperationsAndVisualize(lg, linearizableOperations, timeout) + linearizable, results := validateLinearizableOperationsAndVisualize(lg, linearizableOperations, timeout) if linearizable != porcupine.Ok { t.Error("Failed linearization, skipping further validation") - return visualize + return results } + // TODO: Use requests from linearization for replay. replay := model.NewReplay(persistedRequests) @@ -51,7 +51,7 @@ func ValidateAndReturnVisualize(t *testing.T, lg *zap.Logger, cfg Config, report if err != nil { t.Errorf("Failed validating serializable operations, err: %s", err) } - return visualize + return results } type Config struct {