The workflow name used in the tests is Update.greet.
Tests:
Run Update.greet workflow -> empty list on exit.
Run Update.greet workflow with addNameWithoutValidation method. Args: John Doe 42-> should return Hello, John Doe 42!.
Run Update.greet workflow with addName method. Args: John Doe-> should return Hello, John Doe!.
Run Update.greet workflow with addName method. Args: 123-> should failure with the message: Name must not contain digits.
Run Update.greet workflow with throwException method. Args: John Doe -> should failure with the following message: Test exception with John Doe.
Run Update.greet workflow with randomizeName method. Args: 1 (int) -> should execute a SideEffect and return a slice with the random string.
The same as 6, but with Args: 3 (int) -> should execute a SideEffect and return 3 random strings in a slice.
Run Update.greet workflow with addNameViaActivity method. Args: John Doe-> should execute an Activity and return lowercased name: Hello, john doe!.
Run AwaitsUpdate.greet; update awaitWithTimeout with args "key", 1, "fallback" -> the Update should sleep for 1 second and return "fallback"; workflow should return {"key": "fallback"} (associative array -> map[string]any) (send exit signal to complete Workflow)
Run AwaitsUpdate.greet; start async update await with arg "key" -> will wait for resolving; query getValue with arg "key" should return null; update resolveValue with args "key", "resolved" -> should resolve await in the previous await update and return "resolved"; query getValue with arg "key" should return "resolved"; workflow should return {"key": "resolved"} (send exit signal to complete Workflow)
The same as 10, but with 5 await Updates and then 5 resolve Updates (use unique keys in args) -> should open and complete 5 parallel updates.
Run AwaitsUpdate.greet; for $i from 1 to 3, start async update awaitWithTimeout with args "key$i", 5, "fallback$i"; for $i from 1 to 3, start async update resolveValue with args "key$i", "resolved$i" -> awaits will be resolved before timeout; workflow should return {"key1": "fallback1", "key2": "fallback2", "key3": "fallback3",} (send exit signal to complete Workflow)
[!NOTE]
Tests from 9 should be executed with WaitPolicy=StageAccepted, and Temporal server option frontend.enableUpdateWorkflowExecutionAsyncAccepted=true
[!WARNING]
All the tests require Temporal option frontend.enableUpdateWorkflowExecution=true
[!WARNING]
Need to discard changes in composer.json before merging into master branch
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the MIT license.
PR Checklist
[Author TODO: Meet these criteria.][Reviewer TODO: Verify that these criteria are met. Request changes if not]
[x] All commits in this PR are signed (git commit -s).
[x] The reason for this PR is clearly provided (issue no. or explanation).
[ ] The description of changes is clear and encompassing.
[ ] Any required documentation changes (code and docs) are included in this PR.
[ ] Any user-facing changes are mentioned in CHANGELOG.md.
Reason for This PR
Need to test Workflow Update functionality
Description of Changes
Update.greet
.Tests:
Update.greet
workflow -> empty list on exit.Update.greet
workflow withaddNameWithoutValidation
method. Args:John Doe 42
->
should returnHello, John Doe 42!
.Update.greet
workflow withaddName
method. Args:John Doe
->
should returnHello, John Doe!
.Update.greet
workflow withaddName
method. Args:123
->
should failure with the message:Name must not contain digits
.Update.greet
workflow withthrowException
method. Args:John Doe
-> should failure with the following message:Test exception with John Doe
.Update.greet
workflow withrandomizeName
method. Args:1
(int) -> should execute a SideEffect and return a slice with the random string.3
(int)->
should execute a SideEffect and return 3 random strings in a slice.Update.greet
workflow withaddNameViaActivity
method. Args:John Doe
->
should execute an Activity and return lowercased name:Hello, john doe!
.AwaitsUpdate.greet
; updateawaitWithTimeout
with args"key"
,1
,"fallback"
-> the Update should sleep for 1 second and return"fallback"
; workflow should return{"key": "fallback"}
(associative array ->map[string]any
) (sendexit
signal to complete Workflow)AwaitsUpdate.greet
; start async updateawait
with arg"key"
-> will wait for resolving; querygetValue
with arg"key"
should returnnull
; updateresolveValue
with args"key"
,"resolved"
-> should resolve await in the previousawait
update and return"resolved"
; querygetValue
with arg"key"
should return"resolved"
; workflow should return{"key": "resolved"}
(sendexit
signal to complete Workflow)await
Updates and then 5resolve
Updates (use unique keys in args)->
should open and complete 5 parallel updates.AwaitsUpdate.greet
; for $i from 1 to 3, start async updateawaitWithTimeout
with args"key$i"
,5
,"fallback$i"
; for $i from 1 to 3, start async updateresolveValue
with args"key$i"
,"resolved$i"
-> awaits will be resolved before timeout; workflow should return{"key1": "fallback1", "key2": "fallback2", "key3": "fallback3",}
(sendexit
signal to complete Workflow)License Acceptance
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
PR Checklist
[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]
git commit -s
).CHANGELOG.md
.