@@ -22,7 +22,6 @@ package internal
22
22
23
23
import (
24
24
"context"
25
- "fmt"
26
25
"testing"
27
26
28
27
"github.com/golang/mock/gomock"
@@ -54,46 +53,41 @@ func (s *activityTestSuite) TearDownTest() {
54
53
s .mockCtrl .Finish () // assert mock’s expectations
55
54
}
56
55
57
- // this is the mock for yarpcCallOptions, make sure length are the same
58
- var callOptions = []interface {}{gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()}
59
-
60
- var featureFlags = FeatureFlags {}
61
-
62
56
func (s * activityTestSuite ) TestActivityHeartbeat () {
63
57
ctx , cancel := context .WithCancel (context .Background ())
64
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
58
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
65
59
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
66
60
67
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
61
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
68
62
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
69
63
70
64
RecordActivityHeartbeat (ctx , "testDetails" )
71
65
}
72
66
73
67
func (s * activityTestSuite ) TestActivityHeartbeat_InternalError () {
74
68
ctx , cancel := context .WithCancel (context .Background ())
75
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
69
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
76
70
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
77
71
serviceInvoker : invoker ,
78
72
logger : getTestLogger (s .T ())})
79
73
80
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
74
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
81
75
Return (nil , & shared.InternalServiceError {}).
82
76
Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
83
- fmt . Println ("MOCK RecordActivityTaskHeartbeat executed" )
77
+ s . T (). Log ("MOCK RecordActivityTaskHeartbeat executed" )
84
78
}).AnyTimes ()
85
79
86
80
RecordActivityHeartbeat (ctx , "testDetails" )
87
81
}
88
82
89
83
func (s * activityTestSuite ) TestActivityHeartbeat_CancelRequested () {
90
84
ctx , cancel := context .WithCancel (context .Background ())
91
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
85
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
92
86
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
93
87
serviceInvoker : invoker ,
94
88
logger : getTestLogger (s .T ())})
95
89
96
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
90
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
97
91
Return (& shared.RecordActivityTaskHeartbeatResponse {CancelRequested : common .BoolPtr (true )}, nil ).Times (1 )
98
92
99
93
RecordActivityHeartbeat (ctx , "testDetails" )
@@ -103,12 +97,12 @@ func (s *activityTestSuite) TestActivityHeartbeat_CancelRequested() {
103
97
104
98
func (s * activityTestSuite ) TestActivityHeartbeat_EntityNotExist () {
105
99
ctx , cancel := context .WithCancel (context .Background ())
106
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), featureFlags )
100
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 1 , make (chan struct {}), FeatureFlags {} )
107
101
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
108
102
serviceInvoker : invoker ,
109
103
logger : getTestLogger (s .T ())})
110
104
111
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
105
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
112
106
Return (& shared.RecordActivityTaskHeartbeatResponse {}, & shared.EntityNotExistsError {}).Times (1 )
113
107
114
108
RecordActivityHeartbeat (ctx , "testDetails" )
@@ -118,13 +112,13 @@ func (s *activityTestSuite) TestActivityHeartbeat_EntityNotExist() {
118
112
119
113
func (s * activityTestSuite ) TestActivityHeartbeat_SuppressContinousInvokes () {
120
114
ctx , cancel := context .WithCancel (context .Background ())
121
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), featureFlags )
115
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 2 , make (chan struct {}), FeatureFlags {} )
122
116
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
123
117
serviceInvoker : invoker ,
124
118
logger : getTestLogger (s .T ())})
125
119
126
120
// Multiple calls but only one call is made.
127
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
121
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
128
122
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
129
123
RecordActivityHeartbeat (ctx , "testDetails" )
130
124
RecordActivityHeartbeat (ctx , "testDetails" )
@@ -133,11 +127,11 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
133
127
134
128
// No HB timeout configured.
135
129
service2 := workflowservicetest .NewMockClient (s .mockCtrl )
136
- invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), featureFlags )
130
+ invoker2 := newServiceInvoker ([]byte ("task-token" ), "identity" , service2 , cancel , 0 , make (chan struct {}), FeatureFlags {} )
137
131
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
138
132
serviceInvoker : invoker2 ,
139
133
logger : getTestLogger (s .T ())})
140
- service2 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
134
+ service2 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
141
135
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
142
136
RecordActivityHeartbeat (ctx , "testDetails" )
143
137
RecordActivityHeartbeat (ctx , "testDetails" )
@@ -146,14 +140,14 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
146
140
// simulate batch picks before expiry.
147
141
waitCh := make (chan struct {})
148
142
service3 := workflowservicetest .NewMockClient (s .mockCtrl )
149
- invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), featureFlags )
143
+ invoker3 := newServiceInvoker ([]byte ("task-token" ), "identity" , service3 , cancel , 2 , make (chan struct {}), FeatureFlags {} )
150
144
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
151
145
serviceInvoker : invoker3 ,
152
146
logger : getTestLogger (s .T ())})
153
- service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
147
+ service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
154
148
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
155
149
156
- service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
150
+ service3 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
157
151
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
158
152
Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
159
153
ev := newEncodedValues (request .Details , nil )
@@ -176,13 +170,13 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
176
170
// simulate batch picks before expiry, with out any progress specified.
177
171
waitCh2 := make (chan struct {})
178
172
service4 := workflowservicetest .NewMockClient (s .mockCtrl )
179
- invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), featureFlags )
173
+ invoker4 := newServiceInvoker ([]byte ("task-token" ), "identity" , service4 , cancel , 2 , make (chan struct {}), FeatureFlags {} )
180
174
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {
181
175
serviceInvoker : invoker4 ,
182
176
logger : getTestLogger (s .T ())})
183
- service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
177
+ service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
184
178
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).Times (1 )
185
- service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
179
+ service4 .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
186
180
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
187
181
Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
188
182
require .Nil (s .T (), request .Details )
@@ -200,14 +194,14 @@ func (s *activityTestSuite) TestActivityHeartbeat_SuppressContinousInvokes() {
200
194
func (s * activityTestSuite ) TestActivityHeartbeat_WorkerStop () {
201
195
ctx , cancel := context .WithCancel (context .Background ())
202
196
workerStopChannel := make (chan struct {})
203
- invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , featureFlags )
197
+ invoker := newServiceInvoker ([]byte ("task-token" ), "identity" , s .service , cancel , 5 , workerStopChannel , FeatureFlags {} )
204
198
ctx = context .WithValue (ctx , activityEnvContextKey , & activityEnvironment {serviceInvoker : invoker })
205
199
206
200
heartBeatDetail := "testDetails"
207
201
waitCh := make (chan struct {}, 1 )
208
202
waitCh <- struct {}{}
209
203
waitC2 := make (chan struct {}, 1 )
210
- s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions ... ).
204
+ s .service .EXPECT ().RecordActivityTaskHeartbeat (gomock .Any (), gomock .Any (), callOptions () ... ).
211
205
Return (& shared.RecordActivityTaskHeartbeatResponse {}, nil ).
212
206
Do (func (ctx context.Context , request * shared.RecordActivityTaskHeartbeatRequest , opts ... yarpc.CallOption ) {
213
207
if _ , ok := <- waitCh ; ok {
0 commit comments