temporalio / roadrunner-temporal

Temporal PHP-SDK Host Process plugin for Roadrunner
MIT License
22 stars 8 forks source link

fix: async updates handler #475

Closed rustatian closed 7 months ago

rustatian commented 8 months ago

Reason for This PR

Description of Changes

Tests:

  1. Run Update.greet workflow -> empty list on exit.
  2. Run Update.greet workflow with addNameWithoutValidation method. Args: John Doe 42 -> should return Hello, John Doe 42!.
  3. Run Update.greet workflow with addName method. Args: John Doe -> should return Hello, John Doe!.
  4. Run Update.greet workflow with addName method. Args: 123 -> should failure with the message: Name must not contain digits.
  5. Run Update.greet workflow with throwException method. Args: John Doe -> should failure with the following message: Test exception with John Doe.
  6. Run Update.greet workflow with randomizeName method. Args: 1 (int) -> should execute a SideEffect and return a slice with the random string.
  7. The same as 6, but with Args: 3 (int) -> should execute a SideEffect and return 3 random strings in a slice.
  8. Run Update.greet workflow with addNameViaActivity method. Args: John Doe -> should execute an Activity and return lowercased name: Hello, john doe!.
  9. 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)
  10. 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)
  11. 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.
  12. 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]