457
458
// TestFilteringByType test
460
>
testNamespaceUUID := namespace.ID(uuid.NewString())
461
>
startTime := time.Now()
462
>
463
>
// Create 2 executions
464
>
openRecord1 := s.createOpenWorkflowRecord(
465
>
testNamespaceUUID,
466
>
"visibility-filtering-test1",
467
>
"visibility-workflow-1",
468
>
startTime,
469
>
startTime,
470
>
"test-queue",
471
>
)
472
>
openRecord2 := s.createOpenWorkflowRecord(
473
>
testNamespaceUUID,
474
>
"visibility-filtering-test2",
475
>
"visibility-workflow-2",
476
>
startTime,
477
>
startTime,
478
>
"test-queue",
479
>
)
480
>
481
>
// List open with filtering: ListOpenWorkflowExecutionsByType
482
>
resp, err2 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
483
>
NamespaceID: testNamespaceUUID,
484
>
PageSize: 2,
485
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s' AND %s = '%s'",
486
>
sadefs.StartTime,
487
>
startTime.Format(time.RFC3339Nano),
488
>
sadefs.StartTime,
489
>
startTime.Format(time.RFC3339Nano),
490
>
sadefs.ExecutionStatus,
491
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
492
>
sadefs.WorkflowType,
493
>
"visibility-workflow-1",
494
>
),
495
>
})
496
>
s.NoError(err2)
497
>
s.Len(resp.Executions, 1)
498
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
499
>
500
>
// List with WorkflowType filter in query string
501
>
resp, err := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
502
>
NamespaceID: testNamespaceUUID,
503
>
PageSize: 2,
504
>
Query: `WorkflowType = "visibility-workflow-1"`,
505
>
})
506
>
s.NoError(err)
507
>
s.Len(resp.Executions, 1)
508
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
509
>
510
>
// Close both executions
511
>
s.createClosedWorkflowRecord(openRecord1, time.Now(), enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED)
512
>
closedRecord2 := s.createClosedWorkflowRecord(
513
>
openRecord2,
514
>
time.Now(),
515
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
516
>
)
517
>
518
>
// List closed with filtering: ListClosedWorkflowExecutionsByType
519
>
resp, err5 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
520
>
NamespaceID: testNamespaceUUID,
521
>
PageSize: 2,
522
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s != '%s' AND %s = '%s'",
523
>
sadefs.CloseTime,
524
>
startTime.Format(time.RFC3339Nano),
525
>
sadefs.CloseTime,
526
>
time.Now().Format(time.RFC3339Nano),
527
>
sadefs.ExecutionStatus,
528
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
529
>
sadefs.WorkflowType,
530
>
"visibility-workflow-2",
531
>
),
532
>
})
533
>
s.NoError(err5)
534
>
s.Len(resp.Executions, 1)
535
>
s.assertClosedExecutionEquals(closedRecord2, resp.Executions[0])
536
>
537
>
// List with WorkflowType filter in query string
538
>
resp, err = s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
539
>
NamespaceID: testNamespaceUUID,
540
>
PageSize: 2,
541
>
Query: `WorkflowType = "visibility-workflow-2"`,
542
>
})
543
>
s.NoError(err)
544
>
s.Len(resp.Executions, 1)
545
>
s.assertClosedExecutionEquals(closedRecord2, resp.Executions[0])
546
>
}
547
548
// TestFilteringByWorkflowID test