Skip to content

Commit

Permalink
Minor cleanups (#1154)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Groxx committed Dec 1, 2021
1 parent bb11674 commit 9c6ab23
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 24 deletions.
5 changes: 0 additions & 5 deletions evictiontest/workflow_cache_eviction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
1 change: 1 addition & 0 deletions internal/internal_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions internal/internal_workers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
}

Expand Down
22 changes: 12 additions & 10 deletions test/replaytests/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package replaytests

import (
"context"
"errors"
"time"

"go.uber.org/cadence/activity"
Expand All @@ -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{
Expand All @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 9c6ab23

Please sign in to comment.