@@ -194,7 +194,7 @@ func testActivityMultipleArgsWithStruct(_ context.Context, i int, s testActivity
194
194
}
195
195
196
196
func (s * internalWorkerTestSuite ) TestCreateWorker () {
197
- worker := createWorkerWithThrottle (s .service , float64 (500.0 ), nil )
197
+ worker := createWorkerWithThrottle (s .service , float64 (500.0 ), nil , nil )
198
198
err := worker .Start ()
199
199
require .NoError (s .T (), err )
200
200
time .Sleep (time .Millisecond * 200 )
@@ -209,6 +209,14 @@ func (s *internalWorkerTestSuite) TestCreateWorker_WithDataConverter() {
209
209
worker .Stop ()
210
210
}
211
211
212
+ func (s * internalWorkerTestSuite ) TestCreateShadowWorker () {
213
+ worker := createShadowWorker (s .service , & ShadowOptions {})
214
+ s .Nil (worker .workflowWorker )
215
+ s .Nil (worker .activityWorker )
216
+ s .Nil (worker .locallyDispatchedActivityWorker )
217
+ s .Nil (worker .sessionWorker )
218
+ }
219
+
212
220
func (s * internalWorkerTestSuite ) TestCreateWorkerRun () {
213
221
// Create service endpoint
214
222
mockCtrl := gomock .NewController (s .T ())
@@ -278,6 +286,24 @@ func (s *internalWorkerTestSuite) TestWorkerStartFailsWithInvalidDomain() {
278
286
}
279
287
}
280
288
289
+ func (s * internalWorkerTestSuite ) TestStartShadowWorkerFailWithInvalidOptions () {
290
+ invalidOptions := []* ShadowOptions {
291
+ {
292
+ Mode : ShadowModeContinuous ,
293
+ },
294
+ {
295
+ WorkflowQuery : "workflow query" ,
296
+ WorkflowTypes : []string {"workflowTypeName" },
297
+ },
298
+ }
299
+
300
+ for _ , opt := range invalidOptions {
301
+ worker := createShadowWorker (s .service , opt )
302
+ err := worker .Start ()
303
+ assert .Error (s .T (), err , "worker.Start() should fail given invalid shadow options" )
304
+ }
305
+ }
306
+
281
307
func ofPollForActivityTaskRequest (tps float64 ) gomock.Matcher {
282
308
return & mockPollForActivityTaskRequest {tps : tps }
283
309
}
@@ -298,12 +324,24 @@ func (m *mockPollForActivityTaskRequest) String() string {
298
324
return "PollForActivityTaskRequest"
299
325
}
300
326
301
- func createWorker (service * workflowservicetest.MockClient ) * aggregatedWorker {
302
- return createWorkerWithThrottle (service , float64 (0.0 ), nil )
327
+ func createWorker (
328
+ service * workflowservicetest.MockClient ,
329
+ ) * aggregatedWorker {
330
+ return createWorkerWithThrottle (service , float64 (0.0 ), nil , nil )
331
+ }
332
+
333
+ func createShadowWorker (
334
+ service * workflowservicetest.MockClient ,
335
+ shadowOptions * ShadowOptions ,
336
+ ) * aggregatedWorker {
337
+ return createWorkerWithThrottle (service , float64 (0.0 ), nil , shadowOptions )
303
338
}
304
339
305
340
func createWorkerWithThrottle (
306
- service * workflowservicetest.MockClient , activitiesPerSecond float64 , dc DataConverter ,
341
+ service * workflowservicetest.MockClient ,
342
+ activitiesPerSecond float64 ,
343
+ dc DataConverter ,
344
+ shadowOptions * ShadowOptions ,
307
345
) * aggregatedWorker {
308
346
domain := "testDomain"
309
347
domainStatus := shared .DomainStatusRegistered
@@ -342,6 +380,11 @@ func createWorkerWithThrottle(
342
380
}
343
381
workerOptions .EnableSessionWorker = true
344
382
383
+ if shadowOptions != nil {
384
+ workerOptions .EnableShadowWorker = true
385
+ workerOptions .ShadowOptions = shadowOptions
386
+ }
387
+
345
388
// Start Worker.
346
389
worker := NewWorker (
347
390
service ,
@@ -351,8 +394,10 @@ func createWorkerWithThrottle(
351
394
return worker
352
395
}
353
396
354
- func createWorkerWithDataConverter (service * workflowservicetest.MockClient ) * aggregatedWorker {
355
- return createWorkerWithThrottle (service , float64 (0.0 ), newTestDataConverter ())
397
+ func createWorkerWithDataConverter (
398
+ service * workflowservicetest.MockClient ,
399
+ ) * aggregatedWorker {
400
+ return createWorkerWithThrottle (service , float64 (0.0 ), newTestDataConverter (), nil )
356
401
}
357
402
358
403
func (s * internalWorkerTestSuite ) testCompleteActivityHelper (opt * ClientOptions ) {
0 commit comments