@@ -28,16 +28,24 @@ import (
28
28
"github.com/stretchr/testify/require"
29
29
"github.com/stretchr/testify/suite"
30
30
"go.uber.org/yarpc"
31
+ "go.uber.org/zap"
32
+ "go.uber.org/zap/zaptest"
31
33
32
34
"go.uber.org/cadence/.gen/go/cadence/workflowservicetest"
33
35
"go.uber.org/cadence/.gen/go/shared"
34
36
"go.uber.org/cadence/internal/common"
35
37
)
36
38
39
+ const (
40
+ testWorkflowType = "test-workflow-type"
41
+ testActivityType = "test-activity-type"
42
+ )
43
+
37
44
type activityTestSuite struct {
38
45
suite.Suite
39
46
mockCtrl * gomock.Controller
40
47
service * workflowservicetest.MockClient
48
+ logger * zap.Logger
41
49
}
42
50
43
51
func TestActivityTestSuite (t * testing.T ) {
@@ -48,6 +56,7 @@ func TestActivityTestSuite(t *testing.T) {
48
56
func (s * activityTestSuite ) SetupTest () {
49
57
s .mockCtrl = gomock .NewController (s .T ())
50
58
s .service = workflowservicetest .NewMockClient (s .mockCtrl )
59
+ s .logger = zaptest .NewLogger (s .T ())
51
60
}
52
61
53
62
func (s * activityTestSuite ) TearDownTest () {
@@ -56,7 +65,7 @@ func (s *activityTestSuite) TearDownTest() {
56
65
57
66
func (s * activityTestSuite ) TestActivityHeartbeat () {
58
67
ctx , cancel := context .WithCancel (context .Background ())
59
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {})
68
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
60
69
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
61
70
62
71
s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ()... ).
@@ -67,7 +76,7 @@ func (s *activityTestSuite) TestActivityHeartbeat() {
67
76
68
77
func (s * activityTestSuite ) TestActivityHeartbeat_InternalError () {
69
78
ctx , cancel := context .WithCancel (context .Background ())
70
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {})
79
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
71
80
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
72
81
serviceInvoker : invoker ,
73
82
logger : getTestLogger (s .T ())})
@@ -83,7 +92,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_InternalError() {
83
92
84
93
func (s * activityTestSuite ) TestActivityHeartbeat_CancelRequested () {
85
94
ctx , cancel := context .WithCancel (context .Background ())
86
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {})
95
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
87
96
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
88
97
serviceInvoker : invoker ,
89
98
logger : getTestLogger (s .T ())})
@@ -98,7 +107,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_CancelRequested() {
98
107
99
108
func (s * activityTestSuite ) TestActivityHeartbeat_EntityNotExist () {
100
109
ctx , cancel := context .WithCancel (context .Background ())
101
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {})
110
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
102
111
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
103
112
serviceInvoker : invoker ,
104
113
logger : getTestLogger (s .T ())})
@@ -113,7 +122,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_EntityNotExist() {
113
122
114
123
func (s * activityTestSuite ) TestActivityHeartbeat_SuppressContinousInvokes () {
115
124
ctx , cancel := context .WithCancel (context .Background ())
116
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), FeatureFlags {})
125
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
117
126
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
118
127
serviceInvoker : invoker ,
119
128
logger : getTestLogger (s .T ())})
@@ -128,7 +137,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
128
137
129
138
// No HB timeout configured.
130
139
service2 := workflowservicetest .NewMockClient (s .mockCtrl )
131
- invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), FeatureFlags {})
140
+ invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
132
141
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
133
142
serviceInvoker : invoker2 ,
134
143
logger : getTestLogger (s .T ())})
@@ -141,7 +150,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
141
150
// simulate batch picks before expiry.
142
151
waitCh := make (chan struct {})
143
152
service3 := workflowservicetest .NewMockClient (s .mockCtrl )
144
- invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), FeatureFlags {})
153
+ invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
145
154
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
146
155
serviceInvoker : invoker3 ,
147
156
logger : getTestLogger (s .T ())})
@@ -171,7 +180,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
171
180
// simulate batch picks before expiry, with out any progress specified.
172
181
waitCh2 := make (chan struct {})
173
182
service4 := workflowservicetest .NewMockClient (s .mockCtrl )
174
- invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), FeatureFlags {})
183
+ invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
175
184
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
176
185
serviceInvoker : invoker4 ,
177
186
logger : getTestLogger (s .T ())})
@@ -195,7 +204,7 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
195
204
func (s * activityTestSuite ) TestActivityHeartbeat_WorkerStop () {
196
205
ctx , cancel := context .WithCancel (context .Background ())
197
206
workerStopChannel := make (chan struct {})
198
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , FeatureFlags {})
207
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , FeatureFlags {}, s . logger , testWorkflowType , testActivityType )
199
208
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
200
209
201
210
heartBeatDetail := "testDetails"
0 commit comments