637
638
// TestFilteringByStatus test
640
>
testNamespaceUUID := namespace.ID(uuid.NewString())
641
>
startTime := time.Now()
642
>
executionTime := startTime
643
>
644
>
// Create 2 executions
645
>
startReq1 := s.createOpenWorkflowRecord(
646
>
testNamespaceUUID,
647
>
"visibility-filtering-test1",
648
>
"visibility-workflow",
649
>
startTime,
650
>
executionTime,
651
>
"test-queue",
652
>
)
653
>
654
>
startReq2 := s.createOpenWorkflowRecord(
655
>
testNamespaceUUID,
656
>
"visibility-filtering-test2",
657
>
"visibility-workflow",
658
>
startTime,
659
>
executionTime,
660
>
"test-queue",
661
>
)
662
>
663
>
// Close both executions with different status
664
>
closeTime := time.Now().UTC()
665
>
s.createClosedWorkflowRecord(startReq1, closeTime, enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED)
666
>
closeRecord2 := s.createClosedWorkflowRecord(
667
>
startReq2,
668
>
closeTime,
669
>
enumspb.WORKFLOW_EXECUTION_STATUS_FAILED,
670
>
)
671
>
672
>
// List closed with filtering: ListClosedWorkflowExecutionsByStatus
673
>
resp, err4 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
674
>
NamespaceID: testNamespaceUUID,
675
>
PageSize: 2,
676
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s'",
677
>
sadefs.CloseTime,
678
>
startTime.Format(time.RFC3339Nano),
679
>
sadefs.CloseTime,
680
>
time.Now().Format(time.RFC3339Nano),
681
>
sadefs.ExecutionStatus,
682
>
enumspb.WORKFLOW_EXECUTION_STATUS_FAILED,
683
>
),
684
>
})
685
>
s.NoError(err4)
686
>
s.Len(resp.Executions, 1)
687
>
s.assertClosedExecutionEquals(closeRecord2, resp.Executions[0])
688
>
689
>
resp, err := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
690
>
NamespaceID: testNamespaceUUID,
691
>
PageSize: 5,
692
>
Query: `ExecutionStatus = "Failed"`,
693
>
})
694
>
s.NoError(err)
695
>
s.Len(resp.Executions, 1)
696
>
s.assertClosedExecutionEquals(closeRecord2, resp.Executions[0])
697
>
}
698
699
// TestDelete test