387
388
// TestFilteringByStartTime test
390
>
testNamespaceUUID := namespace.ID(uuid.NewString())
391
>
startTime := time.Now()
392
>
393
>
// Create 2 open workflows, one started 2hrs ago, the other started just now.
394
>
openRecord1 := s.createOpenWorkflowRecord(
395
>
testNamespaceUUID,
396
>
"visibility-filtering-test1",
397
>
"visibility-workflow-1",
398
>
startTime.Add(-2*time.Hour),
399
>
startTime.Add(-2*time.Hour),
400
>
"test-queue",
401
>
)
402
>
openRecord2 := s.createOpenWorkflowRecord(
403
>
testNamespaceUUID,
404
>
"visibility-filtering-test2",
405
>
"visibility-workflow-2",
406
>
startTime,
407
>
startTime,
408
>
"test-queue",
409
>
)
410
>
411
>
// List open workflows with start time filter
412
>
resp, err := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
413
>
NamespaceID: testNamespaceUUID,
414
>
PageSize: 2,
415
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s'",
416
>
sadefs.StartTime,
417
>
time.Now().Add(-time.Hour).Format(time.RFC3339Nano),
418
>
sadefs.StartTime,
419
>
time.Now().Format(time.RFC3339Nano),
420
>
sadefs.ExecutionStatus,
421
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
422
>
),
423
>
})
424
>
s.NoError(err)
425
>
s.Len(resp.Executions, 1)
426
>
s.assertOpenExecutionEquals(openRecord2, resp.Executions[0])
427
>
428
>
// List with WorkflowType filter in query string
429
>
queryStr := fmt.Sprintf(`StartTime BETWEEN "%v" AND "%v"`, time.Now().Add(-time.Hour).Format(time.RFC3339Nano), time.Now().Format(time.RFC3339Nano))
430
>
resp, err = s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
431
>
NamespaceID: testNamespaceUUID,
432
>
PageSize: 2,
433
>
Query: queryStr,
434
>
})
435
>
s.NoError(err)
436
>
s.Len(resp.Executions, 1)
437
>
s.assertOpenExecutionEquals(openRecord2, resp.Executions[0])
438
>
439
>
queryStr = fmt.Sprintf(`StartTime BETWEEN "%v" AND "%v"`, time.Now().Add(-3*time.Hour).Format(time.RFC3339Nano), time.Now().Format(time.RFC3339Nano))
440
>
resp, err = s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
441
>
NamespaceID: testNamespaceUUID,
442
>
PageSize: 2,
443
>
Query: queryStr,
444
>
})
445
>
s.NoError(err)
446
>
s.Len(resp.Executions, 2)
447
>
448
>
resp, err = s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
449
>
NamespaceID: testNamespaceUUID,
450
>
PageSize: 2,
451
>
Query: queryStr + ` AND WorkflowType = "visibility-workflow-1"`,
452
>
})
453
>
s.NoError(err)
454
>
s.Len(resp.Executions, 1)
455
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
456
>
}
457
458
// TestFilteringByType test