547
548
// TestFilteringByWorkflowID test
550
>
testNamespaceUUID := namespace.ID(uuid.NewString())
551
>
startTime := time.Now()
552
>
553
>
// Create 2 executions
554
>
openRecord1 := s.createOpenWorkflowRecord(
555
>
testNamespaceUUID,
556
>
"visibility-filtering-test1",
557
>
"visibility-workflow",
558
>
startTime,
559
>
startTime,
560
>
"test-queue",
561
>
)
562
>
openRecord2 := s.createOpenWorkflowRecord(
563
>
testNamespaceUUID,
564
>
"visibility-filtering-test2",
565
>
"visibility-workflow",
566
>
startTime,
567
>
startTime,
568
>
"test-queue",
569
>
)
570
>
571
>
// List open with filtering: ListOpenWorkflowExecutionsByWorkflowID
572
>
resp, err2 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
573
>
NamespaceID: testNamespaceUUID,
574
>
PageSize: 2,
575
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s' AND %s = '%s'",
576
>
sadefs.StartTime,
577
>
startTime.Format(time.RFC3339Nano),
578
>
sadefs.StartTime,
579
>
startTime.Format(time.RFC3339Nano),
580
>
sadefs.ExecutionStatus,
581
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
582
>
sadefs.WorkflowID,
583
>
"visibility-filtering-test1",
584
>
),
585
>
})
586
>
s.NoError(err2)
587
>
s.Len(resp.Executions, 1)
588
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
589
>
590
>
// List workflow with workflowID filter in query string
591
>
resp, err := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
592
>
NamespaceID: testNamespaceUUID,
593
>
PageSize: 2,
594
>
Query: `WorkflowId = "visibility-filtering-test1"`,
595
>
})
596
>
s.NoError(err)
597
>
s.Len(resp.Executions, 1)
598
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
599
>
600
>
// Close both executions
601
>
s.createClosedWorkflowRecord(openRecord1, time.Now(), enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED)
602
>
closedRecord2 := s.createClosedWorkflowRecord(
603
>
openRecord2,
604
>
time.Now(),
605
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
606
>
)
607
>
608
>
// List closed with filtering: ListClosedWorkflowExecutionsByWorkflowID
609
>
resp, err5 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
610
>
NamespaceID: testNamespaceUUID,
611
>
PageSize: 2,
612
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s != '%s' AND %s = '%s'",
613
>
sadefs.CloseTime,
614
>
startTime.Format(time.RFC3339Nano),
615
>
sadefs.CloseTime,
616
>
time.Now().Format(time.RFC3339Nano),
617
>
sadefs.ExecutionStatus,
618
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
619
>
sadefs.WorkflowID,
620
>
"visibility-filtering-test2",
621
>
),
622
>
})
623
>
s.NoError(err5)
624
>
s.Len(resp.Executions, 1)
625
>
s.assertClosedExecutionEquals(closedRecord2, resp.Executions[0])
626
>
627
>
// List workflow with workflowID filter in query string
628
>
resp, err = s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
629
>
NamespaceID: testNamespaceUUID,
630
>
PageSize: 2,
631
>
Query: `WorkflowId = "visibility-filtering-test2"`,
632
>
})
633
>
s.NoError(err)
634
>
s.Len(resp.Executions, 1)
635
>
s.assertClosedExecutionEquals(closedRecord2, resp.Executions[0])
636
>
}
637
638
// TestFilteringByStatus test