Skip to content

Commit 6d0b6fa

Browse files
committed
Add remaining test suites
1 parent f7d16a3 commit 6d0b6fa

File tree

12 files changed

+836
-127
lines changed

12 files changed

+836
-127
lines changed

chasm/engine.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,18 @@ type ListChasmExecutionsOptions struct {
9797

9898
type ListChasmExecutionsOption func(*ListChasmExecutionsOptions)
9999

100-
func WithPagination(
100+
func WithPageSize(
101101
pageSize int,
102-
nextPageToken []byte,
103102
) ListChasmExecutionsOption {
104103
return func(req *ListChasmExecutionsOptions) {
105104
req.PageSize = pageSize
105+
}
106+
}
107+
108+
func WithNextPageToken(
109+
nextPageToken []byte,
110+
) ListChasmExecutionsOption {
111+
return func(req *ListChasmExecutionsOptions) {
106112
req.NextPageToken = nextPageToken
107113
}
108114
}

chasm/registrable_component.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,6 @@ func (rc *RegistrableComponent) SearchAttributesMapper() *VisibilitySearchAttrib
120120
return rc.searchAttributesMapper
121121
}
122122

123-
// ComponentType returns the component type name.
124-
func (rc *RegistrableComponent) ComponentType() string {
125-
return rc.componentType
126-
}
127-
128123
// fqType returns the fully qualified name of the component, which is a combination of
129124
// the library name and the component type. This is used to uniquely identify
130125
// the component in the registry.

chasm/tree_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ func (s *nodeSuite) initAssertions() {
8787
}
8888

8989
// Test helper functions to avoid hardcoded values and testvars dependency
90-
9190
func newTestEntityKey() EntityKey {
9291
return EntityKey{
9392
NamespaceID: primitives.NewUUID().String(),

common/persistence/visibility/store/elasticsearch/query_interceptors_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func (s *QueryInterceptorSuite) TestTimeProcessFunc() {
3737
vi := NewValuesInterceptor(
3838
"test-namespace",
3939
searchattribute.TestEsNameTypeMap(),
40+
nil,
4041
)
4142

4243
cases := []struct {
@@ -74,6 +75,7 @@ func (s *QueryInterceptorSuite) TestStatusProcessFunc() {
7475
vi := NewValuesInterceptor(
7576
"test-namespace",
7677
searchattribute.TestEsNameTypeMap(),
78+
nil,
7779
)
7880

7981
cases := []struct {
@@ -117,6 +119,7 @@ func (s *QueryInterceptorSuite) TestDurationProcessFunc() {
117119
vi := NewValuesInterceptor(
118120
"test-namespace",
119121
searchattribute.TestEsNameTypeMap(),
122+
nil,
120123
)
121124

122125
cases := []struct {
@@ -173,6 +176,7 @@ func (s *QueryInterceptorSuite) TestValuesInterceptor_ScheduleIDToWorkflowID() {
173176
vi := NewValuesInterceptor(
174177
"test-namespace",
175178
searchattribute.TestEsNameTypeMap(),
179+
nil,
176180
)
177181

178182
values, err := vi.Values(defs.ScheduleID, defs.WorkflowID, "test-schedule-id")
@@ -195,6 +199,7 @@ func (s *QueryInterceptorSuite) TestValuesInterceptor_NoTransformation() {
195199
vi := NewValuesInterceptor(
196200
"test-namespace",
197201
searchattribute.TestEsNameTypeMapWithScheduleID(),
202+
nil,
198203
)
199204

200205
values, err := vi.Values(defs.ScheduleID, defs.ScheduleID, "test-workflow-id")

common/persistence/visibility/store/elasticsearch/visibility_store_read_test.go

Lines changed: 461 additions & 29 deletions
Large diffs are not rendered by default.

common/persistence/visibility/store/query/converter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ func (c *QueryConverter[ExprT]) Convert(
181181
}
182182

183183
// If the query did not explicitly filter on TemporalNamespaceDivision,
184-
// try setting the namespace division filter based on the archetype ID.
185-
// Else, filter by null (no division).
184+
// try setting the namespace division filter based on the archetype ID,
185+
// else filter by null (no division).
186186
var namespaceDivisionExpr ExprT
187187
if !c.seenNamespaceDivision {
188188
nsDivisionCol := NamespaceDivisionSAColumn()

common/persistence/visibility/store/sql/query_converter_legacy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ func (c *QueryConverterLegacy) convertSelectStmt(sel *sqlparser.Select) error {
231231

232232
// This logic comes from elasticsearch/visibility_store.go#convertQuery function.
233233
// If the query did not explicitly filter on TemporalNamespaceDivision,
234-
// handle it based on whether we have an archetype ID.
234+
// try setting the namespace division filter based on the archetype ID,
235+
// else filter by null (no division).
235236
if !c.seenNamespaceDivision {
236237
var namespaceDivisionExpr sqlparser.Expr
237238
if c.archetypeID != chasm.UnspecifiedArchetypeID {

common/persistence/visibility/store/sql/query_converter_legacy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (s *queryConverterSuite) SetupTest() {
5454
&searchattribute.TestMapper{},
5555
"",
5656
nil,
57-
0,
57+
chasm.UnspecifiedArchetypeID,
5858
)
5959
}
6060

common/persistence/visibility/store/visibility_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ type (
7070
RootRunID string
7171
}
7272

73-
// InternalListWorkflowExecutionsResponse is response from InternalListWorkflowExecutions
73+
// InternalListWorkflowExecutionsResponse is response from ListWorkflowExecutions and ListChasmExecutions
7474
InternalListWorkflowExecutionsResponse struct {
7575
Executions []*InternalWorkflowExecutionInfo
7676
// Token to read next page if there are more workflow executions beyond page size.
7777
// Use this to set NextPageToken on ListWorkflowExecutionsRequest to read the next page.
7878
NextPageToken []byte
7979
}
8080

81-
// InternalGetWorkflowExecutionResponse is response from InternalGetWorkflowExecution
81+
// InternalGetWorkflowExecutionResponse is response from GetWorkflowExecution
8282
InternalGetWorkflowExecutionResponse struct {
8383
Execution *InternalWorkflowExecutionInfo
8484
}

service/history/chasm_engine.go

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import (
55
"errors"
66
"fmt"
77
"reflect"
8-
"time"
98

109
commonpb "go.temporal.io/api/common/v1"
11-
1210
enumspb "go.temporal.io/api/enums/v1"
1311
"go.temporal.io/api/serviceerror"
1412
enumsspb "go.temporal.io/server/api/enums/v1"
@@ -659,20 +657,17 @@ func (e *ChasmEngine) ListExecutions(
659657
Query: request.Query,
660658
}
661659

660+
if visReq.PageSize <= 0 {
661+
visReq.PageSize = int(e.config.HistoryMaxPageSize(request.NamespaceName))
662+
}
663+
662664
resp, err := e.visibilityMgr.ListChasmExecutions(ctx, visReq)
663665
if err != nil {
664666
return nil, err
665667
}
666668

667-
// Convert manager.ListChasmExecutionsResponse to chasm.ListChasmRunsResponse
668669
executions := make([]*chasm.ChasmExecutionInfo[*commonpb.Payload], len(resp.Executions))
669670
for i, exec := range resp.Executions {
670-
// Convert map[string]interface{} to SearchAttributesMap
671-
chasmSAValues := make(map[string]chasm.VisibilityValue, len(exec.ChasmSearchAttributes))
672-
for k, v := range exec.ChasmSearchAttributes {
673-
chasmSAValues[k] = convertToVisibilityValue(v)
674-
}
675-
676671
executions[i] = &chasm.ChasmExecutionInfo[*commonpb.Payload]{
677672
BusinessID: exec.BusinessID,
678673
RunID: exec.RunID,
@@ -681,7 +676,7 @@ func (e *ChasmEngine) ListExecutions(
681676
HistoryLength: exec.HistoryLength,
682677
HistorySizeBytes: exec.HistorySizeBytes,
683678
StateTransitionCount: exec.StateTransitionCount,
684-
ChasmSearchAttributes: chasm.NewSearchAttributesMap(chasmSAValues),
679+
ChasmSearchAttributes: chasm.NewSearchAttributesMap(exec.ChasmSearchAttributes),
685680
CustomSearchAttributes: exec.CustomSearchAttributes,
686681
Memo: exec.Memo,
687682
ChasmMemo: exec.ChasmMemo,
@@ -717,29 +712,3 @@ func (e *ChasmEngine) CountExecutions(
717712

718713
return &chasm.CountChasmExecutionsResponse{Count: resp.Count}, nil
719714
}
720-
721-
func convertToVisibilityValue(v interface{}) chasm.VisibilityValue {
722-
switch val := v.(type) {
723-
case int:
724-
return chasm.VisibilityValueInt64(int64(val))
725-
case int32:
726-
return chasm.VisibilityValueInt64(int64(val))
727-
case int64:
728-
return chasm.VisibilityValueInt64(val)
729-
case string:
730-
return chasm.VisibilityValueString(val)
731-
case bool:
732-
return chasm.VisibilityValueBool(val)
733-
case float64:
734-
return chasm.VisibilityValueFloat64(val)
735-
case time.Time:
736-
return chasm.VisibilityValueTime(val)
737-
case []byte:
738-
return chasm.VisibilityValueByteSlice(val)
739-
case []string:
740-
return chasm.VisibilityValueStringSlice(val)
741-
default:
742-
// Return as string if type is unknown
743-
return chasm.VisibilityValueString(fmt.Sprintf("%v", val))
744-
}
745-
}

0 commit comments

Comments
 (0)