From 9c6ab239bbf865f07dd855c7f644931979f790e1 Mon Sep 17 00:00:00 2001 From: Steven L Date: Wed, 1 Dec 2021 12:45:39 -0800 Subject: [PATCH] Minor cleanups (#1154) Contains two changes: 1: Remove logrus, it was only used in tests. 2: Updating replay tests to more-accurately reflect the test I feel the replay-test workflow func was probably intended to test versioning, by running through both code paths... but the history files do not lead to that. So for now I've just made it more capable of detecting errors, and hopefully a bit easier to understand. The replays likely deserve a rewrite at some point. --- evictiontest/workflow_cache_eviction_test.go | 5 ----- go.mod | 1 - go.sum | 2 -- internal/internal_utils_test.go | 1 + internal/internal_workers_test.go | 6 ------ test/replaytests/workflows.go | 22 +++++++++++--------- 6 files changed, 13 insertions(+), 24 deletions(-) diff --git a/evictiontest/workflow_cache_eviction_test.go b/evictiontest/workflow_cache_eviction_test.go index 7a8795562..e81f5137b 100644 --- a/evictiontest/workflow_cache_eviction_test.go +++ b/evictiontest/workflow_cache_eviction_test.go @@ -35,7 +35,6 @@ import ( "time" "github.com/golang/mock/gomock" - log "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" "go.uber.org/atomic" "go.uber.org/cadence/.gen/go/cadence/workflowservicetest" @@ -92,10 +91,6 @@ func (s *CacheEvictionSuite) TearDownTest() { } func TestWorkersTestSuite(t *testing.T) { - formatter := &log.TextFormatter{} - formatter.FullTimestamp = true - log.SetFormatter(formatter) - log.SetLevel(log.DebugLevel) suite.Run(t, new(CacheEvictionSuite)) } diff --git a/go.mod b/go.mod index ef068316c..385f84794 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/opentracing/opentracing-go v1.1.0 github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa github.com/robfig/cron v1.2.0 - github.com/sirupsen/logrus v1.4.2 github.com/stretchr/testify v1.4.0 github.com/uber-go/tally v3.3.15+incompatible github.com/uber/cadence-idl v0.0.0-20211111101836-d6b70b60eb8c diff --git a/go.sum b/go.sum index 51e97f3aa..0d6931d19 100644 --- a/go.sum +++ b/go.sum @@ -86,7 +86,6 @@ github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHz github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -144,7 +143,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af h1:EiWVfh8mr40yFZEui2oF0d45KgH48PkB2H0Z0GANvSI= github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af/go.mod h1:Vrkh1pnjV9Bl8c3P9zH0/D4NlOHWP5d4/hF4YTULaec= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 h1:7z3LSn867ex6VSaahyKadf4WtSsJIgne6A1WLOAGM8A= github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25/go.mod h1:lbP8tGiBjZ5YWIc2fzuRpTaz0b/53vT6PEs3QuAWzuU= diff --git a/internal/internal_utils_test.go b/internal/internal_utils_test.go index ce986fb0f..211df8fdf 100644 --- a/internal/internal_utils_test.go +++ b/internal/internal_utils_test.go @@ -153,6 +153,7 @@ func TestConstructError_TimeoutError(t *testing.T) { // Backward compatibility test reason = errReasonTimeout details, err = dc.ToData(s.TimeoutTypeHeartbeat) + require.NoError(t, err) constructedErr = constructError(reason, details, dc) timeoutErr, ok = constructedErr.(*TimeoutError) require.True(t, ok) diff --git a/internal/internal_workers_test.go b/internal/internal_workers_test.go index e61862fcd..933fa929b 100644 --- a/internal/internal_workers_test.go +++ b/internal/internal_workers_test.go @@ -29,7 +29,6 @@ import ( "github.com/golang/mock/gomock" "github.com/pborman/uuid" - log "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" "go.uber.org/cadence/.gen/go/cadence/workflowservicetest" m "go.uber.org/cadence/.gen/go/shared" @@ -79,11 +78,6 @@ func (s *WorkersTestSuite) TearDownTest() { } func TestWorkersTestSuite(t *testing.T) { - formatter := &log.TextFormatter{} - formatter.FullTimestamp = true - log.SetFormatter(formatter) - log.SetLevel(log.DebugLevel) - suite.Run(t, new(WorkersTestSuite)) } diff --git a/test/replaytests/workflows.go b/test/replaytests/workflows.go index 4e8decb35..1e62765e8 100644 --- a/test/replaytests/workflows.go +++ b/test/replaytests/workflows.go @@ -22,6 +22,7 @@ package replaytests import ( "context" + "errors" "time" "go.uber.org/cadence/activity" @@ -30,9 +31,6 @@ import ( "go.uber.org/zap" ) -// ApplicationName is the task list for this sample -const ApplicationName = "helloWorldGroup" - // Workflow workflow decider func Workflow(ctx workflow.Context, name string) error { ao := workflow.ActivityOptions{ @@ -47,23 +45,23 @@ func Workflow(ctx workflow.Context, name string) error { var helloworldResult string v := workflow.GetVersion(ctx, "test-change", workflow.DefaultVersion, 1) if v == workflow.DefaultVersion { + return errors.New("no default-version history") + } else { err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) if err != nil { - logger.Error("Activity failed.", zap.Error(err)) + logger.Error("First activity failed.", zap.Error(err)) return err } - } else { - err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) err = workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) if err != nil { - logger.Error("Activity failed.", zap.Error(err)) + logger.Error("Second activity failed.", zap.Error(err)) return err } } err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) if err != nil { - logger.Error("Activity failed.", zap.Error(err)) + logger.Error("Third activity failed.", zap.Error(err)) return err } @@ -87,9 +85,13 @@ func Workflow2(ctx workflow.Context, name string) error { workflow.GetVersion(ctx, "test-change", workflow.DefaultVersion, 1) - workflow.UpsertSearchAttributes(ctx, map[string]interface{}{"CustomKeywordField": "testkey"}) + err := workflow.UpsertSearchAttributes(ctx, map[string]interface{}{"CustomKeywordField": "testkey"}) + if err != nil { + logger.Error("upsert failed", zap.Error(err)) + return err + } - err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) + err = workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult) if err != nil { logger.Error("Activity failed.", zap.Error(err)) return err