Skip to content

Commit 9c6ab23

Browse files
authored
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.
1 parent bb11674 commit 9c6ab23

File tree

6 files changed

+13
-24
lines changed

6 files changed

+13
-24
lines changed

evictiontest/workflow_cache_eviction_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"time"
3636

3737
"github.com/golang/mock/gomock"
38-
log "github.com/sirupsen/logrus"
3938
"github.com/stretchr/testify/suite"
4039
"go.uber.org/atomic"
4140
"go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
@@ -92,10 +91,6 @@ func (s *CacheEvictionSuite) TearDownTest() {
9291
}
9392

9493
func TestWorkersTestSuite(t *testing.T) {
95-
formatter := &log.TextFormatter{}
96-
formatter.FullTimestamp = true
97-
log.SetFormatter(formatter)
98-
log.SetLevel(log.DebugLevel)
9994
suite.Run(t, new(CacheEvictionSuite))
10095
}
10196

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require (
1212
github.com/opentracing/opentracing-go v1.1.0
1313
github.com/pborman/uuid v0.0.0-20160209185913-a97ce2ca70fa
1414
github.com/robfig/cron v1.2.0
15-
github.com/sirupsen/logrus v1.4.2
1615
github.com/stretchr/testify v1.4.0
1716
github.com/uber-go/tally v3.3.15+incompatible
1817
github.com/uber/cadence-idl v0.0.0-20211111101836-d6b70b60eb8c

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHz
8686
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
8787
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
8888
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
89-
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
9089
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
9190
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
9291
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
144143
github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af h1:EiWVfh8mr40yFZEui2oF0d45KgH48PkB2H0Z0GANvSI=
145144
github.com/samuel/go-thrift v0.0.0-20191111193933-5165175b40af/go.mod h1:Vrkh1pnjV9Bl8c3P9zH0/D4NlOHWP5d4/hF4YTULaec=
146145
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
147-
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
148146
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
149147
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 h1:7z3LSn867ex6VSaahyKadf4WtSsJIgne6A1WLOAGM8A=
150148
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25/go.mod h1:lbP8tGiBjZ5YWIc2fzuRpTaz0b/53vT6PEs3QuAWzuU=

internal/internal_utils_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func TestConstructError_TimeoutError(t *testing.T) {
153153
// Backward compatibility test
154154
reason = errReasonTimeout
155155
details, err = dc.ToData(s.TimeoutTypeHeartbeat)
156+
require.NoError(t, err)
156157
constructedErr = constructError(reason, details, dc)
157158
timeoutErr, ok = constructedErr.(*TimeoutError)
158159
require.True(t, ok)

internal/internal_workers_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929

3030
"github.com/golang/mock/gomock"
3131
"github.com/pborman/uuid"
32-
log "github.com/sirupsen/logrus"
3332
"github.com/stretchr/testify/suite"
3433
"go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
3534
m "go.uber.org/cadence/.gen/go/shared"
@@ -79,11 +78,6 @@ func (s *WorkersTestSuite) TearDownTest() {
7978
}
8079

8180
func TestWorkersTestSuite(t *testing.T) {
82-
formatter := &log.TextFormatter{}
83-
formatter.FullTimestamp = true
84-
log.SetFormatter(formatter)
85-
log.SetLevel(log.DebugLevel)
86-
8781
suite.Run(t, new(WorkersTestSuite))
8882
}
8983

test/replaytests/workflows.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package replaytests
2222

2323
import (
2424
"context"
25+
"errors"
2526
"time"
2627

2728
"go.uber.org/cadence/activity"
@@ -30,9 +31,6 @@ import (
3031
"go.uber.org/zap"
3132
)
3233

33-
// ApplicationName is the task list for this sample
34-
const ApplicationName = "helloWorldGroup"
35-
3634
// Workflow workflow decider
3735
func Workflow(ctx workflow.Context, name string) error {
3836
ao := workflow.ActivityOptions{
@@ -47,23 +45,23 @@ func Workflow(ctx workflow.Context, name string) error {
4745
var helloworldResult string
4846
v := workflow.GetVersion(ctx, "test-change", workflow.DefaultVersion, 1)
4947
if v == workflow.DefaultVersion {
48+
return errors.New("no default-version history")
49+
} else {
5050
err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
5151
if err != nil {
52-
logger.Error("Activity failed.", zap.Error(err))
52+
logger.Error("First activity failed.", zap.Error(err))
5353
return err
5454
}
55-
} else {
56-
err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
5755
err = workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
5856
if err != nil {
59-
logger.Error("Activity failed.", zap.Error(err))
57+
logger.Error("Second activity failed.", zap.Error(err))
6058
return err
6159
}
6260
}
6361

6462
err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
6563
if err != nil {
66-
logger.Error("Activity failed.", zap.Error(err))
64+
logger.Error("Third activity failed.", zap.Error(err))
6765
return err
6866
}
6967

@@ -87,9 +85,13 @@ func Workflow2(ctx workflow.Context, name string) error {
8785

8886
workflow.GetVersion(ctx, "test-change", workflow.DefaultVersion, 1)
8987

90-
workflow.UpsertSearchAttributes(ctx, map[string]interface{}{"CustomKeywordField": "testkey"})
88+
err := workflow.UpsertSearchAttributes(ctx, map[string]interface{}{"CustomKeywordField": "testkey"})
89+
if err != nil {
90+
logger.Error("upsert failed", zap.Error(err))
91+
return err
92+
}
9193

92-
err := workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
94+
err = workflow.ExecuteActivity(ctx, helloworldActivity, name).Get(ctx, &helloworldResult)
9395
if err != nil {
9496
logger.Error("Activity failed.", zap.Error(err))
9597
return err

0 commit comments

Comments
 (0)