@temporalio/core-bridge 1.13.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +350 -436
- package/Cargo.toml +14 -13
- package/{sdk-core/fsm/rustfsm_procmacro/LICENSE.txt → LICENSE} +5 -5
- package/README.md +0 -1
- package/bridge-macros/Cargo.toml +16 -0
- package/bridge-macros/src/derive_js_function.rs +126 -0
- package/bridge-macros/src/derive_tryfromjs.rs +138 -0
- package/bridge-macros/src/derive_tryintojs.rs +151 -0
- package/bridge-macros/src/lib.rs +42 -0
- package/lib/native.d.ts +23 -9
- package/package.json +6 -5
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +78 -12
- package/sdk-core/.clippy.toml +1 -0
- package/sdk-core/.github/workflows/heavy.yml +2 -0
- package/sdk-core/.github/workflows/per-pr.yml +90 -21
- package/sdk-core/AGENTS.md +17 -19
- package/sdk-core/ARCHITECTURE.md +44 -48
- package/sdk-core/Cargo.toml +25 -7
- package/sdk-core/README.md +16 -15
- package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
- package/sdk-core/arch_docs/diagrams/deps.svg +102 -0
- package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
- package/sdk-core/arch_docs/sdks_intro.md +299 -0
- package/sdk-core/{client → crates/client}/Cargo.toml +15 -16
- package/sdk-core/{client → crates/client}/src/callback_based.rs +1 -2
- package/sdk-core/{client → crates/client}/src/lib.rs +594 -457
- package/sdk-core/{client → crates/client}/src/metrics.rs +32 -8
- package/sdk-core/crates/client/src/proxy.rs +209 -0
- package/sdk-core/{client → crates/client}/src/raw.rs +648 -328
- package/sdk-core/crates/client/src/replaceable.rs +253 -0
- package/sdk-core/crates/client/src/request_extensions.rs +40 -0
- package/sdk-core/{client → crates/client}/src/retry.rs +32 -22
- package/sdk-core/crates/client/src/worker/mod.rs +1468 -0
- package/sdk-core/{client → crates/client}/src/workflow_handle/mod.rs +24 -21
- package/sdk-core/{core-api → crates/common}/Cargo.toml +21 -12
- package/sdk-core/{sdk-core-protos → crates/common}/build.rs +10 -23
- package/sdk-core/crates/common/protos/api_cloud_upstream/VERSION +1 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/account/v1/message.proto +18 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/request_response.proto +38 -11
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/cloudservice/v1/service.proto +21 -4
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/operation/v1/message.proto +6 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/sink/v1/message.proto +22 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/create-release.yml +13 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv2.json +254 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/openapiv3.yaml +234 -5
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
- package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
- package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- package/sdk-core/{core-api → crates/common}/src/envconfig.rs +155 -56
- package/sdk-core/{core-api → crates/common}/src/errors.rs +8 -1
- package/sdk-core/{fsm/rustfsm_trait/src/lib.rs → crates/common/src/fsm_trait.rs} +1 -27
- package/sdk-core/{core-api → crates/common}/src/lib.rs +92 -9
- package/sdk-core/{test-utils/src → crates/common/src/protos}/canned_histories.rs +5 -5
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_builder.rs +3 -3
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/history_info.rs +2 -2
- package/sdk-core/{sdk-core-protos/src/lib.rs → crates/common/src/protos/mod.rs} +43 -26
- package/sdk-core/crates/common/src/protos/test_utils.rs +89 -0
- package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/utilities.rs +14 -5
- package/sdk-core/{core-api → crates/common}/src/telemetry/metrics.rs +449 -51
- package/sdk-core/{core-api → crates/common}/src/telemetry.rs +16 -1
- package/sdk-core/{core-api → crates/common}/src/worker.rs +112 -18
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +129 -0
- package/sdk-core/crates/macros/Cargo.toml +23 -0
- package/sdk-core/{fsm/rustfsm_procmacro → crates/macros}/src/lib.rs +12 -12
- package/sdk-core/{sdk → crates/sdk}/Cargo.toml +18 -12
- package/sdk-core/{sdk → crates/sdk}/src/activity_context.rs +9 -7
- package/sdk-core/{sdk → crates/sdk}/src/app_data.rs +1 -1
- package/sdk-core/{sdk → crates/sdk}/src/interceptors.rs +2 -5
- package/sdk-core/{sdk → crates/sdk}/src/lib.rs +43 -42
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context/options.rs +12 -3
- package/sdk-core/{sdk → crates/sdk}/src/workflow_context.rs +21 -19
- package/sdk-core/{sdk → crates/sdk}/src/workflow_future.rs +2 -2
- package/sdk-core/crates/sdk-core/Cargo.toml +222 -0
- package/sdk-core/{core/benches/workflow_replay.rs → crates/sdk-core/benches/workflow_replay_bench.rs} +15 -10
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +32 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelExternalMachine_Coverage.puml +9 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CancelWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ChildWorkflowMachine_Coverage.puml +27 -0
- package/sdk-core/crates/sdk-core/machine_coverage/CompleteWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ContinueAsNewWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/FailWorkflowMachine_Coverage.puml +6 -0
- package/sdk-core/crates/sdk-core/machine_coverage/LocalActivityMachine_Coverage.puml +23 -0
- package/sdk-core/crates/sdk-core/machine_coverage/ModifyWorkflowPropertiesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/PatchMachine_Coverage.puml +8 -0
- package/sdk-core/crates/sdk-core/machine_coverage/SignalExternalMachine_Coverage.puml +12 -0
- package/sdk-core/crates/sdk-core/machine_coverage/TimerMachine_Coverage.puml +13 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpdateMachine_Coverage.puml +19 -0
- package/sdk-core/crates/sdk-core/machine_coverage/UpsertSearchAttributesMachine_Coverage.puml +5 -0
- package/sdk-core/crates/sdk-core/machine_coverage/WorkflowTaskMachine_Coverage.puml +11 -0
- package/sdk-core/{core → crates/sdk-core}/src/abstractions.rs +62 -6
- package/sdk-core/crates/sdk-core/src/antithesis.rs +60 -0
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/activity_tasks.rs +85 -250
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/mod.rs +13 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/queries.rs +25 -24
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/replay_flag.rs +11 -68
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/updates.rs +21 -20
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workers.rs +242 -16
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_cancels.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/core_tests/workflow_tasks.rs +150 -326
- package/sdk-core/{core → crates/sdk-core}/src/debug_client.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/ephemeral_server/mod.rs +18 -6
- package/sdk-core/{test-utils → crates/sdk-core}/src/histfetch.rs +9 -4
- package/sdk-core/{core → crates/sdk-core}/src/internal_flags.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/lib.rs +128 -72
- package/sdk-core/{core → crates/sdk-core}/src/pollers/mod.rs +13 -11
- package/sdk-core/{core → crates/sdk-core}/src/pollers/poll_buffer.rs +53 -18
- package/sdk-core/{core → crates/sdk-core}/src/protosext/mod.rs +14 -6
- package/sdk-core/{core → crates/sdk-core}/src/protosext/protocol_messages.rs +5 -12
- package/sdk-core/{core → crates/sdk-core}/src/replay/mod.rs +14 -11
- package/sdk-core/crates/sdk-core/src/retry_logic.rs +390 -0
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/log_export.rs +2 -2
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/metrics.rs +80 -33
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/mod.rs +12 -6
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/otel.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_meter.rs +14 -14
- package/sdk-core/{core → crates/sdk-core}/src/telemetry/prometheus_server.rs +2 -2
- package/sdk-core/{core/src/test_help/mod.rs → crates/sdk-core/src/test_help/integ_helpers.rs} +284 -329
- package/sdk-core/crates/sdk-core/src/test_help/mod.rs +13 -0
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +220 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/activity_heartbeat_manager.rs +44 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities/local_activities.rs +33 -31
- package/sdk-core/{core → crates/sdk-core}/src/worker/activities.rs +31 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client/mocks.rs +28 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/client.rs +275 -145
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +246 -0
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1462 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/nexus.rs +24 -12
- package/sdk-core/{core → crates/sdk-core}/src/worker/slot_provider.rs +18 -10
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/fixed_size.rs +5 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner/resource_based.rs +453 -57
- package/sdk-core/{core → crates/sdk-core}/src/worker/tuner.rs +179 -3
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/driven_workflow.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/history_update.rs +5 -267
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/activity_state_machine.rs +147 -90
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -91
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/cancel_nexus_op_state_machine.rs +14 -12
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +97 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/child_workflow_state_machine.rs +32 -229
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/complete_workflow_state_machine.rs +13 -8
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -50
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/local_activity_state_machine.rs +39 -584
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/mod.rs +22 -17
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +4 -74
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/nexus_operation_state_machine.rs +118 -21
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +273 -0
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/signal_external_state_machine.rs +9 -151
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/timer_state_machine.rs +27 -132
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/transition_coverage.rs +1 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/update_state_machine.rs +19 -13
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +25 -80
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_machines.rs +68 -72
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/machines/workflow_task_state_machine.rs +13 -15
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/managed_run.rs +55 -37
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/mod.rs +171 -61
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/run_cache.rs +10 -7
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_extraction.rs +4 -2
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/wft_poller.rs +15 -4
- package/sdk-core/{core → crates/sdk-core}/src/worker/workflow/workflow_stream.rs +38 -19
- package/sdk-core/crates/sdk-core/tests/c_bridge_smoke_test.c +10 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +25 -0
- package/sdk-core/crates/sdk-core/tests/common/fake_grpc_server.rs +106 -0
- package/sdk-core/crates/sdk-core/tests/common/http_proxy.rs +134 -0
- package/sdk-core/{test-utils/src/lib.rs → crates/sdk-core/tests/common/mod.rs} +286 -334
- package/sdk-core/{test-utils/src → crates/sdk-core/tests/common}/workflows.rs +6 -4
- package/sdk-core/crates/sdk-core/tests/fsm_procmacro.rs +6 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dupe_transitions_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/dupe_transitions_fail.stderr +12 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/dynamic_dest_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.rs +1 -3
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/forgot_name_fail.stderr +4 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_arg_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/handler_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/medium_complex_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/no_handle_conversions_require_into_fail.rs +2 -4
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/no_handle_conversions_require_into_fail.stderr +15 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/simple_pass.rs +2 -4
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/struct_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/struct_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_more_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{fsm/rustfsm_procmacro/tests/trybuild → crates/sdk-core/tests/fsm_trybuild}/tuple_zero_item_event_variant_fail.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/fsm_trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/global_metric_tests.rs +22 -22
- package/sdk-core/{tests → crates/sdk-core/tests/heavy_tests}/fuzzy_workflow.rs +4 -4
- package/sdk-core/{tests → crates/sdk-core/tests}/heavy_tests.rs +25 -14
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/activity_functions.rs +1 -1
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/client_tests.rs +115 -123
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/ephemeral_server_tests.rs +19 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/heartbeat_tests.rs +24 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/metrics_tests.rs +241 -67
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +513 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/queries_tests.rs +13 -11
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/update_tests.rs +47 -29
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/visibility_tests.rs +49 -27
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +1061 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +920 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/worker_versioning_tests.rs +58 -40
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/activities.rs +268 -30
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/appdata_propagation.rs +4 -4
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +155 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +121 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +717 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +109 -0
- package/sdk-core/{core/src/core_tests → crates/sdk-core/tests/integ_tests/workflow_tests}/determinism.rs +108 -20
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/eager.rs +10 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +2884 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +119 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/nexus.rs +174 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +740 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/replay.rs +78 -27
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/resets.rs +46 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +294 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/stickyness.rs +9 -8
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +249 -0
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/upsert_search_attrs.rs +72 -7
- package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests.rs +97 -33
- package/sdk-core/{tests → crates/sdk-core/tests}/main.rs +40 -25
- package/sdk-core/{tests → crates/sdk-core/tests}/manual_tests.rs +25 -15
- package/sdk-core/{tests → crates/sdk-core/tests}/runner.rs +23 -41
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/mod.rs +11 -6
- package/sdk-core/{tests → crates/sdk-core/tests}/shared_tests/priority.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +59 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/include/temporal-sdk-core-c-bridge.h +215 -44
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/client.rs +515 -214
- package/sdk-core/crates/sdk-core-c-bridge/src/envconfig.rs +314 -0
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/lib.rs +2 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/metric.rs +1 -1
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/random.rs +4 -4
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/runtime.rs +42 -28
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/testing.rs +2 -5
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/context.rs +42 -41
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/mod.rs +38 -34
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/tests/utils.rs +10 -11
- package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/src/worker.rs +427 -121
- package/sdk-core/docker-cgroup-tests.sh +24 -0
- package/sdk-core/{docker → etc/docker}/docker-compose-ci.yaml +9 -9
- package/sdk-core/{docker → etc/docker}/docker-compose-telem.yaml +11 -11
- package/sdk-core/{docker → etc/docker}/docker-compose.yaml +8 -8
- package/sdk-core/{integ-with-otel.sh → etc/integ-with-otel.sh} +1 -1
- package/sdk-core/etc/regen-depgraph.sh +2 -2
- package/src/client.rs +117 -49
- package/src/helpers/callbacks.rs +4 -4
- package/src/helpers/errors.rs +7 -1
- package/src/helpers/handles.rs +1 -0
- package/src/helpers/try_from_js.rs +5 -4
- package/src/lib.rs +3 -2
- package/src/logs.rs +1 -1
- package/src/metrics.rs +6 -3
- package/src/runtime.rs +41 -24
- package/src/testing.rs +3 -3
- package/src/worker.rs +77 -44
- package/ts/native.ts +26 -9
- package/LICENSE.md +0 -23
- package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- package/sdk-core/client/src/proxy.rs +0 -90
- package/sdk-core/client/src/worker_registry/mod.rs +0 -266
- package/sdk-core/core/Cargo.toml +0 -146
- package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
- package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
- package/sdk-core/core/src/retry_logic.rs +0 -224
- package/sdk-core/core/src/worker/heartbeat.rs +0 -231
- package/sdk-core/core/src/worker/mod.rs +0 -980
- package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -165
- package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -801
- package/sdk-core/core-c-bridge/Cargo.toml +0 -51
- package/sdk-core/etc/deps.svg +0 -162
- package/sdk-core/fsm/Cargo.toml +0 -21
- package/sdk-core/fsm/README.md +0 -3
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- package/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -15
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- package/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -21
- package/sdk-core/fsm/src/lib.rs +0 -2
- package/sdk-core/sdk-core-protos/Cargo.toml +0 -37
- package/sdk-core/sdk-core-protos/protos/api_cloud_upstream/VERSION +0 -1
- package/sdk-core/test-utils/Cargo.toml +0 -38
- package/sdk-core/test-utils/src/interceptors.rs +0 -46
- package/sdk-core/tests/cloud_tests.rs +0 -23
- package/sdk-core/tests/integ_tests/polling_tests.rs +0 -294
- package/sdk-core/tests/integ_tests/worker_tests.rs +0 -203
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -74
- package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -57
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -246
- package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -65
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -85
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -908
- package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -51
- package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -206
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -164
- package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -123
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/build.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/connectivityrule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/identity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/namespace/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/region/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/resource/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_cloud_upstream/temporal/api/cloud/usage/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/CODEOWNERS +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/ci.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/publish-docs.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/push-to-buf.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-delete-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-publish-release.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/.github/workflows/trigger-api-go-update.yml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/LICENSE +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/README.md +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.gen.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.lock +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/annotations.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/api/http.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/any.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/descriptor.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/duration.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/empty.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/struct.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/timestamp.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/google/protobuf/wrappers.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/openapi/payload_description.txt +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/activity/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/command/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/deployment.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/export/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/history/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/nexus/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/query/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/rules/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/enhanced_stack_trace.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/user_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/worker_config.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/sdk/v1/workflow_metadata.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/update/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/version/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/worker/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/google/rpc/status.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/grpc/health/v1/health.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/common/common.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/core_interface.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/nexus/nexus.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/Makefile +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/api-linter.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/buf.yaml +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -0
- /package/sdk-core/{sdk-core-protos → crates/common}/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/constants.rs +0 -0
- /package/sdk-core/{sdk-core-protos/src → crates/common/src/protos}/task_token.rs +0 -0
- /package/sdk-core/{fsm → crates/macros}/LICENSE.txt +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/abstractions/take_cell.rs +0 -0
- /package/sdk-core/{core → crates/sdk-core}/src/worker/slot_supplier.rs +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/ends_empty_wft_complete.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-16_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-23_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/evict_while_la_running_no_interference-85_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/fail_wf_task.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-0_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-1_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-2_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/long_local_activity_with_update-3_history.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/old_change_marker_format.bin +0 -0
- /package/sdk-core/{histories → crates/sdk-core/tests/histories}/timer_workflow_history.bin +0 -0
- /package/sdk-core/{tests → crates/sdk-core/tests}/integ_tests/workflow_tests/priority.rs +0 -0
- /package/sdk-core/{core-c-bridge → crates/sdk-core-c-bridge}/build.rs +0 -0
- /package/sdk-core/{cargo-tokio-console.sh → etc/cargo-tokio-console.sh} +0 -0
package/sdk-core/{core/src/test_help/mod.rs → crates/sdk-core/src/test_help/integ_helpers.rs}
RENAMED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
//! Integration test helpers - available with test-utilities feature or in test mode
|
|
2
|
+
|
|
3
|
+
#![allow(missing_docs)]
|
|
4
|
+
|
|
5
|
+
pub use crate::{
|
|
6
|
+
internal_flags::CoreInternalFlags,
|
|
7
|
+
worker::{LEGACY_QUERY_ID, client::mocks::mock_worker_client},
|
|
8
|
+
};
|
|
2
9
|
|
|
3
10
|
use crate::{
|
|
4
11
|
TaskToken, Worker, WorkerConfig, WorkerConfigBuilder,
|
|
5
|
-
pollers::{BoxedPoller, MockManualPoller
|
|
12
|
+
pollers::{BoxedPoller, MockManualPoller},
|
|
6
13
|
protosext::ValidPollWFTQResponse,
|
|
7
14
|
replay::TestHistoryBuilder,
|
|
8
15
|
sticky_q_name_for_worker,
|
|
9
16
|
worker::{
|
|
10
17
|
TaskPollers,
|
|
11
|
-
client::{
|
|
12
|
-
LegacyQueryResult, MockWorkerClient, WorkerClient, WorkflowTaskCompletion,
|
|
13
|
-
mocks::mock_worker_client,
|
|
14
|
-
},
|
|
18
|
+
client::{LegacyQueryResult, MockWorkerClient, WorkerClient, WorkflowTaskCompletion},
|
|
15
19
|
},
|
|
16
20
|
};
|
|
21
|
+
use assert_matches::assert_matches;
|
|
17
22
|
use async_trait::async_trait;
|
|
18
23
|
use bimap::BiMap;
|
|
19
24
|
use futures_util::{FutureExt, Stream, StreamExt, future::BoxFuture, stream, stream::BoxStream};
|
|
20
25
|
use mockall::TimesRange;
|
|
21
26
|
use parking_lot::RwLock;
|
|
22
27
|
use std::{
|
|
23
|
-
collections::{BTreeMap, HashMap,
|
|
28
|
+
collections::{BTreeMap, HashMap, VecDeque},
|
|
24
29
|
fmt::Debug,
|
|
25
30
|
ops::{Deref, DerefMut},
|
|
26
31
|
pin::Pin,
|
|
@@ -31,46 +36,76 @@ use std::{
|
|
|
31
36
|
task::{Context, Poll},
|
|
32
37
|
time::Duration,
|
|
33
38
|
};
|
|
34
|
-
use
|
|
35
|
-
use temporal_sdk_core_api::{
|
|
39
|
+
use temporalio_common::{
|
|
36
40
|
Worker as WorkerTrait,
|
|
37
41
|
errors::PollError,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
workflow_commands::workflow_command,
|
|
44
|
-
workflow_completion::{self, WorkflowActivationCompletion, workflow_activation_completion},
|
|
45
|
-
},
|
|
46
|
-
temporal::api::{
|
|
47
|
-
common::v1::WorkflowExecution,
|
|
48
|
-
enums::v1::WorkflowTaskFailedCause,
|
|
49
|
-
failure::v1::Failure,
|
|
50
|
-
protocol,
|
|
51
|
-
protocol::v1::message,
|
|
52
|
-
update,
|
|
53
|
-
workflowservice::v1::{
|
|
54
|
-
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse,
|
|
55
|
-
PollWorkflowTaskQueueResponse, RespondWorkflowTaskCompletedResponse,
|
|
42
|
+
protos::{
|
|
43
|
+
coresdk::{
|
|
44
|
+
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
45
|
+
workflow_commands::{CompleteWorkflowExecution, StartTimer},
|
|
46
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
56
47
|
},
|
|
48
|
+
temporal::api::{
|
|
49
|
+
common::v1::WorkflowExecution,
|
|
50
|
+
enums::v1::WorkflowTaskFailedCause,
|
|
51
|
+
failure::v1::Failure,
|
|
52
|
+
protocol::{self, v1::message},
|
|
53
|
+
update,
|
|
54
|
+
workflowservice::v1::{
|
|
55
|
+
PollActivityTaskQueueResponse, PollNexusTaskQueueResponse,
|
|
56
|
+
PollWorkflowTaskQueueResponse, RespondWorkflowTaskCompletedResponse,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
utilities::pack_any,
|
|
57
60
|
},
|
|
58
|
-
|
|
61
|
+
worker::{PollerBehavior, WorkerTaskTypes, WorkerVersioningStrategy},
|
|
59
62
|
};
|
|
60
|
-
use temporal_sdk_core_test_utils::{NAMESPACE, TestWorker};
|
|
61
63
|
use tokio::sync::{Notify, mpsc::unbounded_channel};
|
|
62
64
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
|
65
|
+
use uuid::Uuid;
|
|
66
|
+
|
|
67
|
+
/// Default namespace for testing
|
|
68
|
+
pub const NAMESPACE: &str = "default";
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
/// Initiate shutdown, drain the pollers (handling evictions), and wait for shutdown to complete.
|
|
71
|
+
pub async fn drain_pollers_and_shutdown(worker: &dyn WorkerTrait) {
|
|
72
|
+
worker.initiate_shutdown();
|
|
73
|
+
tokio::join!(
|
|
74
|
+
async {
|
|
75
|
+
assert_matches!(
|
|
76
|
+
worker.poll_activity_task().await.unwrap_err(),
|
|
77
|
+
PollError::ShutDown
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
async {
|
|
81
|
+
loop {
|
|
82
|
+
match worker.poll_workflow_activation().await {
|
|
83
|
+
Err(PollError::ShutDown) => break,
|
|
84
|
+
Ok(a) if a.is_only_eviction() => {
|
|
85
|
+
worker
|
|
86
|
+
.complete_workflow_activation(WorkflowActivationCompletion::empty(
|
|
87
|
+
a.run_id,
|
|
88
|
+
))
|
|
89
|
+
.await
|
|
90
|
+
.unwrap();
|
|
91
|
+
}
|
|
92
|
+
o => panic!("Unexpected activation while draining: {o:?}"),
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
worker.shutdown().await;
|
|
98
|
+
}
|
|
65
99
|
|
|
66
|
-
pub
|
|
100
|
+
pub fn test_worker_cfg() -> WorkerConfigBuilder {
|
|
67
101
|
let mut wcb = WorkerConfigBuilder::default();
|
|
68
102
|
wcb.namespace(NAMESPACE)
|
|
69
|
-
.task_queue(
|
|
103
|
+
.task_queue(Uuid::new_v4().to_string())
|
|
70
104
|
.versioning_strategy(WorkerVersioningStrategy::None {
|
|
71
105
|
build_id: "test_bin_id".to_string(),
|
|
72
106
|
})
|
|
73
107
|
.ignore_evicts_on_shutdown(true)
|
|
108
|
+
.task_types(WorkerTaskTypes::all())
|
|
74
109
|
// Serial polling since it makes mocking much easier.
|
|
75
110
|
.workflow_task_poller_behavior(PollerBehavior::SimpleMaximum(1_usize));
|
|
76
111
|
wcb
|
|
@@ -79,7 +114,7 @@ pub(crate) fn test_worker_cfg() -> WorkerConfigBuilder {
|
|
|
79
114
|
/// When constructing responses for mocks, indicates how a given response should be built
|
|
80
115
|
#[derive(derive_more::From)]
|
|
81
116
|
#[allow(clippy::large_enum_variant)] // Test only code, whatever.
|
|
82
|
-
pub
|
|
117
|
+
pub enum ResponseType {
|
|
83
118
|
ToTaskNum(usize),
|
|
84
119
|
/// Returns just the history from the WFT completed of the provided task number - 1, through to
|
|
85
120
|
/// the next WFT started. Simulating the incremental history for just the provided task number
|
|
@@ -94,7 +129,7 @@ pub(crate) enum ResponseType {
|
|
|
94
129
|
}
|
|
95
130
|
|
|
96
131
|
#[derive(Eq, PartialEq, Hash)]
|
|
97
|
-
pub
|
|
132
|
+
pub enum HashableResponseType {
|
|
98
133
|
ToTaskNum(usize),
|
|
99
134
|
OneTask(usize),
|
|
100
135
|
UntilResolved(usize),
|
|
@@ -130,7 +165,7 @@ impl From<&usize> for ResponseType {
|
|
|
130
165
|
/// `response_batches` is used to control the fake [PollWorkflowTaskQueueResponse]s returned. For
|
|
131
166
|
/// each number in the input list, a fake response will be prepared which includes history up to the
|
|
132
167
|
/// workflow task with that number, as in [TestHistoryBuilder::get_history_info].
|
|
133
|
-
pub
|
|
168
|
+
pub fn build_fake_worker(
|
|
134
169
|
wf_id: &str,
|
|
135
170
|
t: TestHistoryBuilder,
|
|
136
171
|
response_batches: impl IntoIterator<Item = impl Into<ResponseType>>,
|
|
@@ -148,24 +183,17 @@ pub(crate) fn build_fake_worker(
|
|
|
148
183
|
mock_worker(mock_holder)
|
|
149
184
|
}
|
|
150
185
|
|
|
151
|
-
pub
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
let core = mock_worker(mock);
|
|
158
|
-
let mut worker = temporal_sdk::Worker::new_from_core(Arc::new(core), "replay_q".to_string());
|
|
159
|
-
worker.set_worker_interceptor(FailOnNondeterminismInterceptor {});
|
|
160
|
-
worker
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
pub(crate) fn mock_worker(mocks: MocksHolder) -> Worker {
|
|
164
|
-
let sticky_q = sticky_q_name_for_worker("unit-test", &mocks.inputs.config);
|
|
165
|
-
let act_poller = if mocks.inputs.config.no_remote_activities {
|
|
186
|
+
pub fn mock_worker(mocks: MocksHolder) -> Worker {
|
|
187
|
+
let sticky_q = sticky_q_name_for_worker("unit-test", mocks.inputs.config.max_cached_workflows);
|
|
188
|
+
let act_poller = if mocks.inputs.config.task_types.enable_remote_activities {
|
|
189
|
+
mocks.inputs.act_poller
|
|
190
|
+
} else {
|
|
166
191
|
None
|
|
192
|
+
};
|
|
193
|
+
let nexus_poller = if mocks.inputs.config.task_types.enable_nexus {
|
|
194
|
+
mocks.inputs.nexus_poller
|
|
167
195
|
} else {
|
|
168
|
-
|
|
196
|
+
None
|
|
169
197
|
};
|
|
170
198
|
Worker::new_with_pollers(
|
|
171
199
|
mocks.inputs.config,
|
|
@@ -174,45 +202,30 @@ pub(crate) fn mock_worker(mocks: MocksHolder) -> Worker {
|
|
|
174
202
|
TaskPollers::Mocked {
|
|
175
203
|
wft_stream: mocks.inputs.wft_stream,
|
|
176
204
|
act_poller,
|
|
177
|
-
nexus_poller
|
|
178
|
-
.inputs
|
|
179
|
-
.nexus_poller
|
|
180
|
-
.unwrap_or_else(|| mock_poller_from_resps([])),
|
|
205
|
+
nexus_poller,
|
|
181
206
|
},
|
|
182
207
|
None,
|
|
183
208
|
None,
|
|
209
|
+
false,
|
|
184
210
|
)
|
|
211
|
+
.unwrap()
|
|
185
212
|
}
|
|
186
213
|
|
|
187
|
-
pub
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
pub
|
|
191
|
-
mut poll_cfg: MockPollCfg,
|
|
192
|
-
mutator: impl FnOnce(&mut WorkerConfig),
|
|
193
|
-
) -> TestWorker {
|
|
194
|
-
poll_cfg.using_rust_sdk = true;
|
|
195
|
-
let mut mock = build_mock_pollers(poll_cfg);
|
|
196
|
-
mock.worker_cfg(mutator);
|
|
197
|
-
let core = mock_worker(mock);
|
|
198
|
-
TestWorker::new(Arc::new(core), TEST_Q.to_string())
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
pub(crate) struct FakeWfResponses {
|
|
202
|
-
pub(crate) wf_id: String,
|
|
203
|
-
pub(crate) hist: TestHistoryBuilder,
|
|
204
|
-
pub(crate) response_batches: Vec<ResponseType>,
|
|
214
|
+
pub struct FakeWfResponses {
|
|
215
|
+
pub wf_id: String,
|
|
216
|
+
pub hist: TestHistoryBuilder,
|
|
217
|
+
pub response_batches: Vec<ResponseType>,
|
|
205
218
|
}
|
|
206
219
|
|
|
207
220
|
// TODO: Should be all-internal to this module
|
|
208
|
-
pub
|
|
221
|
+
pub struct MocksHolder {
|
|
209
222
|
client: Arc<dyn WorkerClient>,
|
|
210
223
|
inputs: MockWorkerInputs,
|
|
211
|
-
pub
|
|
224
|
+
pub outstanding_task_map: Option<OutstandingWFTMap>,
|
|
212
225
|
}
|
|
213
226
|
|
|
214
227
|
impl MocksHolder {
|
|
215
|
-
pub
|
|
228
|
+
pub fn worker_cfg(&mut self, mutator: impl FnOnce(&mut WorkerConfig)) {
|
|
216
229
|
mutator(&mut self.inputs.config);
|
|
217
230
|
}
|
|
218
231
|
|
|
@@ -220,15 +233,38 @@ impl MocksHolder {
|
|
|
220
233
|
self.inputs.act_poller = Some(poller);
|
|
221
234
|
}
|
|
222
235
|
|
|
236
|
+
/// Helper to create and set an activity poller from responses
|
|
237
|
+
#[cfg(test)]
|
|
238
|
+
pub(crate) fn set_act_poller_from_resps<ACT>(&mut self, act_tasks: ACT)
|
|
239
|
+
where
|
|
240
|
+
ACT: IntoIterator<Item = QueueResponse<PollActivityTaskQueueResponse>>,
|
|
241
|
+
<ACT as IntoIterator>::IntoIter: Send + 'static,
|
|
242
|
+
{
|
|
243
|
+
let act_poller = mock_poller_from_resps(act_tasks);
|
|
244
|
+
self.set_act_poller(act_poller);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/// Helper to create and set a nexus poller from responses
|
|
248
|
+
#[cfg(test)]
|
|
249
|
+
pub(crate) fn set_nexus_poller_from_resps<NEX>(&mut self, nexus_tasks: NEX)
|
|
250
|
+
where
|
|
251
|
+
NEX: IntoIterator<Item = QueueResponse<PollNexusTaskQueueResponse>>,
|
|
252
|
+
<NEX as IntoIterator>::IntoIter: Send + 'static,
|
|
253
|
+
{
|
|
254
|
+
let nexus_poller = mock_poller_from_resps(nexus_tasks);
|
|
255
|
+
self.inputs.nexus_poller = Some(nexus_poller);
|
|
256
|
+
}
|
|
257
|
+
|
|
223
258
|
/// Can be used for tests that need to avoid auto-shutdown due to running out of mock responses
|
|
224
|
-
pub
|
|
225
|
-
let old_stream =
|
|
226
|
-
|
|
259
|
+
pub fn make_wft_stream_interminable(&mut self) {
|
|
260
|
+
if let Some(old_stream) = self.inputs.wft_stream.take() {
|
|
261
|
+
self.inputs.wft_stream = Some(old_stream.chain(stream::pending()).boxed());
|
|
262
|
+
}
|
|
227
263
|
}
|
|
228
264
|
}
|
|
229
265
|
|
|
230
|
-
pub
|
|
231
|
-
pub(crate) wft_stream: BoxStream<'static, Result<ValidPollWFTQResponse, tonic::Status
|
|
266
|
+
pub struct MockWorkerInputs {
|
|
267
|
+
pub(crate) wft_stream: Option<BoxStream<'static, Result<ValidPollWFTQResponse, tonic::Status>>>,
|
|
232
268
|
pub(crate) act_poller: Option<BoxedPoller<PollActivityTaskQueueResponse>>,
|
|
233
269
|
pub(crate) nexus_poller: Option<BoxedPoller<PollNexusTaskQueueResponse>>,
|
|
234
270
|
pub(crate) config: WorkerConfig,
|
|
@@ -245,7 +281,7 @@ impl MockWorkerInputs {
|
|
|
245
281
|
wft_stream: BoxStream<'static, Result<ValidPollWFTQResponse, tonic::Status>>,
|
|
246
282
|
) -> Self {
|
|
247
283
|
Self {
|
|
248
|
-
wft_stream,
|
|
284
|
+
wft_stream: Some(wft_stream),
|
|
249
285
|
act_poller: None,
|
|
250
286
|
nexus_poller: None,
|
|
251
287
|
config: test_worker_cfg().build().unwrap(),
|
|
@@ -254,7 +290,7 @@ impl MockWorkerInputs {
|
|
|
254
290
|
}
|
|
255
291
|
|
|
256
292
|
impl MocksHolder {
|
|
257
|
-
pub
|
|
293
|
+
pub fn from_mock_worker(
|
|
258
294
|
client: impl WorkerClient + 'static,
|
|
259
295
|
mock_worker: MockWorkerInputs,
|
|
260
296
|
) -> Self {
|
|
@@ -265,8 +301,8 @@ impl MocksHolder {
|
|
|
265
301
|
}
|
|
266
302
|
}
|
|
267
303
|
|
|
268
|
-
/// Uses the provided list of tasks to create a mock poller
|
|
269
|
-
pub
|
|
304
|
+
/// Uses the provided list of tasks to create a mock poller with a randomly generated task queue
|
|
305
|
+
pub fn from_client_with_activities<ACT>(
|
|
270
306
|
client: impl WorkerClient + 'static,
|
|
271
307
|
act_tasks: ACT,
|
|
272
308
|
) -> Self
|
|
@@ -274,10 +310,9 @@ impl MocksHolder {
|
|
|
274
310
|
ACT: IntoIterator<Item = QueueResponse<PollActivityTaskQueueResponse>>,
|
|
275
311
|
<ACT as IntoIterator>::IntoIter: Send + 'static,
|
|
276
312
|
{
|
|
277
|
-
let wft_stream = stream::pending().boxed();
|
|
278
313
|
let mock_act_poller = mock_poller_from_resps(act_tasks);
|
|
279
314
|
let mock_worker = MockWorkerInputs {
|
|
280
|
-
wft_stream,
|
|
315
|
+
wft_stream: None,
|
|
281
316
|
act_poller: Some(mock_act_poller),
|
|
282
317
|
nexus_poller: None,
|
|
283
318
|
config: test_worker_cfg().build().unwrap(),
|
|
@@ -289,16 +324,78 @@ impl MocksHolder {
|
|
|
289
324
|
}
|
|
290
325
|
}
|
|
291
326
|
|
|
327
|
+
/// Uses the provided list of tasks to create a mock poller with a randomly generated task queue
|
|
328
|
+
pub fn from_client_with_nexus<NEX>(
|
|
329
|
+
client: impl WorkerClient + 'static,
|
|
330
|
+
nexus_tasks: NEX,
|
|
331
|
+
) -> Self
|
|
332
|
+
where
|
|
333
|
+
NEX: IntoIterator<Item = QueueResponse<PollNexusTaskQueueResponse>>,
|
|
334
|
+
<NEX as IntoIterator>::IntoIter: Send + 'static,
|
|
335
|
+
{
|
|
336
|
+
let mock_nexus_poller = mock_poller_from_resps(nexus_tasks);
|
|
337
|
+
let mock_worker = MockWorkerInputs {
|
|
338
|
+
wft_stream: None,
|
|
339
|
+
act_poller: None,
|
|
340
|
+
nexus_poller: Some(mock_nexus_poller),
|
|
341
|
+
config: test_worker_cfg().build().unwrap(),
|
|
342
|
+
};
|
|
343
|
+
Self {
|
|
344
|
+
client: Arc::new(client),
|
|
345
|
+
inputs: mock_worker,
|
|
346
|
+
outstanding_task_map: None,
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/// Create a MocksHolder with custom combination of task pollers.
|
|
351
|
+
/// Allows any combination of workflow, activity, and nexus tasks.
|
|
352
|
+
pub fn from_client_with_custom<WFT, ACT, NEX>(
|
|
353
|
+
client: impl WorkerClient + 'static,
|
|
354
|
+
wft_stream: Option<WFT>,
|
|
355
|
+
activity_tasks: Option<ACT>,
|
|
356
|
+
nexus_tasks: Option<NEX>,
|
|
357
|
+
) -> Self
|
|
358
|
+
where
|
|
359
|
+
WFT: Stream<Item = PollWorkflowTaskQueueResponse> + Send + 'static,
|
|
360
|
+
ACT: IntoIterator<Item = QueueResponse<PollActivityTaskQueueResponse>>,
|
|
361
|
+
<ACT as IntoIterator>::IntoIter: Send + 'static,
|
|
362
|
+
NEX: IntoIterator<Item = QueueResponse<PollNexusTaskQueueResponse>>,
|
|
363
|
+
<NEX as IntoIterator>::IntoIter: Send + 'static,
|
|
364
|
+
{
|
|
365
|
+
let wft_stream = wft_stream.map(|s| {
|
|
366
|
+
s.map(|r| Ok(r.try_into().expect("Mock responses must be valid work")))
|
|
367
|
+
.boxed()
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
let act_poller = activity_tasks.map(|tasks| mock_poller_from_resps(tasks));
|
|
371
|
+
let nexus_poller = nexus_tasks.map(|tasks| mock_poller_from_resps(tasks));
|
|
372
|
+
|
|
373
|
+
let mock_worker = MockWorkerInputs {
|
|
374
|
+
wft_stream,
|
|
375
|
+
act_poller,
|
|
376
|
+
nexus_poller,
|
|
377
|
+
config: test_worker_cfg().build().unwrap(),
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
Self {
|
|
381
|
+
client: Arc::new(client),
|
|
382
|
+
inputs: mock_worker,
|
|
383
|
+
outstanding_task_map: None,
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
292
387
|
/// Uses the provided task responses and delivers them as quickly as possible when polled.
|
|
293
388
|
/// This is only useful to test buffering, as typically you do not want to pretend that
|
|
294
389
|
/// the server is delivering WFTs super fast for the same run.
|
|
295
|
-
pub
|
|
390
|
+
pub fn from_wft_stream(
|
|
296
391
|
client: impl WorkerClient + 'static,
|
|
297
392
|
stream: impl Stream<Item = PollWorkflowTaskQueueResponse> + Send + 'static,
|
|
298
393
|
) -> Self {
|
|
299
|
-
let wft_stream =
|
|
300
|
-
|
|
301
|
-
|
|
394
|
+
let wft_stream = Some(
|
|
395
|
+
stream
|
|
396
|
+
.map(|r| Ok(r.try_into().expect("Mock responses must be valid work")))
|
|
397
|
+
.boxed(),
|
|
398
|
+
);
|
|
302
399
|
let mock_worker = MockWorkerInputs {
|
|
303
400
|
wft_stream,
|
|
304
401
|
act_poller: None,
|
|
@@ -313,8 +410,7 @@ impl MocksHolder {
|
|
|
313
410
|
}
|
|
314
411
|
}
|
|
315
412
|
|
|
316
|
-
|
|
317
|
-
pub(crate) fn mock_poller_from_resps<T, I>(tasks: I) -> BoxedPoller<T>
|
|
413
|
+
fn mock_poller_from_resps<T, I>(tasks: I) -> BoxedPoller<T>
|
|
318
414
|
where
|
|
319
415
|
T: Send + Sync + 'static,
|
|
320
416
|
I: IntoIterator<Item = QueueResponse<T>>,
|
|
@@ -338,16 +434,6 @@ where
|
|
|
338
434
|
Box::new(mock_poller) as BoxedPoller<T>
|
|
339
435
|
}
|
|
340
436
|
|
|
341
|
-
pub(crate) fn mock_poller<T>() -> MockPoller<T>
|
|
342
|
-
where
|
|
343
|
-
T: Send + Sync + 'static,
|
|
344
|
-
{
|
|
345
|
-
let mut mock_poller = MockPoller::new();
|
|
346
|
-
mock_poller.expect_shutdown_box().return_const(());
|
|
347
|
-
mock_poller.expect_notify_shutdown().return_const(());
|
|
348
|
-
mock_poller
|
|
349
|
-
}
|
|
350
|
-
|
|
351
437
|
pub(crate) fn mock_manual_poller<T>() -> MockManualPoller<T>
|
|
352
438
|
where
|
|
353
439
|
T: Send + Sync + 'static,
|
|
@@ -369,7 +455,7 @@ where
|
|
|
369
455
|
///
|
|
370
456
|
/// `num_expected_fails` can be provided to set a specific number of expected failed workflow tasks
|
|
371
457
|
/// sent to the server.
|
|
372
|
-
pub
|
|
458
|
+
pub fn build_multihist_mock_sg(
|
|
373
459
|
hists: impl IntoIterator<Item = FakeWfResponses>,
|
|
374
460
|
enforce_correct_number_of_polls: bool,
|
|
375
461
|
num_expected_fails: usize,
|
|
@@ -383,7 +469,7 @@ pub(crate) fn build_multihist_mock_sg(
|
|
|
383
469
|
}
|
|
384
470
|
|
|
385
471
|
/// See [build_multihist_mock_sg] -- one history convenience version
|
|
386
|
-
pub
|
|
472
|
+
pub fn single_hist_mock_sg(
|
|
387
473
|
wf_id: &str,
|
|
388
474
|
t: TestHistoryBuilder,
|
|
389
475
|
response_batches: impl IntoIterator<Item = impl Into<ResponseType>>,
|
|
@@ -399,29 +485,31 @@ type WFTCompletionMockFn = dyn FnMut(&WorkflowTaskCompletion) -> Result<RespondW
|
|
|
399
485
|
+ Send;
|
|
400
486
|
|
|
401
487
|
#[allow(clippy::type_complexity)]
|
|
402
|
-
pub
|
|
403
|
-
pub
|
|
404
|
-
pub
|
|
405
|
-
pub
|
|
406
|
-
pub
|
|
407
|
-
pub
|
|
488
|
+
pub struct MockPollCfg {
|
|
489
|
+
pub hists: Vec<FakeWfResponses>,
|
|
490
|
+
pub enforce_correct_number_of_polls: bool,
|
|
491
|
+
pub num_expected_fails: usize,
|
|
492
|
+
pub num_expected_legacy_query_resps: usize,
|
|
493
|
+
pub mock_client: MockWorkerClient,
|
|
408
494
|
/// All calls to fail WFTs must match this predicate
|
|
409
|
-
pub
|
|
495
|
+
pub expect_fail_wft_matcher:
|
|
410
496
|
Box<dyn Fn(&TaskToken, &WorkflowTaskFailedCause, &Option<Failure>) -> bool + Send>,
|
|
411
497
|
/// All calls to legacy query responses must match this predicate
|
|
412
|
-
pub(
|
|
413
|
-
|
|
414
|
-
pub
|
|
415
|
-
pub(crate) num_expected_completions: Option<TimesRange>,
|
|
498
|
+
pub expect_legacy_query_matcher: Box<dyn Fn(&TaskToken, &LegacyQueryResult) -> bool + Send>,
|
|
499
|
+
pub completion_mock_fn: Option<Box<WFTCompletionMockFn>>,
|
|
500
|
+
pub num_expected_completions: Option<TimesRange>,
|
|
416
501
|
/// If being used with the Rust SDK, this is set true. It ensures pollers will not error out
|
|
417
502
|
/// early with no work, since we cannot know the exact number of times polling will happen.
|
|
418
503
|
/// Instead, they will just block forever.
|
|
419
|
-
pub
|
|
420
|
-
pub
|
|
504
|
+
pub using_rust_sdk: bool,
|
|
505
|
+
pub make_poll_stream_interminable: bool,
|
|
506
|
+
/// If set, will create a mock activity poller with the provided responeses. If unset, no poller
|
|
507
|
+
/// is created.
|
|
508
|
+
pub activity_responses: Option<Vec<QueueResponse<PollActivityTaskQueueResponse>>>,
|
|
421
509
|
}
|
|
422
510
|
|
|
423
511
|
impl MockPollCfg {
|
|
424
|
-
pub
|
|
512
|
+
pub fn new(
|
|
425
513
|
hists: Vec<FakeWfResponses>,
|
|
426
514
|
enforce_correct_number_of_polls: bool,
|
|
427
515
|
num_expected_fails: usize,
|
|
@@ -438,24 +526,25 @@ impl MockPollCfg {
|
|
|
438
526
|
num_expected_completions: None,
|
|
439
527
|
using_rust_sdk: false,
|
|
440
528
|
make_poll_stream_interminable: false,
|
|
529
|
+
activity_responses: None,
|
|
441
530
|
}
|
|
442
531
|
}
|
|
443
532
|
|
|
444
533
|
/// Builds a config which will hand out each WFT in the history builder one by one
|
|
445
|
-
pub
|
|
534
|
+
pub fn from_hist_builder(t: TestHistoryBuilder) -> Self {
|
|
446
535
|
let full_hist_info = t.get_full_history_info().unwrap();
|
|
447
536
|
let tasks = 1..=full_hist_info.wf_task_count();
|
|
448
537
|
Self::from_resp_batches("fake_wf_id", t, tasks, mock_worker_client())
|
|
449
538
|
}
|
|
450
539
|
|
|
451
|
-
pub
|
|
540
|
+
pub fn from_resps(
|
|
452
541
|
t: TestHistoryBuilder,
|
|
453
542
|
resps: impl IntoIterator<Item = impl Into<ResponseType>>,
|
|
454
543
|
) -> Self {
|
|
455
544
|
Self::from_resp_batches("fake_wf_id", t, resps, mock_worker_client())
|
|
456
545
|
}
|
|
457
546
|
|
|
458
|
-
pub
|
|
547
|
+
pub fn from_resp_batches(
|
|
459
548
|
wf_id: &str,
|
|
460
549
|
t: TestHistoryBuilder,
|
|
461
550
|
resps: impl IntoIterator<Item = impl Into<ResponseType>>,
|
|
@@ -477,10 +566,11 @@ impl MockPollCfg {
|
|
|
477
566
|
num_expected_completions: None,
|
|
478
567
|
using_rust_sdk: false,
|
|
479
568
|
make_poll_stream_interminable: false,
|
|
569
|
+
activity_responses: None,
|
|
480
570
|
}
|
|
481
571
|
}
|
|
482
572
|
|
|
483
|
-
pub
|
|
573
|
+
pub fn completion_asserts_from_expectations(
|
|
484
574
|
&mut self,
|
|
485
575
|
builder_fn: impl FnOnce(CompletionAssertsBuilder<'_>),
|
|
486
576
|
) {
|
|
@@ -493,13 +583,13 @@ impl MockPollCfg {
|
|
|
493
583
|
}
|
|
494
584
|
|
|
495
585
|
#[allow(clippy::type_complexity)]
|
|
496
|
-
pub
|
|
586
|
+
pub struct CompletionAssertsBuilder<'a> {
|
|
497
587
|
dest: &'a mut Option<Box<WFTCompletionMockFn>>,
|
|
498
588
|
assertions: VecDeque<Box<dyn FnOnce(&WorkflowTaskCompletion) + Send>>,
|
|
499
589
|
}
|
|
500
590
|
|
|
501
591
|
impl CompletionAssertsBuilder<'_> {
|
|
502
|
-
pub
|
|
592
|
+
pub fn then(
|
|
503
593
|
&mut self,
|
|
504
594
|
assert: impl FnOnce(&WorkflowTaskCompletion) + Send + 'static,
|
|
505
595
|
) -> &mut Self {
|
|
@@ -521,7 +611,7 @@ impl Drop for CompletionAssertsBuilder<'_> {
|
|
|
521
611
|
}
|
|
522
612
|
|
|
523
613
|
#[derive(Default, Clone)]
|
|
524
|
-
pub
|
|
614
|
+
pub struct OutstandingWFTMap {
|
|
525
615
|
map: Arc<RwLock<BiMap<String, TaskToken>>>,
|
|
526
616
|
waker: Arc<Notify>,
|
|
527
617
|
all_work_delivered: Arc<AtomicBool>,
|
|
@@ -541,12 +631,12 @@ impl OutstandingWFTMap {
|
|
|
541
631
|
self.waker.notify_one();
|
|
542
632
|
}
|
|
543
633
|
|
|
544
|
-
pub
|
|
634
|
+
pub fn release_run(&self, run_id: &str) {
|
|
545
635
|
self.map.write().remove_by_left(run_id);
|
|
546
636
|
self.waker.notify_waiters();
|
|
547
637
|
}
|
|
548
638
|
|
|
549
|
-
pub
|
|
639
|
+
pub fn all_work_delivered(&self) -> bool {
|
|
550
640
|
self.all_work_delivered.load(Ordering::Acquire)
|
|
551
641
|
}
|
|
552
642
|
}
|
|
@@ -571,7 +661,7 @@ impl Drop for EnsuresWorkDoneWFTStream {
|
|
|
571
661
|
}
|
|
572
662
|
|
|
573
663
|
/// Given an iterable of fake responses, return the mocks & associated data to work with them
|
|
574
|
-
pub
|
|
664
|
+
pub fn build_mock_pollers(mut cfg: MockPollCfg) -> MocksHolder {
|
|
575
665
|
let mut task_q_resps: BTreeMap<String, VecDeque<_>> = BTreeMap::new();
|
|
576
666
|
let all_work_delivered = if cfg.enforce_correct_number_of_polls && !cfg.using_rust_sdk {
|
|
577
667
|
Arc::new(AtomicBool::new(false))
|
|
@@ -657,7 +747,6 @@ pub(crate) fn build_mock_pollers(mut cfg: MockPollCfg) -> MocksHolder {
|
|
|
657
747
|
)
|
|
658
748
|
.is_err()
|
|
659
749
|
{
|
|
660
|
-
dbg!("Exiting mock WFT task because rcv half of stream was dropped");
|
|
661
750
|
break;
|
|
662
751
|
}
|
|
663
752
|
}
|
|
@@ -728,15 +817,19 @@ pub(crate) fn build_mock_pollers(mut cfg: MockPollCfg) -> MocksHolder {
|
|
|
728
817
|
inputs: mock_worker,
|
|
729
818
|
outstanding_task_map: Some(outstanding_wf_task_tokens),
|
|
730
819
|
};
|
|
820
|
+
if let Some(activity_responses) = cfg.activity_responses {
|
|
821
|
+
let act_poller = mock_poller_from_resps(activity_responses);
|
|
822
|
+
mh.set_act_poller(act_poller);
|
|
823
|
+
}
|
|
731
824
|
if cfg.make_poll_stream_interminable {
|
|
732
825
|
mh.make_wft_stream_interminable();
|
|
733
826
|
}
|
|
734
827
|
mh
|
|
735
828
|
}
|
|
736
829
|
|
|
737
|
-
pub
|
|
738
|
-
pub
|
|
739
|
-
pub
|
|
830
|
+
pub struct QueueResponse<T> {
|
|
831
|
+
pub resp: T,
|
|
832
|
+
pub delay_until: Option<BoxFuture<'static, ()>>,
|
|
740
833
|
}
|
|
741
834
|
|
|
742
835
|
impl<T> From<T> for QueueResponse<T> {
|
|
@@ -777,7 +870,7 @@ where
|
|
|
777
870
|
}
|
|
778
871
|
}
|
|
779
872
|
|
|
780
|
-
pub
|
|
873
|
+
pub trait PollWFTRespExt {
|
|
781
874
|
/// Add an update request to the poll response, using the update name "update_fn" and no args.
|
|
782
875
|
/// Returns the inner request body.
|
|
783
876
|
fn add_update_request(
|
|
@@ -820,7 +913,7 @@ impl PollWFTRespExt for PollWorkflowTaskQueueResponse {
|
|
|
820
913
|
}
|
|
821
914
|
}
|
|
822
915
|
|
|
823
|
-
pub
|
|
916
|
+
pub fn hist_to_poll_resp(
|
|
824
917
|
t: &TestHistoryBuilder,
|
|
825
918
|
wf_id: impl Into<String>,
|
|
826
919
|
response_type: ResponseType,
|
|
@@ -857,175 +950,6 @@ pub(crate) fn hist_to_poll_resp(
|
|
|
857
950
|
QueueResponse { resp, delay_until }
|
|
858
951
|
}
|
|
859
952
|
|
|
860
|
-
type AsserterWithReply<'a> = (
|
|
861
|
-
&'a dyn Fn(&WorkflowActivation),
|
|
862
|
-
workflow_activation_completion::Status,
|
|
863
|
-
);
|
|
864
|
-
|
|
865
|
-
/// Determines when workflows are kept in the cache or evicted for [poll_and_reply] type tests
|
|
866
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
867
|
-
pub(crate) enum WorkflowCachingPolicy {
|
|
868
|
-
/// Workflows are evicted after each workflow task completion. Note that this is *not* after
|
|
869
|
-
/// each workflow activation - there are often multiple activations per workflow task.
|
|
870
|
-
NonSticky,
|
|
871
|
-
|
|
872
|
-
/// Not a real mode, but good for imitating crashes. Evict workflows after *every* reply,
|
|
873
|
-
/// even if there are pending activations
|
|
874
|
-
#[cfg(test)]
|
|
875
|
-
AfterEveryReply,
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/// This function accepts a list of asserts and replies to workflow activations to run against the
|
|
879
|
-
/// provided instance of fake core.
|
|
880
|
-
///
|
|
881
|
-
/// It handles the business of re-sending the same activation replies over again in the event
|
|
882
|
-
/// of eviction or workflow activation failure. Activation failures specifically are only run once,
|
|
883
|
-
/// since they clearly can't be returned every time we replay the workflow, or it could never
|
|
884
|
-
/// proceed
|
|
885
|
-
pub(crate) async fn poll_and_reply<'a>(
|
|
886
|
-
worker: &'a Worker,
|
|
887
|
-
eviction_mode: WorkflowCachingPolicy,
|
|
888
|
-
expect_and_reply: &'a [AsserterWithReply<'a>],
|
|
889
|
-
) {
|
|
890
|
-
poll_and_reply_clears_outstanding_evicts(worker, None, eviction_mode, expect_and_reply).await;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
pub(crate) async fn poll_and_reply_clears_outstanding_evicts<'a>(
|
|
894
|
-
worker: &'a Worker,
|
|
895
|
-
outstanding_map: Option<OutstandingWFTMap>,
|
|
896
|
-
eviction_mode: WorkflowCachingPolicy,
|
|
897
|
-
expect_and_reply: &'a [AsserterWithReply<'a>],
|
|
898
|
-
) {
|
|
899
|
-
let mut evictions = 0;
|
|
900
|
-
let expected_evictions = expect_and_reply.len() - 1;
|
|
901
|
-
let mut executed_failures = HashSet::new();
|
|
902
|
-
let expected_fail_count = expect_and_reply
|
|
903
|
-
.iter()
|
|
904
|
-
.filter(|(_, reply)| !reply.is_success())
|
|
905
|
-
.count();
|
|
906
|
-
|
|
907
|
-
'outer: loop {
|
|
908
|
-
let expect_iter = expect_and_reply.iter();
|
|
909
|
-
|
|
910
|
-
for (i, interaction) in expect_iter.enumerate() {
|
|
911
|
-
let (asserter, reply) = interaction;
|
|
912
|
-
let complete_is_failure = !reply.is_success();
|
|
913
|
-
// Only send activation failures once
|
|
914
|
-
if executed_failures.contains(&i) {
|
|
915
|
-
continue;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
let mut res = worker.poll_workflow_activation().await.unwrap();
|
|
919
|
-
if res.jobs.iter().any(|j| {
|
|
920
|
-
matches!(
|
|
921
|
-
j.variant,
|
|
922
|
-
Some(workflow_activation_job::Variant::RemoveFromCache(_))
|
|
923
|
-
)
|
|
924
|
-
}) && res.jobs.len() > 1
|
|
925
|
-
{
|
|
926
|
-
panic!("Saw an activation with an eviction & other work! {res:?}");
|
|
927
|
-
}
|
|
928
|
-
let is_eviction = res.is_only_eviction();
|
|
929
|
-
|
|
930
|
-
let mut do_release = false;
|
|
931
|
-
|
|
932
|
-
if is_eviction {
|
|
933
|
-
// If the job is an eviction, clear it, since in the tests we don't explicitly
|
|
934
|
-
// specify evict assertions
|
|
935
|
-
res.jobs.clear();
|
|
936
|
-
do_release = true;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
// TODO: Can remove this if?
|
|
940
|
-
if !res.jobs.is_empty() {
|
|
941
|
-
asserter(&res);
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
let reply = if res.jobs.is_empty() {
|
|
945
|
-
// Just an eviction
|
|
946
|
-
WorkflowActivationCompletion::empty(res.run_id.clone())
|
|
947
|
-
} else {
|
|
948
|
-
// Eviction plus some work, we still want to issue the reply
|
|
949
|
-
WorkflowActivationCompletion {
|
|
950
|
-
run_id: res.run_id.clone(),
|
|
951
|
-
status: Some(reply.clone()),
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
let ends_execution = reply.has_execution_ending();
|
|
956
|
-
|
|
957
|
-
worker.complete_workflow_activation(reply).await.unwrap();
|
|
958
|
-
|
|
959
|
-
if do_release && let Some(omap) = outstanding_map.as_ref() {
|
|
960
|
-
omap.release_run(&res.run_id);
|
|
961
|
-
}
|
|
962
|
-
// Restart assertions from the beginning if it was an eviction (and workflow execution
|
|
963
|
-
// isn't over)
|
|
964
|
-
if is_eviction && !ends_execution {
|
|
965
|
-
continue 'outer;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
if complete_is_failure {
|
|
969
|
-
executed_failures.insert(i);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
match eviction_mode {
|
|
973
|
-
WorkflowCachingPolicy::NonSticky => (),
|
|
974
|
-
WorkflowCachingPolicy::AfterEveryReply => {
|
|
975
|
-
if evictions < expected_evictions {
|
|
976
|
-
worker.request_workflow_eviction(&res.run_id);
|
|
977
|
-
evictions += 1;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
break;
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
assert_eq!(expected_fail_count, executed_failures.len());
|
|
987
|
-
assert_eq!(worker.outstanding_workflow_tasks().await, 0);
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
pub(crate) fn gen_assert_and_reply(
|
|
991
|
-
asserter: &dyn Fn(&WorkflowActivation),
|
|
992
|
-
reply_commands: Vec<workflow_command::Variant>,
|
|
993
|
-
) -> AsserterWithReply<'_> {
|
|
994
|
-
(
|
|
995
|
-
asserter,
|
|
996
|
-
workflow_completion::Success::from_variants(reply_commands).into(),
|
|
997
|
-
)
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
pub(crate) fn gen_assert_and_fail(asserter: &dyn Fn(&WorkflowActivation)) -> AsserterWithReply<'_> {
|
|
1001
|
-
(
|
|
1002
|
-
asserter,
|
|
1003
|
-
workflow_completion::Failure {
|
|
1004
|
-
failure: Some(Failure {
|
|
1005
|
-
message: "Intentional test failure".to_string(),
|
|
1006
|
-
..Default::default()
|
|
1007
|
-
}),
|
|
1008
|
-
..Default::default()
|
|
1009
|
-
}
|
|
1010
|
-
.into(),
|
|
1011
|
-
)
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
/// Generate asserts for [poll_and_reply] by passing patterns to match against the job list
|
|
1015
|
-
#[macro_export]
|
|
1016
|
-
macro_rules! job_assert {
|
|
1017
|
-
($($pat:pat),+) => {
|
|
1018
|
-
|res| {
|
|
1019
|
-
assert_matches!(
|
|
1020
|
-
res.jobs.as_slice(),
|
|
1021
|
-
[$(WorkflowActivationJob {
|
|
1022
|
-
variant: Some($pat),
|
|
1023
|
-
}),+]
|
|
1024
|
-
);
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
953
|
/// Forcibly drive a future a number of times, enforcing it is always returning Pending. This is
|
|
1030
954
|
/// useful for ensuring some future has proceeded "enough" before racing it against another future.
|
|
1031
955
|
#[macro_export]
|
|
@@ -1054,7 +978,7 @@ macro_rules! prost_dur {
|
|
|
1054
978
|
}
|
|
1055
979
|
|
|
1056
980
|
#[async_trait]
|
|
1057
|
-
pub
|
|
981
|
+
pub trait WorkerExt {
|
|
1058
982
|
/// Initiate shutdown, drain the pollers, and wait for shutdown to complete.
|
|
1059
983
|
async fn drain_pollers_and_shutdown(self);
|
|
1060
984
|
/// Initiate shutdown, drain the *activity* poller, and wait for shutdown to complete.
|
|
@@ -1065,30 +989,7 @@ pub(crate) trait WorkerExt {
|
|
|
1065
989
|
#[async_trait]
|
|
1066
990
|
impl WorkerExt for Worker {
|
|
1067
991
|
async fn drain_pollers_and_shutdown(self) {
|
|
1068
|
-
self.
|
|
1069
|
-
tokio::join!(
|
|
1070
|
-
async {
|
|
1071
|
-
assert_matches!(
|
|
1072
|
-
self.poll_activity_task().await.unwrap_err(),
|
|
1073
|
-
PollError::ShutDown
|
|
1074
|
-
);
|
|
1075
|
-
},
|
|
1076
|
-
async {
|
|
1077
|
-
loop {
|
|
1078
|
-
match self.poll_workflow_activation().await {
|
|
1079
|
-
Err(PollError::ShutDown) => break,
|
|
1080
|
-
Ok(a) if a.is_only_eviction() => {
|
|
1081
|
-
self.complete_workflow_activation(WorkflowActivationCompletion::empty(
|
|
1082
|
-
a.run_id,
|
|
1083
|
-
))
|
|
1084
|
-
.await
|
|
1085
|
-
.unwrap();
|
|
1086
|
-
}
|
|
1087
|
-
o => panic!("Unexpected activation while draining: {o:?}"),
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
);
|
|
992
|
+
drain_pollers_and_shutdown(&self).await;
|
|
1092
993
|
self.finalize_shutdown().await;
|
|
1093
994
|
}
|
|
1094
995
|
|
|
@@ -1101,3 +1002,57 @@ impl WorkerExt for Worker {
|
|
|
1101
1002
|
self.shutdown().await;
|
|
1102
1003
|
}
|
|
1103
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
#[async_trait::async_trait]
|
|
1007
|
+
/// Test helper methods for core workers
|
|
1008
|
+
pub trait WorkerTestHelpers {
|
|
1009
|
+
/// Complete a workflow execution
|
|
1010
|
+
async fn complete_execution(&self, run_id: &str);
|
|
1011
|
+
/// Complete a timer with the given sequence number and duration
|
|
1012
|
+
async fn complete_timer(&self, run_id: &str, seq: u32, duration: Duration);
|
|
1013
|
+
/// Handle workflow eviction from cache
|
|
1014
|
+
async fn handle_eviction(&self);
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
#[async_trait::async_trait]
|
|
1018
|
+
impl<T> WorkerTestHelpers for T
|
|
1019
|
+
where
|
|
1020
|
+
T: WorkerTrait + ?Sized,
|
|
1021
|
+
{
|
|
1022
|
+
async fn complete_execution(&self, run_id: &str) {
|
|
1023
|
+
self.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
1024
|
+
run_id.to_string(),
|
|
1025
|
+
vec![CompleteWorkflowExecution { result: None }.into()],
|
|
1026
|
+
))
|
|
1027
|
+
.await
|
|
1028
|
+
.unwrap();
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
async fn complete_timer(&self, run_id: &str, seq: u32, duration: Duration) {
|
|
1032
|
+
self.complete_workflow_activation(WorkflowActivationCompletion::from_cmds(
|
|
1033
|
+
run_id.to_string(),
|
|
1034
|
+
vec![
|
|
1035
|
+
StartTimer {
|
|
1036
|
+
seq,
|
|
1037
|
+
start_to_fire_timeout: Some(duration.try_into().expect("duration fits")),
|
|
1038
|
+
}
|
|
1039
|
+
.into(),
|
|
1040
|
+
],
|
|
1041
|
+
))
|
|
1042
|
+
.await
|
|
1043
|
+
.unwrap();
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
async fn handle_eviction(&self) {
|
|
1047
|
+
let task = self.poll_workflow_activation().await.unwrap();
|
|
1048
|
+
assert_matches!(
|
|
1049
|
+
task.jobs.as_slice(),
|
|
1050
|
+
[WorkflowActivationJob {
|
|
1051
|
+
variant: Some(workflow_activation_job::Variant::RemoveFromCache(_)),
|
|
1052
|
+
}]
|
|
1053
|
+
);
|
|
1054
|
+
self.complete_workflow_activation(WorkflowActivationCompletion::empty(task.run_id))
|
|
1055
|
+
.await
|
|
1056
|
+
.unwrap();
|
|
1057
|
+
}
|
|
1058
|
+
}
|