From 2b0fabc9881852f6b0b3f45e2d365ca00b77ff81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Ca=C3=A7ador?= Date: Thu, 17 Oct 2024 18:51:25 +0100 Subject: [PATCH] IWF-137: Allow to use separate persistency loading policy for waitUntil (#448) --- Makefile | 2 +- gen/iwfidl/api/openapi.yaml | 332 ++++++++++++++++ gen/iwfidl/docs/WorkflowStateOptions.md | 104 +++++ gen/iwfidl/model_workflow_state_options.go | 180 ++++++++- ...te_options_data_attributes_loading_test.go | 93 +++++ ..._options_search_attributes_loading_test.go | 93 +++++ .../routers.go | 356 ++++++++++++++++++ .../routers.go | 350 +++++++++++++++++ iwf-idl | 2 +- service/common/compatibility/stateOptions.go | 56 ++- service/interpreter/workflowImpl.go | 8 +- 11 files changed, 1548 insertions(+), 28 deletions(-) create mode 100644 integ/wf_state_options_data_attributes_loading_test.go create mode 100644 integ/wf_state_options_search_attributes_loading_test.go create mode 100644 integ/workflow/wf_state_options_data_attributes_loading/routers.go create mode 100644 integ/workflow/wf_state_options_search_attributes_loading/routers.go diff --git a/Makefile b/Makefile index 00db06d1..b1ff37c5 100644 --- a/Makefile +++ b/Makefile @@ -138,7 +138,7 @@ iwf-server: .PHONY: bins release clean -idl-code-gen: #generate/refresh go clent code for idl, do this after update the idl file +idl-code-gen: #generate/refresh go code for idl (API schema), do this after updating the idl file rm -Rf ./gen ; true java -jar openapi-generator-cli-6.6.0.jar generate -i iwf-idl/iwf.yaml -g go -o gen/iwfidl/ -p packageName=iwfidl -p generateInterfaces=true -p isGoSubmodule=false --git-user-id indeedeng --git-repo-id iwf-idl rm ./gen/iwfidl/go.* ; rm -rf ./gen/iwfidl/test; gofmt -s -w gen; true diff --git a/gen/iwfidl/api/openapi.yaml b/gen/iwfidl/api/openapi.yaml index f52b178f..4120b0e4 100644 --- a/gen/iwfidl/api/openapi.yaml +++ b/gen/iwfidl/api/openapi.yaml @@ -572,6 +572,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -580,6 +589,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -589,8 +607,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -600,6 +636,10 @@ components: properties: searchAttributesLoadingPolicy: $ref: '#/components/schemas/PersistenceLoadingPolicy' + waitUntilApiSearchAttributesLoadingPolicy: + $ref: '#/components/schemas/PersistenceLoadingPolicy' + executeApiSearchAttributesLoadingPolicy: + $ref: '#/components/schemas/PersistenceLoadingPolicy' dataObjectsLoadingPolicy: $ref: '#/components/schemas/PersistenceLoadingPolicy' startApiTimeoutSeconds: @@ -634,6 +674,10 @@ components: type: boolean dataAttributesLoadingPolicy: $ref: '#/components/schemas/PersistenceLoadingPolicy' + waitUntilApiDataAttributesLoadingPolicy: + $ref: '#/components/schemas/PersistenceLoadingPolicy' + executeApiDataAttributesLoadingPolicy: + $ref: '#/components/schemas/PersistenceLoadingPolicy' type: object WorkflowStartOptions: example: @@ -842,6 +886,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -850,6 +903,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -859,8 +921,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -1623,6 +1703,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -1631,6 +1720,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -1640,8 +1738,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -1691,6 +1807,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -1699,6 +1824,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -1708,8 +1842,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2081,6 +2233,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2089,6 +2250,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -2098,8 +2268,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2149,6 +2337,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2157,6 +2354,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -2166,8 +2372,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2325,6 +2549,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2333,6 +2566,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -2342,8 +2584,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2393,6 +2653,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2401,6 +2670,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -2410,8 +2688,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2498,6 +2794,15 @@ components: - partialLoadingKeys - partialLoadingKeys persistenceLoadingType: null + executeApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null decideApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 @@ -2506,6 +2811,15 @@ components: backoffCoefficient: 5.637377 executeApiFailureProceedStateId: executeApiFailureProceedStateId decideApiTimeoutSeconds: 1 + executeApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null startApiTimeoutSeconds: 6 executeApiFailurePolicy: null executeApiFailureProceedStateOptions: null @@ -2515,8 +2829,26 @@ components: initialIntervalSeconds: 5 maximumIntervalSeconds: 2 backoffCoefficient: 5.637377 + waitUntilApiSearchAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null skipStartApi: true waitUntilApiTimeoutSeconds: 3 + waitUntilApiDataAttributesLoadingPolicy: + lockingKeys: + - lockingKeys + - lockingKeys + useKeyAsPrefix: true + partialLoadingKeys: + - partialLoadingKeys + - partialLoadingKeys + persistenceLoadingType: null executeApiRetryPolicy: maximumAttemptsDurationSeconds: 9 maximumAttempts: 7 diff --git a/gen/iwfidl/docs/WorkflowStateOptions.md b/gen/iwfidl/docs/WorkflowStateOptions.md index 936683a2..1a7dcb9b 100644 --- a/gen/iwfidl/docs/WorkflowStateOptions.md +++ b/gen/iwfidl/docs/WorkflowStateOptions.md @@ -5,6 +5,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **SearchAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] +**WaitUntilApiSearchAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] +**ExecuteApiSearchAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] **DataObjectsLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] **StartApiTimeoutSeconds** | Pointer to **int32** | | [optional] **DecideApiTimeoutSeconds** | Pointer to **int32** | | [optional] @@ -22,6 +24,8 @@ Name | Type | Description | Notes **WaitUntilApiFailurePolicy** | Pointer to [**WaitUntilApiFailurePolicy**](WaitUntilApiFailurePolicy.md) | | [optional] **SkipWaitUntil** | Pointer to **bool** | | [optional] **DataAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] +**WaitUntilApiDataAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] +**ExecuteApiDataAttributesLoadingPolicy** | Pointer to [**PersistenceLoadingPolicy**](PersistenceLoadingPolicy.md) | | [optional] ## Methods @@ -67,6 +71,56 @@ SetSearchAttributesLoadingPolicy sets SearchAttributesLoadingPolicy field to giv HasSearchAttributesLoadingPolicy returns a boolean if a field has been set. +### GetWaitUntilApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) GetWaitUntilApiSearchAttributesLoadingPolicy() PersistenceLoadingPolicy` + +GetWaitUntilApiSearchAttributesLoadingPolicy returns the WaitUntilApiSearchAttributesLoadingPolicy field if non-nil, zero value otherwise. + +### GetWaitUntilApiSearchAttributesLoadingPolicyOk + +`func (o *WorkflowStateOptions) GetWaitUntilApiSearchAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool)` + +GetWaitUntilApiSearchAttributesLoadingPolicyOk returns a tuple with the WaitUntilApiSearchAttributesLoadingPolicy field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetWaitUntilApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) SetWaitUntilApiSearchAttributesLoadingPolicy(v PersistenceLoadingPolicy)` + +SetWaitUntilApiSearchAttributesLoadingPolicy sets WaitUntilApiSearchAttributesLoadingPolicy field to given value. + +### HasWaitUntilApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) HasWaitUntilApiSearchAttributesLoadingPolicy() bool` + +HasWaitUntilApiSearchAttributesLoadingPolicy returns a boolean if a field has been set. + +### GetExecuteApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) GetExecuteApiSearchAttributesLoadingPolicy() PersistenceLoadingPolicy` + +GetExecuteApiSearchAttributesLoadingPolicy returns the ExecuteApiSearchAttributesLoadingPolicy field if non-nil, zero value otherwise. + +### GetExecuteApiSearchAttributesLoadingPolicyOk + +`func (o *WorkflowStateOptions) GetExecuteApiSearchAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool)` + +GetExecuteApiSearchAttributesLoadingPolicyOk returns a tuple with the ExecuteApiSearchAttributesLoadingPolicy field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetExecuteApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) SetExecuteApiSearchAttributesLoadingPolicy(v PersistenceLoadingPolicy)` + +SetExecuteApiSearchAttributesLoadingPolicy sets ExecuteApiSearchAttributesLoadingPolicy field to given value. + +### HasExecuteApiSearchAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) HasExecuteApiSearchAttributesLoadingPolicy() bool` + +HasExecuteApiSearchAttributesLoadingPolicy returns a boolean if a field has been set. + ### GetDataObjectsLoadingPolicy `func (o *WorkflowStateOptions) GetDataObjectsLoadingPolicy() PersistenceLoadingPolicy` @@ -492,6 +546,56 @@ SetDataAttributesLoadingPolicy sets DataAttributesLoadingPolicy field to given v HasDataAttributesLoadingPolicy returns a boolean if a field has been set. +### GetWaitUntilApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) GetWaitUntilApiDataAttributesLoadingPolicy() PersistenceLoadingPolicy` + +GetWaitUntilApiDataAttributesLoadingPolicy returns the WaitUntilApiDataAttributesLoadingPolicy field if non-nil, zero value otherwise. + +### GetWaitUntilApiDataAttributesLoadingPolicyOk + +`func (o *WorkflowStateOptions) GetWaitUntilApiDataAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool)` + +GetWaitUntilApiDataAttributesLoadingPolicyOk returns a tuple with the WaitUntilApiDataAttributesLoadingPolicy field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetWaitUntilApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) SetWaitUntilApiDataAttributesLoadingPolicy(v PersistenceLoadingPolicy)` + +SetWaitUntilApiDataAttributesLoadingPolicy sets WaitUntilApiDataAttributesLoadingPolicy field to given value. + +### HasWaitUntilApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) HasWaitUntilApiDataAttributesLoadingPolicy() bool` + +HasWaitUntilApiDataAttributesLoadingPolicy returns a boolean if a field has been set. + +### GetExecuteApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) GetExecuteApiDataAttributesLoadingPolicy() PersistenceLoadingPolicy` + +GetExecuteApiDataAttributesLoadingPolicy returns the ExecuteApiDataAttributesLoadingPolicy field if non-nil, zero value otherwise. + +### GetExecuteApiDataAttributesLoadingPolicyOk + +`func (o *WorkflowStateOptions) GetExecuteApiDataAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool)` + +GetExecuteApiDataAttributesLoadingPolicyOk returns a tuple with the ExecuteApiDataAttributesLoadingPolicy field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetExecuteApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) SetExecuteApiDataAttributesLoadingPolicy(v PersistenceLoadingPolicy)` + +SetExecuteApiDataAttributesLoadingPolicy sets ExecuteApiDataAttributesLoadingPolicy field to given value. + +### HasExecuteApiDataAttributesLoadingPolicy + +`func (o *WorkflowStateOptions) HasExecuteApiDataAttributesLoadingPolicy() bool` + +HasExecuteApiDataAttributesLoadingPolicy returns a boolean if a field has been set. + [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/gen/iwfidl/model_workflow_state_options.go b/gen/iwfidl/model_workflow_state_options.go index cce01166..8a76e07b 100644 --- a/gen/iwfidl/model_workflow_state_options.go +++ b/gen/iwfidl/model_workflow_state_options.go @@ -19,24 +19,28 @@ var _ MappedNullable = &WorkflowStateOptions{} // WorkflowStateOptions struct for WorkflowStateOptions type WorkflowStateOptions struct { - SearchAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"searchAttributesLoadingPolicy,omitempty"` - DataObjectsLoadingPolicy *PersistenceLoadingPolicy `json:"dataObjectsLoadingPolicy,omitempty"` - StartApiTimeoutSeconds *int32 `json:"startApiTimeoutSeconds,omitempty"` - DecideApiTimeoutSeconds *int32 `json:"decideApiTimeoutSeconds,omitempty"` - StartApiRetryPolicy *RetryPolicy `json:"startApiRetryPolicy,omitempty"` - DecideApiRetryPolicy *RetryPolicy `json:"decideApiRetryPolicy,omitempty"` - StartApiFailurePolicy *StartApiFailurePolicy `json:"startApiFailurePolicy,omitempty"` - ExecuteApiFailurePolicy *ExecuteApiFailurePolicy `json:"executeApiFailurePolicy,omitempty"` - ExecuteApiFailureProceedStateId *string `json:"executeApiFailureProceedStateId,omitempty"` - ExecuteApiFailureProceedStateOptions *WorkflowStateOptions `json:"executeApiFailureProceedStateOptions,omitempty"` - SkipStartApi *bool `json:"skipStartApi,omitempty"` - WaitUntilApiTimeoutSeconds *int32 `json:"waitUntilApiTimeoutSeconds,omitempty"` - ExecuteApiTimeoutSeconds *int32 `json:"executeApiTimeoutSeconds,omitempty"` - WaitUntilApiRetryPolicy *RetryPolicy `json:"waitUntilApiRetryPolicy,omitempty"` - ExecuteApiRetryPolicy *RetryPolicy `json:"executeApiRetryPolicy,omitempty"` - WaitUntilApiFailurePolicy *WaitUntilApiFailurePolicy `json:"waitUntilApiFailurePolicy,omitempty"` - SkipWaitUntil *bool `json:"skipWaitUntil,omitempty"` - DataAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"dataAttributesLoadingPolicy,omitempty"` + SearchAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"searchAttributesLoadingPolicy,omitempty"` + WaitUntilApiSearchAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"waitUntilApiSearchAttributesLoadingPolicy,omitempty"` + ExecuteApiSearchAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"executeApiSearchAttributesLoadingPolicy,omitempty"` + DataObjectsLoadingPolicy *PersistenceLoadingPolicy `json:"dataObjectsLoadingPolicy,omitempty"` + StartApiTimeoutSeconds *int32 `json:"startApiTimeoutSeconds,omitempty"` + DecideApiTimeoutSeconds *int32 `json:"decideApiTimeoutSeconds,omitempty"` + StartApiRetryPolicy *RetryPolicy `json:"startApiRetryPolicy,omitempty"` + DecideApiRetryPolicy *RetryPolicy `json:"decideApiRetryPolicy,omitempty"` + StartApiFailurePolicy *StartApiFailurePolicy `json:"startApiFailurePolicy,omitempty"` + ExecuteApiFailurePolicy *ExecuteApiFailurePolicy `json:"executeApiFailurePolicy,omitempty"` + ExecuteApiFailureProceedStateId *string `json:"executeApiFailureProceedStateId,omitempty"` + ExecuteApiFailureProceedStateOptions *WorkflowStateOptions `json:"executeApiFailureProceedStateOptions,omitempty"` + SkipStartApi *bool `json:"skipStartApi,omitempty"` + WaitUntilApiTimeoutSeconds *int32 `json:"waitUntilApiTimeoutSeconds,omitempty"` + ExecuteApiTimeoutSeconds *int32 `json:"executeApiTimeoutSeconds,omitempty"` + WaitUntilApiRetryPolicy *RetryPolicy `json:"waitUntilApiRetryPolicy,omitempty"` + ExecuteApiRetryPolicy *RetryPolicy `json:"executeApiRetryPolicy,omitempty"` + WaitUntilApiFailurePolicy *WaitUntilApiFailurePolicy `json:"waitUntilApiFailurePolicy,omitempty"` + SkipWaitUntil *bool `json:"skipWaitUntil,omitempty"` + DataAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"dataAttributesLoadingPolicy,omitempty"` + WaitUntilApiDataAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"waitUntilApiDataAttributesLoadingPolicy,omitempty"` + ExecuteApiDataAttributesLoadingPolicy *PersistenceLoadingPolicy `json:"executeApiDataAttributesLoadingPolicy,omitempty"` } // NewWorkflowStateOptions instantiates a new WorkflowStateOptions object @@ -88,6 +92,70 @@ func (o *WorkflowStateOptions) SetSearchAttributesLoadingPolicy(v PersistenceLoa o.SearchAttributesLoadingPolicy = &v } +// GetWaitUntilApiSearchAttributesLoadingPolicy returns the WaitUntilApiSearchAttributesLoadingPolicy field value if set, zero value otherwise. +func (o *WorkflowStateOptions) GetWaitUntilApiSearchAttributesLoadingPolicy() PersistenceLoadingPolicy { + if o == nil || IsNil(o.WaitUntilApiSearchAttributesLoadingPolicy) { + var ret PersistenceLoadingPolicy + return ret + } + return *o.WaitUntilApiSearchAttributesLoadingPolicy +} + +// GetWaitUntilApiSearchAttributesLoadingPolicyOk returns a tuple with the WaitUntilApiSearchAttributesLoadingPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowStateOptions) GetWaitUntilApiSearchAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool) { + if o == nil || IsNil(o.WaitUntilApiSearchAttributesLoadingPolicy) { + return nil, false + } + return o.WaitUntilApiSearchAttributesLoadingPolicy, true +} + +// HasWaitUntilApiSearchAttributesLoadingPolicy returns a boolean if a field has been set. +func (o *WorkflowStateOptions) HasWaitUntilApiSearchAttributesLoadingPolicy() bool { + if o != nil && !IsNil(o.WaitUntilApiSearchAttributesLoadingPolicy) { + return true + } + + return false +} + +// SetWaitUntilApiSearchAttributesLoadingPolicy gets a reference to the given PersistenceLoadingPolicy and assigns it to the WaitUntilApiSearchAttributesLoadingPolicy field. +func (o *WorkflowStateOptions) SetWaitUntilApiSearchAttributesLoadingPolicy(v PersistenceLoadingPolicy) { + o.WaitUntilApiSearchAttributesLoadingPolicy = &v +} + +// GetExecuteApiSearchAttributesLoadingPolicy returns the ExecuteApiSearchAttributesLoadingPolicy field value if set, zero value otherwise. +func (o *WorkflowStateOptions) GetExecuteApiSearchAttributesLoadingPolicy() PersistenceLoadingPolicy { + if o == nil || IsNil(o.ExecuteApiSearchAttributesLoadingPolicy) { + var ret PersistenceLoadingPolicy + return ret + } + return *o.ExecuteApiSearchAttributesLoadingPolicy +} + +// GetExecuteApiSearchAttributesLoadingPolicyOk returns a tuple with the ExecuteApiSearchAttributesLoadingPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowStateOptions) GetExecuteApiSearchAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool) { + if o == nil || IsNil(o.ExecuteApiSearchAttributesLoadingPolicy) { + return nil, false + } + return o.ExecuteApiSearchAttributesLoadingPolicy, true +} + +// HasExecuteApiSearchAttributesLoadingPolicy returns a boolean if a field has been set. +func (o *WorkflowStateOptions) HasExecuteApiSearchAttributesLoadingPolicy() bool { + if o != nil && !IsNil(o.ExecuteApiSearchAttributesLoadingPolicy) { + return true + } + + return false +} + +// SetExecuteApiSearchAttributesLoadingPolicy gets a reference to the given PersistenceLoadingPolicy and assigns it to the ExecuteApiSearchAttributesLoadingPolicy field. +func (o *WorkflowStateOptions) SetExecuteApiSearchAttributesLoadingPolicy(v PersistenceLoadingPolicy) { + o.ExecuteApiSearchAttributesLoadingPolicy = &v +} + // GetDataObjectsLoadingPolicy returns the DataObjectsLoadingPolicy field value if set, zero value otherwise. func (o *WorkflowStateOptions) GetDataObjectsLoadingPolicy() PersistenceLoadingPolicy { if o == nil || IsNil(o.DataObjectsLoadingPolicy) { @@ -632,6 +700,70 @@ func (o *WorkflowStateOptions) SetDataAttributesLoadingPolicy(v PersistenceLoadi o.DataAttributesLoadingPolicy = &v } +// GetWaitUntilApiDataAttributesLoadingPolicy returns the WaitUntilApiDataAttributesLoadingPolicy field value if set, zero value otherwise. +func (o *WorkflowStateOptions) GetWaitUntilApiDataAttributesLoadingPolicy() PersistenceLoadingPolicy { + if o == nil || IsNil(o.WaitUntilApiDataAttributesLoadingPolicy) { + var ret PersistenceLoadingPolicy + return ret + } + return *o.WaitUntilApiDataAttributesLoadingPolicy +} + +// GetWaitUntilApiDataAttributesLoadingPolicyOk returns a tuple with the WaitUntilApiDataAttributesLoadingPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowStateOptions) GetWaitUntilApiDataAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool) { + if o == nil || IsNil(o.WaitUntilApiDataAttributesLoadingPolicy) { + return nil, false + } + return o.WaitUntilApiDataAttributesLoadingPolicy, true +} + +// HasWaitUntilApiDataAttributesLoadingPolicy returns a boolean if a field has been set. +func (o *WorkflowStateOptions) HasWaitUntilApiDataAttributesLoadingPolicy() bool { + if o != nil && !IsNil(o.WaitUntilApiDataAttributesLoadingPolicy) { + return true + } + + return false +} + +// SetWaitUntilApiDataAttributesLoadingPolicy gets a reference to the given PersistenceLoadingPolicy and assigns it to the WaitUntilApiDataAttributesLoadingPolicy field. +func (o *WorkflowStateOptions) SetWaitUntilApiDataAttributesLoadingPolicy(v PersistenceLoadingPolicy) { + o.WaitUntilApiDataAttributesLoadingPolicy = &v +} + +// GetExecuteApiDataAttributesLoadingPolicy returns the ExecuteApiDataAttributesLoadingPolicy field value if set, zero value otherwise. +func (o *WorkflowStateOptions) GetExecuteApiDataAttributesLoadingPolicy() PersistenceLoadingPolicy { + if o == nil || IsNil(o.ExecuteApiDataAttributesLoadingPolicy) { + var ret PersistenceLoadingPolicy + return ret + } + return *o.ExecuteApiDataAttributesLoadingPolicy +} + +// GetExecuteApiDataAttributesLoadingPolicyOk returns a tuple with the ExecuteApiDataAttributesLoadingPolicy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WorkflowStateOptions) GetExecuteApiDataAttributesLoadingPolicyOk() (*PersistenceLoadingPolicy, bool) { + if o == nil || IsNil(o.ExecuteApiDataAttributesLoadingPolicy) { + return nil, false + } + return o.ExecuteApiDataAttributesLoadingPolicy, true +} + +// HasExecuteApiDataAttributesLoadingPolicy returns a boolean if a field has been set. +func (o *WorkflowStateOptions) HasExecuteApiDataAttributesLoadingPolicy() bool { + if o != nil && !IsNil(o.ExecuteApiDataAttributesLoadingPolicy) { + return true + } + + return false +} + +// SetExecuteApiDataAttributesLoadingPolicy gets a reference to the given PersistenceLoadingPolicy and assigns it to the ExecuteApiDataAttributesLoadingPolicy field. +func (o *WorkflowStateOptions) SetExecuteApiDataAttributesLoadingPolicy(v PersistenceLoadingPolicy) { + o.ExecuteApiDataAttributesLoadingPolicy = &v +} + func (o WorkflowStateOptions) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { @@ -645,6 +777,12 @@ func (o WorkflowStateOptions) ToMap() (map[string]interface{}, error) { if !IsNil(o.SearchAttributesLoadingPolicy) { toSerialize["searchAttributesLoadingPolicy"] = o.SearchAttributesLoadingPolicy } + if !IsNil(o.WaitUntilApiSearchAttributesLoadingPolicy) { + toSerialize["waitUntilApiSearchAttributesLoadingPolicy"] = o.WaitUntilApiSearchAttributesLoadingPolicy + } + if !IsNil(o.ExecuteApiSearchAttributesLoadingPolicy) { + toSerialize["executeApiSearchAttributesLoadingPolicy"] = o.ExecuteApiSearchAttributesLoadingPolicy + } if !IsNil(o.DataObjectsLoadingPolicy) { toSerialize["dataObjectsLoadingPolicy"] = o.DataObjectsLoadingPolicy } @@ -696,6 +834,12 @@ func (o WorkflowStateOptions) ToMap() (map[string]interface{}, error) { if !IsNil(o.DataAttributesLoadingPolicy) { toSerialize["dataAttributesLoadingPolicy"] = o.DataAttributesLoadingPolicy } + if !IsNil(o.WaitUntilApiDataAttributesLoadingPolicy) { + toSerialize["waitUntilApiDataAttributesLoadingPolicy"] = o.WaitUntilApiDataAttributesLoadingPolicy + } + if !IsNil(o.ExecuteApiDataAttributesLoadingPolicy) { + toSerialize["executeApiDataAttributesLoadingPolicy"] = o.ExecuteApiDataAttributesLoadingPolicy + } return toSerialize, nil } diff --git a/integ/wf_state_options_data_attributes_loading_test.go b/integ/wf_state_options_data_attributes_loading_test.go new file mode 100644 index 00000000..ecc63a79 --- /dev/null +++ b/integ/wf_state_options_data_attributes_loading_test.go @@ -0,0 +1,93 @@ +package integ + +import ( + "context" + "github.com/indeedeng/iwf/gen/iwfidl" + "github.com/indeedeng/iwf/integ/workflow/wf_state_options_data_attributes_loading" + "github.com/indeedeng/iwf/service" + "github.com/indeedeng/iwf/service/common/ptr" + "github.com/stretchr/testify/assert" + "strconv" + "testing" + "time" +) + +func TestWfStateOptionsDataAttributesLoading_PARTIAL_WITHOUT_LOCK(t *testing.T) { + for _, backendType := range getBackendTypes() { + for i := 0; i < *repeatIntegTest; i++ { + doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + } + } +} + +func TestWfStateOptionsDataAttributesLoading_PARTIAL_WITH_LOCK(t *testing.T) { + for _, backendType := range getBackendTypes() { + for i := 0; i < *repeatIntegTest; i++ { + doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK) + smallWaitForFastTest() + doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + } + } +} + +func doTestWfStateOptionsDataAttributesLoading( + t *testing.T, backendType service.BackendType, loadingType iwfidl.PersistenceLoadingType, +) { + assertions := assert.New(t) + + wfHandler := wf_state_options_data_attributes_loading.NewHandler() + closeFunc1 := startWorkflowWorkerWithRpc(wfHandler) + defer closeFunc1() + closeFunc2 := startIwfService(backendType) + defer closeFunc2() + + apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{ + Servers: []iwfidl.ServerConfiguration{ + { + URL: "http://localhost:" + testIwfServerPort, + }, + }, + }) + + wfId := wf_state_options_data_attributes_loading.WorkflowType + "_" + string(loadingType) + "_" + strconv.Itoa(int(time.Now().UnixNano())) + + wfInput := &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString(string(loadingType)), + } + + req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background()) + + startReq := iwfidl.WorkflowStartRequest{ + WorkflowId: wfId, + IwfWorkflowType: wf_state_options_data_attributes_loading.WorkflowType, + WorkflowTimeoutSeconds: 10, + IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort, + StartStateId: ptr.Any(wf_state_options_data_attributes_loading.State1), + StateInput: wfInput, + } + + _, httpResp, err := req.WorkflowStartRequest(startReq).Execute() + panicAtHttpError(err, httpResp) + + time.Sleep(time.Second * 2) + + history, _ := wfHandler.GetTestResult() + + assertions.Equalf(map[string]int64{ + "S1_start": 1, + "S1_decide": 1, + "S2_start": 1, + "S2_decide": 1, + "S3_start": 1, + "S3_decide": 1, + "S4_start": 1, + "S4_decide": 1, + "S5_start": 1, + "S5_decide": 1, + }, history, "state options data attributes loading, %v", history) +} diff --git a/integ/wf_state_options_search_attributes_loading_test.go b/integ/wf_state_options_search_attributes_loading_test.go new file mode 100644 index 00000000..1b338b9b --- /dev/null +++ b/integ/wf_state_options_search_attributes_loading_test.go @@ -0,0 +1,93 @@ +package integ + +import ( + "context" + "github.com/indeedeng/iwf/gen/iwfidl" + "github.com/indeedeng/iwf/integ/workflow/wf_state_options_search_attributes_loading" + "github.com/indeedeng/iwf/service" + "github.com/indeedeng/iwf/service/common/ptr" + "github.com/stretchr/testify/assert" + "strconv" + "testing" + "time" +) + +func TestWfStateOptionsSearchAttributesLoading_PARTIAL_WITHOUT_LOCK(t *testing.T) { + for _, backendType := range getBackendTypes() { + for i := 0; i < *repeatIntegTest; i++ { + doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + } + } +} + +func TestWfStateOptionsSearchAttributesLoading_PARTIAL_WITH_LOCK(t *testing.T) { + for _, backendType := range getBackendTypes() { + for i := 0; i < *repeatIntegTest; i++ { + doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK) + smallWaitForFastTest() + doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING) + smallWaitForFastTest() + } + } +} + +func doTestWfStateOptionsSearchAttributesLoading( + t *testing.T, backendType service.BackendType, loadingType iwfidl.PersistenceLoadingType, +) { + assertions := assert.New(t) + + wfHandler := wf_state_options_search_attributes_loading.NewHandler() + closeFunc1 := startWorkflowWorkerWithRpc(wfHandler) + defer closeFunc1() + closeFunc2 := startIwfService(backendType) + defer closeFunc2() + + apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{ + Servers: []iwfidl.ServerConfiguration{ + { + URL: "http://localhost:" + testIwfServerPort, + }, + }, + }) + + wfId := wf_state_options_search_attributes_loading.WorkflowType + "_" + string(loadingType) + "_" + strconv.Itoa(int(time.Now().UnixNano())) + + wfInput := &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString(string(loadingType)), + } + + req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background()) + + startReq := iwfidl.WorkflowStartRequest{ + WorkflowId: wfId, + IwfWorkflowType: wf_state_options_search_attributes_loading.WorkflowType, + WorkflowTimeoutSeconds: 10, + IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort, + StartStateId: ptr.Any(wf_state_options_search_attributes_loading.State1), + StateInput: wfInput, + } + + _, httpResp, err := req.WorkflowStartRequest(startReq).Execute() + panicAtHttpError(err, httpResp) + + time.Sleep(time.Second * 2) + + history, _ := wfHandler.GetTestResult() + + assertions.Equalf(map[string]int64{ + "S1_start": 1, + "S1_decide": 1, + "S2_start": 1, + "S2_decide": 1, + "S3_start": 1, + "S3_decide": 1, + "S4_start": 1, + "S4_decide": 1, + "S5_start": 1, + "S5_decide": 1, + }, history, "state options search attributes loading, %v", history) +} diff --git a/integ/workflow/wf_state_options_data_attributes_loading/routers.go b/integ/workflow/wf_state_options_data_attributes_loading/routers.go new file mode 100644 index 00000000..dd0c0af4 --- /dev/null +++ b/integ/workflow/wf_state_options_data_attributes_loading/routers.go @@ -0,0 +1,356 @@ +package wf_state_options_data_attributes_loading + +import ( + "github.com/gin-gonic/gin" + "github.com/indeedeng/iwf/gen/iwfidl" + "github.com/indeedeng/iwf/integ/workflow/common" + "github.com/indeedeng/iwf/service" + "github.com/stretchr/testify/assert" + "log" + "net/http" +) + +/** + * This test workflow has four states, using REST controller to implement the workflow directly. + * + * State1: + * - WaitUntil method does nothing + * - Execute method creates all Data Attributes keys that will be used in this test + * - da_wait_until1 + * - da_execute1 + * - da_other_key + * State2: + * - State Options contains WaitUntilApiDataAttributesLoadingPolicy + * - WaitUntil method asserts that expected DataAttributes are loaded + * - Execute method asserts that no DataAttributes are loaded + * State3: + * - State Options contains ExecuteApiDataAttributesLoadingPolicy + * - WaitUntil method asserts that no DataAttributes are loaded + * - Execute method asserts that expected DataAttributes are loaded + * State4: + * - State Options contains DataAttributesLoadingPolicy + * - WaitUntil method asserts that expected DataAttributes are loaded + * - Execute method asserts that expected DataAttributes are loaded + * State5: + * - State Options contains DataAttributesLoadingPolicy and WaitUntilApiDataAttributesLoadingPolicy + * - WaitUntil method asserts that WaitUntilApiDataAttributesLoadingPolicy are loaded + * - Execute method asserts that DataAttributesLoadingPolicy are loaded + */ +const ( + WorkflowType = "state_options_data_attributes_loading" + State1 = "S1" + State2 = "S2" + State3 = "S3" + State4 = "S4" + State5 = "S5" +) + +type handler struct { + invokeHistory map[string]int64 +} + +func NewHandler() common.WorkflowHandlerWithRpc { + return &handler{ + invokeHistory: make(map[string]int64), + } +} + +func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) { + var req iwfidl.WorkflowStateStartRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + if req.GetWorkflowType() != WorkflowType { + c.JSON(http.StatusBadRequest, struct{}{}) + return + } + + log.Println("state_options_data_attributes_loading: received state start request, ", req) + + h.invokeHistory[req.GetWorkflowStateId()+"_start"]++ + + currentMethod := "WaitUntil" + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + if req.GetWorkflowStateId() == State2 { + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + } + + if req.GetWorkflowStateId() == State3 { + verifyEmptyDataAttributes(req.GetDataObjects()) + } + + if req.GetWorkflowStateId() == State4 { + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + } + + if req.GetWorkflowStateId() == State5 { + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + } + + c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{ + CommandRequest: &iwfidl.CommandRequest{ + DeciderTriggerType: iwfidl.ANY_COMMAND_COMPLETED.Ptr(), + }, + }) +} + +func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) { + var req iwfidl.WorkflowStateDecideRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + if req.GetWorkflowType() != WorkflowType { + c.JSON(http.StatusBadRequest, struct{}{}) + return + } + + log.Println("state_options_data_attributes_loading: received state decide request, ", req) + + h.invokeHistory[req.GetWorkflowStateId()+"_decide"]++ + + currentMethod := "Execute" + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + var response iwfidl.WorkflowStateDecideResponse + switch req.GetWorkflowStateId() { + case State1: + response = getState1DecideResponse(req) + case State2: + verifyEmptyDataAttributes(req.GetDataObjects()) + response = getState2DecideResponse(req) + case State3: + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + response = getState3DecideResponse(req) + case State4: + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + response = getState4DecideResponse(req) + case State5: + verifyLoadedDataAttributes(req.GetWorkflowStateId(), currentMethod, req.GetDataObjects(), loadingType) + response = getState5DecideResponse() + } + + c.JSON(http.StatusOK, response) +} + +func (h *handler) ApiV1WorkflowWorkerRpc(c *gin.Context) { + c.JSON(http.StatusBadRequest, struct{}{}) +} + +func getState1DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + noneLoadingType := iwfidl.NONE + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State2, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiDataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"da_wait_until1"}, + }, + ExecuteApiDataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &noneLoadingType, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + UpsertDataObjects: getUpsertDataObjects(), + } +} + +func getState2DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + noneLoadingType := iwfidl.NONE + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State3, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiDataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &noneLoadingType, + }, + ExecuteApiDataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"da_execute1"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState3DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State4, + StateOptions: &iwfidl.WorkflowStateOptions{ + DataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"da_other_key"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState4DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State5, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiDataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"da_wait_until1"}, + }, + DataAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"da_other_key"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState5DecideResponse() iwfidl.WorkflowStateDecideResponse { + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: service.GracefulCompletingWorkflowStateId, + }, + }, + }, + } +} + +func verifyEmptyDataAttributes(dataAttributes []iwfidl.KeyValue) { + var expectedDataAttributes []iwfidl.KeyValue + if !assert.ElementsMatch(common.DummyT{}, expectedDataAttributes, dataAttributes) { + panic("Data attributes should be empty") + } +} + +func verifyLoadedDataAttributes(stateId string, method string, dataAttributes []iwfidl.KeyValue, loadingType iwfidl.PersistenceLoadingType) { + expectedDataAttributes := getExpectedDataAttributes(stateId, method, loadingType) + if !assert.ElementsMatch(common.DummyT{}, expectedDataAttributes, dataAttributes) { + panic("Data attributes should be the same") + } +} + +func getUpsertDataObjects() []iwfidl.KeyValue { + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_wait_until1"), + Value: &iwfidl.EncodedObject{Encoding: iwfidl.PtrString("json"), Data: iwfidl.PtrString("test-data-object-wait-until")}, + }, + { + Key: iwfidl.PtrString("da_execute1"), + Value: &iwfidl.EncodedObject{Encoding: iwfidl.PtrString("json"), Data: iwfidl.PtrString("test-data-object-execute")}, + }, + { + Key: iwfidl.PtrString("da_other_key"), + Value: &iwfidl.EncodedObject{Encoding: iwfidl.PtrString("json"), Data: iwfidl.PtrString("random-value")}, + }, + } +} + +func getExpectedDataAttributes(stateId string, method string, loadingType iwfidl.PersistenceLoadingType) []iwfidl.KeyValue { + if stateId == State2 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_wait_until1"), + Value: &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString("test-data-object-wait-until"), + }, + }, + } + } + if stateId == State3 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_execute1"), + Value: &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString("test-data-object-execute"), + }, + }, + } + } + + if stateId == State4 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_other_key"), + Value: &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString("random-value"), + }, + }, + } + } + + if stateId == State5 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + switch method { + case "WaitUntil": + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_wait_until1"), + Value: &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString("test-data-object-wait-until"), + }, + }, + } + case "Execute": + return []iwfidl.KeyValue{ + { + Key: iwfidl.PtrString("da_other_key"), + Value: &iwfidl.EncodedObject{ + Encoding: iwfidl.PtrString("json"), + Data: iwfidl.PtrString("random-value"), + }, + }, + } + } + } + + return getUpsertDataObjects() +} + +func (h *handler) GetTestResult() (map[string]int64, map[string]interface{}) { + return h.invokeHistory, nil +} diff --git a/integ/workflow/wf_state_options_search_attributes_loading/routers.go b/integ/workflow/wf_state_options_search_attributes_loading/routers.go new file mode 100644 index 00000000..6dd87fd6 --- /dev/null +++ b/integ/workflow/wf_state_options_search_attributes_loading/routers.go @@ -0,0 +1,350 @@ +package wf_state_options_search_attributes_loading + +import ( + "github.com/gin-gonic/gin" + "github.com/indeedeng/iwf/gen/iwfidl" + "github.com/indeedeng/iwf/integ/workflow/common" + "github.com/indeedeng/iwf/service" + "github.com/indeedeng/iwf/service/common/ptr" + "github.com/stretchr/testify/assert" + "log" + "net/http" +) + +/** + * This test workflow has four states, using REST controller to implement the workflow directly. + * + * State1: + * - WaitUntil method does nothing + * - Execute method sets values for all Search Attributes used in this test + * - CustomKeywordField + * - CustomStringField + * - CustomBoolField + * State2: + * - State Options contains WaitUntilApiSearchAttributesLoadingPolicy + * - WaitUntil method asserts that expected SearchAttributes are loaded + * - Execute method asserts that no SearchAttributes are loaded + * State3: + * - State Options contains WaitUntilApiSearchAttributesLoadingPolicy + * - WaitUntil method asserts that no SearchAttributes are loaded + * - Execute method asserts that expected SearchAttributes are loaded + * State4: + * - State Options contains SearchAttributesLoadingPolicy + * - WaitUntil method asserts that expected SearchAttributes are loaded + * - Execute method asserts that expected SearchAttributes are loaded + * State5: + * - State Options contains AdSearchAttributesLoadingPolicy and WaitUntilApiSearchAttributesLoadingPolicy + * - WaitUntil method asserts that WaitUntilApiSearchAttributesLoadingPolicy are loaded + * - Execute method asserts that SearchAttributesLoadingPolicy are loaded + */ +const ( + WorkflowType = "state_options_search_attributes_loading" + State1 = "S1" + State2 = "S2" + State3 = "S3" + State4 = "S4" + State5 = "S5" +) + +type handler struct { + invokeHistory map[string]int64 +} + +func NewHandler() common.WorkflowHandlerWithRpc { + return &handler{ + invokeHistory: make(map[string]int64), + } +} + +func (h *handler) ApiV1WorkflowStateStart(c *gin.Context) { + var req iwfidl.WorkflowStateStartRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + if req.GetWorkflowType() != WorkflowType { + c.JSON(http.StatusBadRequest, struct{}{}) + return + } + + log.Println("state_options_search_attributes_loading: received state decide request, ", req) + + h.invokeHistory[req.GetWorkflowStateId()+"_start"]++ + + currentMethod := "WaitUntil" + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + if req.GetWorkflowStateId() == State2 { + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + } + + if req.GetWorkflowStateId() == State3 { + verifyEmptySearchAttributes(req.GetSearchAttributes()) + } + + if req.GetWorkflowStateId() == State4 { + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + } + + if req.GetWorkflowStateId() == State5 { + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + } + + c.JSON(http.StatusOK, iwfidl.WorkflowStateStartResponse{ + CommandRequest: &iwfidl.CommandRequest{ + DeciderTriggerType: iwfidl.ANY_COMMAND_COMPLETED.Ptr(), + }, + }) +} + +func (h *handler) ApiV1WorkflowStateDecide(c *gin.Context) { + var req iwfidl.WorkflowStateDecideRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + if req.GetWorkflowType() != WorkflowType { + c.JSON(http.StatusBadRequest, struct{}{}) + return + } + + log.Println("state_options_search_attributes_loading: received state decide request, ", req) + + h.invokeHistory[req.GetWorkflowStateId()+"_decide"]++ + + currentMethod := "Execute" + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + var response iwfidl.WorkflowStateDecideResponse + switch req.GetWorkflowStateId() { + case State1: + response = getState1DecideResponse(req) + case State2: + verifyEmptySearchAttributes(req.GetSearchAttributes()) + response = getState2DecideResponse(req) + case State3: + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + response = getState3DecideResponse(req) + case State4: + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + response = getState4DecideResponse(req) + case State5: + verifyLoadedSearchAttributes(req.GetWorkflowStateId(), currentMethod, req.GetSearchAttributes(), loadingType) + response = getState5DecideResponse() + } + + c.JSON(http.StatusOK, response) +} + +func (h *handler) ApiV1WorkflowWorkerRpc(c *gin.Context) { + c.JSON(http.StatusBadRequest, struct{}{}) +} + +func getState1DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + noneLoadingType := iwfidl.NONE + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State2, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiSearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"CustomKeywordField"}, + }, + ExecuteApiSearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &noneLoadingType, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + UpsertSearchAttributes: getUpsertSearchAttributes(), + } +} + +func getState2DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + noneLoadingType := iwfidl.NONE + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State3, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiSearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &noneLoadingType, + }, + ExecuteApiSearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"CustomStringField"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState3DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State4, + StateOptions: &iwfidl.WorkflowStateOptions{ + SearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"CustomBoolField"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState4DecideResponse(req iwfidl.WorkflowStateDecideRequest) iwfidl.WorkflowStateDecideResponse { + loadingTypeFromInput := req.GetStateInput() + loadingType := iwfidl.PersistenceLoadingType(loadingTypeFromInput.GetData()) + + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: State5, + StateOptions: &iwfidl.WorkflowStateOptions{ + WaitUntilApiSearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"CustomKeywordField"}, + }, + SearchAttributesLoadingPolicy: &iwfidl.PersistenceLoadingPolicy{ + PersistenceLoadingType: &loadingType, + PartialLoadingKeys: []string{"CustomBoolField"}, + }, + }, + StateInput: &loadingTypeFromInput, + }, + }, + }, + } +} + +func getState5DecideResponse() iwfidl.WorkflowStateDecideResponse { + return iwfidl.WorkflowStateDecideResponse{ + StateDecision: &iwfidl.StateDecision{ + NextStates: []iwfidl.StateMovement{ + { + StateId: service.GracefulCompletingWorkflowStateId, + }, + }, + }, + } +} + +func verifyEmptySearchAttributes(searchAttributes []iwfidl.SearchAttribute) { + var expectedSearchAttributes []iwfidl.SearchAttribute + if !assert.ElementsMatch(common.DummyT{}, expectedSearchAttributes, searchAttributes) { + panic("Search attributes should be empty") + } +} + +func verifyLoadedSearchAttributes(stateId string, method string, searchAttributes []iwfidl.SearchAttribute, loadingType iwfidl.PersistenceLoadingType) { + expectedSearchAttributes := getExpectedSearchAttributes(stateId, method, loadingType) + if !assert.ElementsMatch(common.DummyT{}, expectedSearchAttributes, searchAttributes) { + panic("Search attributes should be the same") + } +} + +func getUpsertSearchAttributes() []iwfidl.SearchAttribute { + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomKeywordField"), + ValueType: ptr.Any(iwfidl.KEYWORD_ARRAY), + StringArrayValue: []string{"keyword1", "keyword2"}, + }, + { + Key: iwfidl.PtrString("CustomStringField"), + ValueType: ptr.Any(iwfidl.TEXT), + StringValue: iwfidl.PtrString("I am a string"), + }, + { + Key: iwfidl.PtrString("CustomBoolField"), + ValueType: ptr.Any(iwfidl.BOOL), + BoolValue: ptr.Any(true), + }, + } +} + +func getExpectedSearchAttributes(stateId string, method string, loadingType iwfidl.PersistenceLoadingType) []iwfidl.SearchAttribute { + if stateId == State2 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomKeywordField"), + ValueType: ptr.Any(iwfidl.KEYWORD_ARRAY), + StringArrayValue: []string{"keyword1", "keyword2"}, + }, + } + } + if stateId == State3 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomStringField"), + ValueType: ptr.Any(iwfidl.TEXT), + StringValue: iwfidl.PtrString("I am a string"), + }, + } + } + + if stateId == State4 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomBoolField"), + ValueType: ptr.Any(iwfidl.BOOL), + BoolValue: ptr.Any(true), + }, + } + } + + if stateId == State5 && (loadingType == iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK || loadingType == iwfidl.PARTIAL_WITHOUT_LOCKING) { + switch method { + case "WaitUntil": + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomKeywordField"), + ValueType: ptr.Any(iwfidl.KEYWORD_ARRAY), + StringArrayValue: []string{"keyword1", "keyword2"}, + }, + } + case "Execute": + return []iwfidl.SearchAttribute{ + { + Key: iwfidl.PtrString("CustomBoolField"), + ValueType: ptr.Any(iwfidl.BOOL), + BoolValue: ptr.Any(true), + }, + } + } + } + + return getUpsertSearchAttributes() +} + +func (h *handler) GetTestResult() (map[string]int64, map[string]interface{}) { + return h.invokeHistory, nil +} diff --git a/iwf-idl b/iwf-idl index fdd0d8ea..b476e69f 160000 --- a/iwf-idl +++ b/iwf-idl @@ -1 +1 @@ -Subproject commit fdd0d8eae1326489e567bf0073263a3f14bad04e +Subproject commit b476e69f83ed9d1adceca659829630a749eea543 diff --git a/service/common/compatibility/stateOptions.go b/service/common/compatibility/stateOptions.go index 96eadc16..4cb04059 100644 --- a/service/common/compatibility/stateOptions.go +++ b/service/common/compatibility/stateOptions.go @@ -45,14 +45,62 @@ func GetDecideApiRetryPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl. return stateOptions.ExecuteApiRetryPolicy } -func GetDataObjectsLoadingPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.PersistenceLoadingPolicy { +func GetWaitUntilApiDataObjectsLoadingPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.PersistenceLoadingPolicy { if stateOptions == nil { return nil } - if stateOptions.HasDataObjectsLoadingPolicy() { - return stateOptions.DataObjectsLoadingPolicy + + if stateOptions.HasWaitUntilApiDataAttributesLoadingPolicy() { + return stateOptions.WaitUntilApiDataAttributesLoadingPolicy + } + + if stateOptions.HasDataAttributesLoadingPolicy() { + return stateOptions.DataAttributesLoadingPolicy + } + + return stateOptions.DataObjectsLoadingPolicy +} + +func GetExecuteApiDataObjectsLoadingPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.PersistenceLoadingPolicy { + if stateOptions == nil { + return nil + } + + if stateOptions.HasExecuteApiDataAttributesLoadingPolicy() { + return stateOptions.ExecuteApiDataAttributesLoadingPolicy + } + + if stateOptions.HasDataAttributesLoadingPolicy() { + return stateOptions.DataAttributesLoadingPolicy + } + + return stateOptions.DataObjectsLoadingPolicy +} + +func GetWaitUntilApiSearchAttributesLoadingPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.PersistenceLoadingPolicy { + if stateOptions == nil { + return nil + } + + if stateOptions.HasWaitUntilApiSearchAttributesLoadingPolicy() { + return stateOptions.WaitUntilApiSearchAttributesLoadingPolicy + + } + + return stateOptions.SearchAttributesLoadingPolicy +} + +func GetExecuteApiSearchAttributesLoadingPolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.PersistenceLoadingPolicy { + if stateOptions == nil { + return nil } - return stateOptions.DataAttributesLoadingPolicy + + if stateOptions.HasExecuteApiSearchAttributesLoadingPolicy() { + return stateOptions.ExecuteApiSearchAttributesLoadingPolicy + + } + + return stateOptions.SearchAttributesLoadingPolicy } func GetStartApiFailurePolicy(stateOptions *iwfidl.WorkflowStateOptions) *iwfidl.StartApiFailurePolicy { diff --git a/service/interpreter/workflowImpl.go b/service/interpreter/workflowImpl.go index f60825de..5f5c3444 100644 --- a/service/interpreter/workflowImpl.go +++ b/service/interpreter/workflowImpl.go @@ -508,8 +508,8 @@ func executeState( ctx = provider.WithActivityOptions(ctx, activityOptions) - saLoadingPolicy := state.GetStateOptions().SearchAttributesLoadingPolicy - doLoadingPolicy := compatibility.GetDataObjectsLoadingPolicy(state.StateOptions) + saLoadingPolicy := compatibility.GetWaitUntilApiSearchAttributesLoadingPolicy(state.StateOptions) + doLoadingPolicy := compatibility.GetWaitUntilApiDataObjectsLoadingPolicy(state.StateOptions) errStartApi = provider.ExecuteActivity(&startResponse, configer.ShouldOptimizeActivity(), ctx, waitUntilApi, provider.GetBackendType(), service.StateStartActivityInput{ @@ -739,8 +739,8 @@ func invokeStateExecute( activityOptions.RetryPolicy = compatibility.GetDecideApiRetryPolicy(state.StateOptions) } - saLoadingPolicy := state.GetStateOptions().SearchAttributesLoadingPolicy - doLoadingPolicy := compatibility.GetDataObjectsLoadingPolicy(state.StateOptions) + saLoadingPolicy := compatibility.GetExecuteApiSearchAttributesLoadingPolicy(state.StateOptions) + doLoadingPolicy := compatibility.GetExecuteApiDataObjectsLoadingPolicy(state.StateOptions) ctx = provider.WithActivityOptions(ctx, activityOptions) var decideResponse *iwfidl.WorkflowStateDecideResponse