@temporalio/core-bridge 1.14.2-canary-release-testing.0 → 1.16.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 +794 -650
- package/bridge-macros/src/derive_tryintojs.rs +40 -0
- package/lib/native.d.ts +24 -3
- package/package.json +4 -4
- 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/.github/workflows/per-pr.yml +6 -6
- package/sdk-core/AGENTS.md +42 -31
- package/sdk-core/Cargo.toml +4 -1
- package/sdk-core/README.md +19 -13
- package/sdk-core/crates/client/Cargo.toml +4 -0
- package/sdk-core/crates/client/README.md +139 -0
- package/sdk-core/crates/client/src/async_activity_handle.rs +297 -0
- package/sdk-core/crates/client/src/callback_based.rs +7 -0
- package/sdk-core/crates/client/src/errors.rs +294 -0
- package/sdk-core/crates/client/src/{raw.rs → grpc.rs} +370 -159
- package/sdk-core/crates/client/src/lib.rs +920 -1326
- package/sdk-core/crates/client/src/metrics.rs +24 -33
- package/sdk-core/crates/client/src/options_structs.rs +457 -0
- package/sdk-core/crates/client/src/replaceable.rs +5 -4
- package/sdk-core/crates/client/src/request_extensions.rs +8 -9
- package/sdk-core/crates/client/src/retry.rs +99 -54
- package/sdk-core/crates/client/src/{worker/mod.rs → worker.rs} +104 -29
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +62 -3
- package/sdk-core/crates/common/build.rs +742 -12
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/ci.yml +2 -0
- package/sdk-core/crates/common/protos/api_upstream/.github/workflows/create-release.yml +0 -5
- package/sdk-core/crates/common/protos/api_upstream/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/README.md +8 -0
- package/sdk-core/crates/common/protos/api_upstream/cmd/check-path-conflicts/main.go +137 -0
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv2.json +3329 -2647
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +2734 -708
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/activity/v1/message.proto +155 -3
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/command/v1/message.proto +26 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/common/v1/message.proto +8 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +27 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/activity.proto +81 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/event_type.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +15 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +63 -15
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/errordetails/v1/message.proto +8 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/failure/v1/message.proto +1 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/history/v1/message.proto +111 -17
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +21 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +20 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/schedule/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/worker/v1/message.proto +4 -7
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflow/v1/message.proto +80 -22
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +347 -23
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +242 -43
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/core_interface.proto +15 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +9 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +8 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +22 -5
- package/sdk-core/crates/common/src/activity_definition.rs +20 -0
- package/sdk-core/crates/common/src/data_converters.rs +770 -0
- package/sdk-core/crates/common/src/envconfig.rs +5 -0
- package/sdk-core/crates/common/src/lib.rs +15 -211
- package/sdk-core/crates/common/src/payload_visitor.rs +648 -0
- package/sdk-core/crates/common/src/priority.rs +110 -0
- package/sdk-core/crates/common/src/protos/canned_histories.rs +19 -0
- package/sdk-core/crates/common/src/protos/history_builder.rs +45 -0
- package/sdk-core/crates/common/src/protos/history_info.rs +2 -0
- package/sdk-core/crates/common/src/protos/mod.rs +134 -27
- package/sdk-core/crates/common/src/protos/task_token.rs +3 -3
- package/sdk-core/crates/common/src/protos/utilities.rs +11 -0
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/log_export.rs +11 -16
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +272 -225
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/otel.rs +8 -13
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_meter.rs +49 -50
- package/sdk-core/crates/{sdk-core → common}/src/telemetry/prometheus_server.rs +2 -3
- package/sdk-core/crates/common/src/telemetry.rs +278 -19
- package/sdk-core/crates/common/src/worker.rs +68 -636
- package/sdk-core/crates/common/src/workflow_definition.rs +60 -0
- package/sdk-core/crates/macros/Cargo.toml +5 -1
- package/sdk-core/crates/macros/src/activities_definitions.rs +585 -0
- package/sdk-core/crates/macros/src/fsm_impl.rs +507 -0
- package/sdk-core/crates/macros/src/lib.rs +138 -512
- package/sdk-core/crates/macros/src/macro_utils.rs +106 -0
- package/sdk-core/crates/macros/src/workflow_definitions.rs +1224 -0
- package/sdk-core/crates/sdk/Cargo.toml +19 -6
- package/sdk-core/crates/sdk/README.md +415 -0
- package/sdk-core/crates/sdk/src/activities.rs +417 -0
- package/sdk-core/crates/sdk/src/interceptors.rs +1 -1
- package/sdk-core/crates/sdk/src/lib.rs +759 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +64 -35
- package/sdk-core/crates/sdk/src/workflow_context.rs +1033 -289
- package/sdk-core/crates/sdk/src/workflow_future.rs +277 -213
- package/sdk-core/crates/sdk/src/workflows.rs +711 -0
- package/sdk-core/crates/sdk-core/Cargo.toml +59 -65
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +45 -54
- package/sdk-core/crates/sdk-core/machine_coverage/ActivityMachine_Coverage.puml +1 -1
- package/sdk-core/crates/sdk-core/src/abstractions.rs +6 -10
- package/sdk-core/crates/sdk-core/src/core_tests/activity_tasks.rs +6 -5
- package/sdk-core/crates/sdk-core/src/core_tests/mod.rs +22 -21
- package/sdk-core/crates/sdk-core/src/core_tests/queries.rs +21 -25
- package/sdk-core/crates/sdk-core/src/core_tests/replay_flag.rs +7 -10
- package/sdk-core/crates/sdk-core/src/core_tests/updates.rs +14 -17
- package/sdk-core/crates/sdk-core/src/core_tests/workers.rs +647 -27
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +46 -41
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +13 -16
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +60 -123
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +411 -32
- package/sdk-core/crates/sdk-core/src/protosext/mod.rs +2 -2
- package/sdk-core/crates/sdk-core/src/replay/mod.rs +14 -5
- package/sdk-core/crates/sdk-core/src/telemetry/metrics.rs +183 -198
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -281
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +35 -16
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- package/sdk-core/crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +1 -0
- package/sdk-core/crates/sdk-core/src/worker/activities/local_activities.rs +11 -14
- package/sdk-core/crates/sdk-core/src/worker/activities.rs +16 -19
- package/sdk-core/crates/sdk-core/src/worker/client/mocks.rs +11 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +104 -86
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +10 -14
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1175 -241
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +150 -23
- package/sdk-core/crates/sdk-core/src/worker/slot_provider.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/fixed_size.rs +2 -2
- package/sdk-core/crates/sdk-core/src/worker/tuner/resource_based.rs +25 -27
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +64 -44
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/patch_state_machine.rs +5 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +21 -22
- package/sdk-core/crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs +28 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +20 -41
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +50 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/run_cache.rs +4 -7
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_extraction.rs +2 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/wft_poller.rs +8 -9
- package/sdk-core/crates/sdk-core/src/worker/workflow/workflow_stream.rs +1 -3
- package/sdk-core/crates/sdk-core/tests/activities_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/basic_pass.rs +54 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.rs +18 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/invalid_self_type_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/missing_context_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/multi_arg_pass.rs +48 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_input_pass.rs +14 -0
- package/sdk-core/crates/sdk-core/tests/activities_trybuild/no_return_type_pass.rs +19 -0
- package/sdk-core/crates/sdk-core/tests/cloud_tests.rs +14 -5
- package/sdk-core/crates/sdk-core/tests/common/activity_functions.rs +55 -0
- package/sdk-core/crates/sdk-core/tests/common/mod.rs +281 -236
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +9 -14
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -66
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +306 -268
- package/sdk-core/crates/sdk-core/tests/integ_tests/async_activity_client_tests.rs +230 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/client_tests.rs +94 -57
- package/sdk-core/crates/sdk-core/tests/integ_tests/data_converter_tests.rs +381 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +37 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +49 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +447 -300
- package/sdk-core/crates/sdk-core/tests/integ_tests/pagination_tests.rs +50 -45
- package/sdk-core/crates/sdk-core/tests/integ_tests/polling_tests.rs +157 -157
- package/sdk-core/crates/sdk-core/tests/integ_tests/queries_tests.rs +103 -89
- package/sdk-core/crates/sdk-core/tests/integ_tests/update_tests.rs +609 -463
- package/sdk-core/crates/sdk-core/tests/integ_tests/visibility_tests.rs +80 -62
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs +389 -265
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +250 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -49
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_client_tests.rs +180 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/activities.rs +437 -327
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -58
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -30
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -251
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/client_interactions.rs +552 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +110 -46
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -149
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -32
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1040
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -43
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +402 -245
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +343 -207
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/queries.rs +415 -0
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/replay.rs +96 -36
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs +155 -140
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -113
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -44
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -48
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +365 -242
- package/sdk-core/crates/sdk-core/tests/main.rs +22 -16
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +233 -187
- package/sdk-core/crates/sdk-core/tests/runner.rs +4 -6
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +73 -27
- package/sdk-core/crates/sdk-core/tests/shared_tests/priority.rs +107 -84
- package/sdk-core/crates/sdk-core/tests/workflows_procmacro.rs +6 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/async_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/basic_pass.rs +49 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/minimal_pass.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.rs +26 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/mut_query_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.rs +21 -0
- package/sdk-core/crates/sdk-core/tests/workflows_trybuild/sync_run_fail.stderr +5 -0
- package/sdk-core/crates/sdk-core-c-bridge/Cargo.toml +8 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +37 -26
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +180 -87
- package/sdk-core/crates/sdk-core-c-bridge/src/lib.rs +89 -5
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +10 -16
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +59 -67
- package/sdk-core/crates/sdk-core-c-bridge/src/testing.rs +10 -10
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +57 -22
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +108 -12
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +9 -52
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +74 -91
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +206 -289
- package/src/helpers/try_into_js.rs +88 -2
- package/src/metrics.rs +277 -35
- package/src/runtime.rs +94 -45
- package/src/testing.rs +9 -16
- package/src/worker.rs +86 -68
- package/ts/native.ts +39 -3
- package/sdk-core/crates/client/src/workflow_handle/mod.rs +0 -212
- package/sdk-core/crates/common/src/errors.rs +0 -85
- package/sdk-core/crates/common/tests/worker_task_types_test.rs +0 -129
- package/sdk-core/crates/macros/LICENSE.txt +0 -21
- package/sdk-core/crates/sdk/src/activity_context.rs +0 -238
- package/sdk-core/crates/sdk/src/app_data.rs +0 -37
- package/sdk-core/crates/sdk-core/tests/integ_tests/activity_functions.rs +0 -5
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
//! Common integration testing utilities
|
|
2
2
|
//! These utilities are specific to integration tests and depend on the full temporal-client stack.
|
|
3
3
|
|
|
4
|
+
pub(crate) mod activity_functions;
|
|
4
5
|
pub(crate) mod fake_grpc_server;
|
|
5
6
|
pub(crate) mod http_proxy;
|
|
6
7
|
pub(crate) mod workflows;
|
|
7
8
|
|
|
8
|
-
use anyhow::
|
|
9
|
+
use anyhow::bail;
|
|
9
10
|
use futures_util::{
|
|
10
11
|
Future, StreamExt, future, stream,
|
|
11
12
|
stream::{Stream, TryStreamExt},
|
|
@@ -28,44 +29,45 @@ use std::{
|
|
|
28
29
|
time::{Duration, Instant},
|
|
29
30
|
};
|
|
30
31
|
use temporalio_client::{
|
|
31
|
-
Client, ClientTlsOptions,
|
|
32
|
-
|
|
33
|
-
WorkflowHandle,
|
|
32
|
+
Client, ClientTlsOptions, Connection, ConnectionOptions, NamespacedClient, TlsOptions,
|
|
33
|
+
UntypedWorkflow, UntypedWorkflowHandle, WorkflowExecutionInfo, WorkflowGetResultOptions,
|
|
34
|
+
WorkflowHandle, WorkflowStartOptions,
|
|
35
|
+
errors::{WorkflowGetResultError, WorkflowStartError},
|
|
36
|
+
grpc::WorkflowService,
|
|
34
37
|
};
|
|
35
38
|
use temporalio_common::{
|
|
36
|
-
|
|
39
|
+
WorkflowDefinition,
|
|
40
|
+
data_converters::{DataConverter, RawValue},
|
|
37
41
|
protos::{
|
|
38
42
|
coresdk::{
|
|
39
|
-
|
|
43
|
+
workflow_activation::WorkflowActivation,
|
|
40
44
|
workflow_completion::WorkflowActivationCompletion,
|
|
41
45
|
},
|
|
42
46
|
temporal::api::{
|
|
43
|
-
common::v1::Payload,
|
|
44
|
-
history::v1::History,
|
|
45
|
-
workflowservice::v1::{GetClusterInfoRequest, StartWorkflowExecutionResponse},
|
|
47
|
+
common::v1::Payload, history::v1::History, workflowservice::v1::GetClusterInfoRequest,
|
|
46
48
|
},
|
|
47
49
|
},
|
|
48
50
|
telemetry::{
|
|
49
|
-
Logger,
|
|
50
|
-
|
|
51
|
-
metrics::CoreMeter,
|
|
51
|
+
Logger, OtelCollectorOptions, PrometheusExporterOptions, TelemetryOptions,
|
|
52
|
+
build_otlp_metric_exporter, metrics::CoreMeter, start_prometheus_metric_exporter,
|
|
52
53
|
},
|
|
53
|
-
worker::{
|
|
54
|
+
worker::{WorkerDeploymentOptions, WorkerDeploymentVersion, WorkerTaskTypes},
|
|
54
55
|
};
|
|
55
56
|
use temporalio_sdk::{
|
|
56
|
-
|
|
57
|
+
Worker, WorkerOptions,
|
|
58
|
+
activities::ActivityImplementer,
|
|
57
59
|
interceptors::{
|
|
58
60
|
FailOnNondeterminismInterceptor, InterceptorWithNext, ReturnWorkflowExitValueInterceptor,
|
|
59
61
|
WorkerInterceptor,
|
|
60
62
|
},
|
|
63
|
+
workflows::{WorkflowImplementation, WorkflowImplementer},
|
|
61
64
|
};
|
|
62
65
|
#[cfg(any(feature = "test-utilities", test))]
|
|
63
66
|
pub(crate) use temporalio_sdk_core::test_help::NAMESPACE;
|
|
64
67
|
use temporalio_sdk_core::{
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
CoreRuntime, RuntimeOptions, Worker as CoreWorker, WorkerConfig, WorkerVersioningStrategy,
|
|
69
|
+
init_replay_worker, init_worker,
|
|
67
70
|
replay::{HistoryForReplay, ReplayWorkerInput},
|
|
68
|
-
telemetry::{build_otlp_metric_exporter, start_prometheus_metric_exporter},
|
|
69
71
|
test_help::{MockPollCfg, build_mock_pollers, mock_worker},
|
|
70
72
|
};
|
|
71
73
|
use tokio::{sync::OnceCell, task::AbortHandle};
|
|
@@ -101,9 +103,13 @@ pub(crate) async fn init_core_and_create_wf(test_name: &str) -> CoreWfStarter {
|
|
|
101
103
|
starter
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
pub(crate) fn
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
pub(crate) fn integ_namespace() -> String {
|
|
107
|
+
env::var(INTEG_NAMESPACE_ENV_VAR).unwrap_or(NAMESPACE.to_string())
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
pub(crate) fn integ_worker_config(tq: &str) -> WorkerConfig {
|
|
111
|
+
WorkerConfig::builder()
|
|
112
|
+
.namespace(integ_namespace())
|
|
107
113
|
.task_queue(tq)
|
|
108
114
|
.max_outstanding_activities(100_usize)
|
|
109
115
|
.max_outstanding_local_activities(100_usize)
|
|
@@ -112,29 +118,40 @@ pub(crate) fn integ_worker_config(tq: &str) -> WorkerConfigBuilder {
|
|
|
112
118
|
build_id: "test_build_id".to_owned(),
|
|
113
119
|
})
|
|
114
120
|
.task_types(WorkerTaskTypes::all())
|
|
115
|
-
.skip_client_worker_set_check(true)
|
|
116
|
-
|
|
121
|
+
.skip_client_worker_set_check(true)
|
|
122
|
+
.build()
|
|
123
|
+
.expect("Configuration options construct properly")
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pub(crate) fn integ_sdk_config(tq: &str) -> WorkerOptions {
|
|
127
|
+
WorkerOptions::new(tq)
|
|
128
|
+
.deployment_options(WorkerDeploymentOptions {
|
|
129
|
+
version: WorkerDeploymentVersion {
|
|
130
|
+
deployment_name: "".to_owned(),
|
|
131
|
+
build_id: "test_build_id".to_owned(),
|
|
132
|
+
},
|
|
133
|
+
use_worker_versioning: false,
|
|
134
|
+
default_versioning_behavior: None,
|
|
135
|
+
})
|
|
136
|
+
.build()
|
|
117
137
|
}
|
|
118
138
|
|
|
119
139
|
/// Create a worker replay instance preloaded with provided histories. Returns the worker impl.
|
|
120
|
-
pub(crate) fn init_core_replay_preloaded<I>(test_name: &str, histories: I) ->
|
|
140
|
+
pub(crate) fn init_core_replay_preloaded<I>(test_name: &str, histories: I) -> CoreWorker
|
|
121
141
|
where
|
|
122
142
|
I: IntoIterator<Item = HistoryForReplay> + 'static,
|
|
123
143
|
<I as IntoIterator>::IntoIter: Send,
|
|
124
144
|
{
|
|
125
145
|
init_core_replay_stream(test_name, stream::iter(histories))
|
|
126
146
|
}
|
|
127
|
-
pub(crate) fn init_core_replay_stream<I>(test_name: &str, histories: I) ->
|
|
147
|
+
pub(crate) fn init_core_replay_stream<I>(test_name: &str, histories: I) -> CoreWorker
|
|
128
148
|
where
|
|
129
149
|
I: Stream<Item = HistoryForReplay> + Send + 'static,
|
|
130
150
|
{
|
|
131
151
|
init_integ_telem();
|
|
132
|
-
let worker_cfg = integ_worker_config(test_name)
|
|
133
|
-
|
|
134
|
-
.expect("
|
|
135
|
-
let worker = init_replay_worker(ReplayWorkerInput::new(worker_cfg, histories))
|
|
136
|
-
.expect("Replay worker must init properly");
|
|
137
|
-
Arc::new(worker)
|
|
152
|
+
let worker_cfg = integ_worker_config(test_name);
|
|
153
|
+
init_replay_worker(ReplayWorkerInput::new(worker_cfg, histories))
|
|
154
|
+
.expect("Replay worker must init properly")
|
|
138
155
|
}
|
|
139
156
|
pub(crate) fn replay_sdk_worker<I>(histories: I) -> Worker
|
|
140
157
|
where
|
|
@@ -148,7 +165,8 @@ where
|
|
|
148
165
|
I: Stream<Item = HistoryForReplay> + Send + 'static,
|
|
149
166
|
{
|
|
150
167
|
let core = init_core_replay_stream("replay_worker_test", histories);
|
|
151
|
-
|
|
168
|
+
// TODO [rust-sdk-branch]: Needs DC passed in
|
|
169
|
+
let mut worker = Worker::new_from_core(Arc::new(core), DataConverter::default());
|
|
152
170
|
worker.set_worker_interceptor(FailOnNondeterminismInterceptor {});
|
|
153
171
|
worker
|
|
154
172
|
}
|
|
@@ -177,7 +195,7 @@ pub(crate) fn init_integ_telem() -> Option<&'static CoreRuntime> {
|
|
|
177
195
|
}
|
|
178
196
|
Some(INTEG_TESTS_RT.get_or_init(|| {
|
|
179
197
|
let telemetry_options = get_integ_telem_options();
|
|
180
|
-
let runtime_options =
|
|
198
|
+
let runtime_options = RuntimeOptions::builder()
|
|
181
199
|
.telemetry_options(telemetry_options)
|
|
182
200
|
.build()
|
|
183
201
|
.expect("Runtime options build cleanly");
|
|
@@ -190,7 +208,7 @@ pub(crate) fn init_integ_telem() -> Option<&'static CoreRuntime> {
|
|
|
190
208
|
}))
|
|
191
209
|
}
|
|
192
210
|
|
|
193
|
-
pub(crate) async fn get_cloud_client() ->
|
|
211
|
+
pub(crate) async fn get_cloud_client() -> Client {
|
|
194
212
|
let cloud_addr = env::var("TEMPORAL_CLOUD_ADDRESS").unwrap();
|
|
195
213
|
let cloud_key = env::var("TEMPORAL_CLIENT_KEY").unwrap();
|
|
196
214
|
|
|
@@ -199,8 +217,7 @@ pub(crate) async fn get_cloud_client() -> RetryClient<Client> {
|
|
|
199
217
|
.replace("\\n", "\n")
|
|
200
218
|
.into_bytes();
|
|
201
219
|
let client_private_key = cloud_key.replace("\\n", "\n").into_bytes();
|
|
202
|
-
let
|
|
203
|
-
.target_url(Url::from_str(&cloud_addr).unwrap())
|
|
220
|
+
let connection_opts = ConnectionOptions::new(Url::from_str(&cloud_addr).unwrap())
|
|
204
221
|
.client_name("sdk-core-integ-tests")
|
|
205
222
|
.client_version("clientver")
|
|
206
223
|
.identity("sdk-test-client")
|
|
@@ -212,29 +229,31 @@ pub(crate) async fn get_cloud_client() -> RetryClient<Client> {
|
|
|
212
229
|
..Default::default()
|
|
213
230
|
})
|
|
214
231
|
.build();
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
)
|
|
219
|
-
.await
|
|
220
|
-
.unwrap()
|
|
232
|
+
let connection = Connection::connect(connection_opts).await.unwrap();
|
|
233
|
+
let namespace = env::var("TEMPORAL_NAMESPACE").expect("TEMPORAL_NAMESPACE must be set");
|
|
234
|
+
let client_opts = temporalio_client::ClientOptions::new(namespace).build();
|
|
235
|
+
Client::new(connection, client_opts).unwrap()
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
/// Implements a builder pattern to help integ tests initialize core and create workflows
|
|
224
239
|
pub(crate) struct CoreWfStarter {
|
|
225
240
|
/// Used for both the task queue and workflow id
|
|
226
241
|
task_queue_name: String,
|
|
227
|
-
pub
|
|
228
|
-
/// Options to use when starting workflow(s)
|
|
229
|
-
|
|
242
|
+
pub sdk_config: WorkerOptions,
|
|
243
|
+
/// Options to use when starting workflow(s). Is initialized with task_queue & workflow_id
|
|
244
|
+
/// to be the same, derived from test name given to `new`.
|
|
245
|
+
pub workflow_options: WorkflowStartOptions,
|
|
230
246
|
initted_worker: OnceCell<InitializedWorker>,
|
|
231
247
|
runtime_override: Option<Arc<CoreRuntime>>,
|
|
232
|
-
client_override: Option<
|
|
248
|
+
client_override: Option<Client>,
|
|
233
249
|
min_local_server_version: Option<String>,
|
|
250
|
+
/// Run when initializing, allows for altering the config used to init the core worker
|
|
251
|
+
#[allow(clippy::type_complexity)] // It's not tho
|
|
252
|
+
core_config_mutator: Option<Arc<dyn Fn(&mut WorkerConfig)>>,
|
|
234
253
|
}
|
|
235
254
|
struct InitializedWorker {
|
|
236
|
-
worker: Arc<
|
|
237
|
-
client:
|
|
255
|
+
worker: Arc<CoreWorker>,
|
|
256
|
+
client: Client,
|
|
238
257
|
}
|
|
239
258
|
|
|
240
259
|
impl CoreWfStarter {
|
|
@@ -263,10 +282,9 @@ impl CoreWfStarter {
|
|
|
263
282
|
let mut s = Self::new_with_overrides(test_name, None, client);
|
|
264
283
|
|
|
265
284
|
if check_mlsv && !version_req.is_empty() {
|
|
266
|
-
let clustinfo =
|
|
285
|
+
let clustinfo = s
|
|
267
286
|
.get_client()
|
|
268
|
-
.
|
|
269
|
-
.workflow_svc()
|
|
287
|
+
.await
|
|
270
288
|
.get_cluster_info(GetClusterInfoRequest::default().into_request())
|
|
271
289
|
.await;
|
|
272
290
|
let srv_ver = semver::Version::parse(
|
|
@@ -294,22 +312,20 @@ impl CoreWfStarter {
|
|
|
294
312
|
pub(crate) fn new_with_overrides(
|
|
295
313
|
test_name: &str,
|
|
296
314
|
runtime_override: Option<CoreRuntime>,
|
|
297
|
-
client_override: Option<
|
|
315
|
+
client_override: Option<Client>,
|
|
298
316
|
) -> Self {
|
|
299
317
|
let task_q_salt = rand_6_chars();
|
|
300
318
|
let task_queue = format!("{test_name}_{task_q_salt}");
|
|
301
|
-
let
|
|
302
|
-
worker_config
|
|
303
|
-
.namespace(env::var(INTEG_NAMESPACE_ENV_VAR).unwrap_or(NAMESPACE.to_string()))
|
|
304
|
-
.max_cached_workflows(1000_usize);
|
|
319
|
+
let sdk_config = integ_sdk_config(&task_queue);
|
|
305
320
|
Self {
|
|
306
|
-
task_queue_name: task_queue,
|
|
307
|
-
|
|
321
|
+
task_queue_name: task_queue.clone(),
|
|
322
|
+
sdk_config,
|
|
308
323
|
initted_worker: OnceCell::new(),
|
|
309
|
-
workflow_options:
|
|
324
|
+
workflow_options: WorkflowStartOptions::new(task_queue.clone(), task_queue).build(),
|
|
310
325
|
runtime_override: runtime_override.map(Arc::new),
|
|
311
|
-
client_override
|
|
326
|
+
client_override,
|
|
312
327
|
min_local_server_version: None,
|
|
328
|
+
core_config_mutator: None,
|
|
313
329
|
}
|
|
314
330
|
}
|
|
315
331
|
|
|
@@ -318,32 +334,44 @@ impl CoreWfStarter {
|
|
|
318
334
|
pub(crate) fn clone_no_worker(&self) -> Self {
|
|
319
335
|
Self {
|
|
320
336
|
task_queue_name: self.task_queue_name.clone(),
|
|
321
|
-
|
|
337
|
+
sdk_config: self.sdk_config.clone(),
|
|
322
338
|
workflow_options: self.workflow_options.clone(),
|
|
323
339
|
runtime_override: self.runtime_override.clone(),
|
|
324
340
|
client_override: self.client_override.clone(),
|
|
325
341
|
min_local_server_version: self.min_local_server_version.clone(),
|
|
326
342
|
initted_worker: Default::default(),
|
|
343
|
+
core_config_mutator: self.core_config_mutator.clone(),
|
|
327
344
|
}
|
|
328
345
|
}
|
|
329
346
|
|
|
330
347
|
pub(crate) async fn worker(&mut self) -> TestWorker {
|
|
331
|
-
let
|
|
332
|
-
let
|
|
333
|
-
|
|
348
|
+
let worker = self.get_worker().await;
|
|
349
|
+
let client = self.get_client().await;
|
|
350
|
+
let sdk = Worker::new_from_core_definitions(
|
|
351
|
+
worker,
|
|
352
|
+
client.data_converter().clone(),
|
|
353
|
+
self.sdk_config.activities(),
|
|
354
|
+
self.sdk_config.workflows(),
|
|
355
|
+
);
|
|
356
|
+
let mut w = TestWorker::new(sdk);
|
|
357
|
+
w.client = Some(client);
|
|
334
358
|
|
|
335
359
|
w
|
|
336
360
|
}
|
|
337
361
|
|
|
362
|
+
pub(crate) fn set_core_cfg_mutator(&mut self, mutator: impl Fn(&mut WorkerConfig) + 'static) {
|
|
363
|
+
self.core_config_mutator = Some(Arc::new(mutator))
|
|
364
|
+
}
|
|
365
|
+
|
|
338
366
|
pub(crate) async fn shutdown(&mut self) {
|
|
339
367
|
self.get_worker().await.shutdown().await;
|
|
340
368
|
}
|
|
341
369
|
|
|
342
|
-
pub(crate) async fn get_worker(&mut self) -> Arc<
|
|
370
|
+
pub(crate) async fn get_worker(&mut self) -> Arc<CoreWorker> {
|
|
343
371
|
self.get_or_init().await.worker.clone()
|
|
344
372
|
}
|
|
345
373
|
|
|
346
|
-
pub(crate) async fn get_client(&mut self) ->
|
|
374
|
+
pub(crate) async fn get_client(&mut self) -> Client {
|
|
347
375
|
self.get_or_init().await.client.clone()
|
|
348
376
|
}
|
|
349
377
|
|
|
@@ -357,38 +385,17 @@ impl CoreWfStarter {
|
|
|
357
385
|
&self,
|
|
358
386
|
wf_name: impl Into<String>,
|
|
359
387
|
worker: &mut TestWorker,
|
|
360
|
-
) ->
|
|
361
|
-
let
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
wf_name.into(),
|
|
365
|
-
vec![],
|
|
366
|
-
self.workflow_options.clone(),
|
|
367
|
-
)
|
|
388
|
+
) -> UntypedWorkflowHandle<Client> {
|
|
389
|
+
let wf_name = wf_name.into();
|
|
390
|
+
worker
|
|
391
|
+
.submit_wf(&wf_name, vec![], self.workflow_options.clone())
|
|
368
392
|
.await
|
|
369
393
|
.unwrap();
|
|
370
394
|
self.initted_worker
|
|
371
395
|
.get()
|
|
372
396
|
.unwrap()
|
|
373
397
|
.client
|
|
374
|
-
.
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
pub(crate) async fn eager_start_with_worker(
|
|
378
|
-
&self,
|
|
379
|
-
wf_name: impl Into<String>,
|
|
380
|
-
worker: &mut TestWorker,
|
|
381
|
-
) -> StartWorkflowExecutionResponse {
|
|
382
|
-
assert!(self.workflow_options.enable_eager_workflow_start);
|
|
383
|
-
worker
|
|
384
|
-
.eager_submit_wf(
|
|
385
|
-
self.task_queue_name.clone(),
|
|
386
|
-
wf_name.into(),
|
|
387
|
-
vec![],
|
|
388
|
-
self.workflow_options.clone(),
|
|
389
|
-
)
|
|
390
|
-
.await
|
|
391
|
-
.unwrap()
|
|
398
|
+
.get_workflow_handle::<UntypedWorkflow>(&self.task_queue_name)
|
|
392
399
|
}
|
|
393
400
|
|
|
394
401
|
pub(crate) async fn start_wf_with_id(&self, workflow_id: String) -> String {
|
|
@@ -396,18 +403,19 @@ impl CoreWfStarter {
|
|
|
396
403
|
"Worker must be initted before starting a workflow.\
|
|
397
404
|
Tests must call `get_worker` first.",
|
|
398
405
|
);
|
|
406
|
+
let mut options = self.workflow_options.clone();
|
|
407
|
+
options.workflow_id = workflow_id;
|
|
399
408
|
iw.client
|
|
400
409
|
.start_workflow(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
self.task_queue_name.clone(),
|
|
405
|
-
None,
|
|
406
|
-
self.workflow_options.clone(),
|
|
410
|
+
UntypedWorkflow::new(&self.task_queue_name),
|
|
411
|
+
RawValue::empty(),
|
|
412
|
+
options,
|
|
407
413
|
)
|
|
408
414
|
.await
|
|
409
415
|
.unwrap()
|
|
410
|
-
.run_id
|
|
416
|
+
.run_id()
|
|
417
|
+
.unwrap()
|
|
418
|
+
.to_string()
|
|
411
419
|
}
|
|
412
420
|
|
|
413
421
|
pub(crate) fn get_task_queue(&self) -> &str {
|
|
@@ -421,26 +429,33 @@ impl CoreWfStarter {
|
|
|
421
429
|
/// Fetch the history of the default workflow for this starter. IE: The one that would
|
|
422
430
|
/// be started by [CoreWfStarter::start_wf].
|
|
423
431
|
pub(crate) async fn get_history(&self) -> History {
|
|
424
|
-
self
|
|
432
|
+
let client = &self
|
|
433
|
+
.initted_worker
|
|
425
434
|
.get()
|
|
426
435
|
.expect("Starter must be initialized")
|
|
427
|
-
.client
|
|
428
|
-
|
|
436
|
+
.client;
|
|
437
|
+
let events = client
|
|
438
|
+
.get_workflow_handle::<UntypedWorkflow>(self.get_wf_id())
|
|
439
|
+
.fetch_history(Default::default())
|
|
429
440
|
.await
|
|
430
441
|
.unwrap()
|
|
431
|
-
.
|
|
432
|
-
|
|
442
|
+
.into_events();
|
|
443
|
+
History { events }
|
|
433
444
|
}
|
|
434
445
|
|
|
435
446
|
pub(crate) async fn wait_for_default_wf_finish(
|
|
436
447
|
&self,
|
|
437
|
-
) -> Result<
|
|
448
|
+
) -> Result<RawValue, WorkflowGetResultError> {
|
|
438
449
|
self.initted_worker
|
|
439
450
|
.get()
|
|
440
451
|
.unwrap()
|
|
441
452
|
.client
|
|
442
|
-
.
|
|
443
|
-
.
|
|
453
|
+
.get_workflow_handle::<UntypedWorkflow>(&self.task_queue_name)
|
|
454
|
+
.get_result(
|
|
455
|
+
WorkflowGetResultOptions::builder()
|
|
456
|
+
.follow_runs(false)
|
|
457
|
+
.build(),
|
|
458
|
+
)
|
|
444
459
|
.await
|
|
445
460
|
}
|
|
446
461
|
|
|
@@ -452,24 +467,29 @@ impl CoreWfStarter {
|
|
|
452
467
|
} else {
|
|
453
468
|
init_integ_telem().unwrap()
|
|
454
469
|
};
|
|
455
|
-
let
|
|
456
|
-
|
|
457
|
-
.
|
|
458
|
-
|
|
459
|
-
let client = if let Some(client) = self.client_override.take() {
|
|
460
|
-
client
|
|
470
|
+
let (connection, client) = if let Some(client) = self.client_override.take() {
|
|
471
|
+
// Extract the connection from the client to pass to init_worker
|
|
472
|
+
let connection = client.connection().clone();
|
|
473
|
+
(connection, client)
|
|
461
474
|
} else {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
)
|
|
475
|
+
// Create connection and client
|
|
476
|
+
let mut opts = get_integ_server_options();
|
|
477
|
+
opts.metrics_meter = rt.telemetry().get_temporal_metric_meter();
|
|
478
|
+
let connection = Connection::connect(opts).await.expect("Must connect");
|
|
479
|
+
let client_opts =
|
|
480
|
+
temporalio_client::ClientOptions::new(integ_namespace()).build();
|
|
481
|
+
let client = Client::new(connection.clone(), client_opts).unwrap();
|
|
482
|
+
(connection, client)
|
|
471
483
|
};
|
|
472
|
-
let
|
|
484
|
+
let mut core_config = self
|
|
485
|
+
.sdk_config
|
|
486
|
+
.to_core_options(client.namespace(), client.identity())
|
|
487
|
+
.expect("sdk config converts to core config");
|
|
488
|
+
if let Some(ref ccm) = self.core_config_mutator {
|
|
489
|
+
ccm(&mut core_config);
|
|
490
|
+
}
|
|
491
|
+
let worker =
|
|
492
|
+
init_worker(rt, core_config, connection).expect("Worker inits cleanly");
|
|
473
493
|
InitializedWorker {
|
|
474
494
|
worker: Arc::new(worker),
|
|
475
495
|
client,
|
|
@@ -482,8 +502,7 @@ impl CoreWfStarter {
|
|
|
482
502
|
/// Provides conveniences for running integ tests with the SDK (against real server or mocks)
|
|
483
503
|
pub(crate) struct TestWorker {
|
|
484
504
|
inner: Worker,
|
|
485
|
-
|
|
486
|
-
client: Option<Arc<RetryClient<Client>>>,
|
|
505
|
+
client: Option<Client>,
|
|
487
506
|
pub started_workflows: Arc<Mutex<Vec<WorkflowExecutionInfo>>>,
|
|
488
507
|
/// If set true (default), and a client is available, we will fetch workflow results to
|
|
489
508
|
/// determine when they have all completed.
|
|
@@ -491,14 +510,9 @@ pub(crate) struct TestWorker {
|
|
|
491
510
|
}
|
|
492
511
|
impl TestWorker {
|
|
493
512
|
/// Create a new test worker
|
|
494
|
-
pub(crate) fn new(
|
|
495
|
-
let inner = Worker::new_from_core(
|
|
496
|
-
core_worker.clone(),
|
|
497
|
-
core_worker.get_config().task_queue.clone(),
|
|
498
|
-
);
|
|
513
|
+
pub(crate) fn new(sdk: Worker) -> Self {
|
|
499
514
|
Self {
|
|
500
|
-
inner,
|
|
501
|
-
core_worker,
|
|
515
|
+
inner: sdk,
|
|
502
516
|
client: None,
|
|
503
517
|
started_workflows: Arc::new(Mutex::new(vec![])),
|
|
504
518
|
fetch_results: true,
|
|
@@ -510,24 +524,31 @@ impl TestWorker {
|
|
|
510
524
|
}
|
|
511
525
|
|
|
512
526
|
pub(crate) fn worker_instance_key(&self) -> Uuid {
|
|
513
|
-
self.
|
|
527
|
+
self.inner.worker_instance_key()
|
|
514
528
|
}
|
|
515
529
|
|
|
516
|
-
|
|
517
|
-
pub(crate) fn register_wf<F: Into<WorkflowFunction>>(
|
|
530
|
+
pub(crate) fn register_activities<AI: ActivityImplementer>(
|
|
518
531
|
&mut self,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
self
|
|
532
|
+
instance: AI,
|
|
533
|
+
) -> &mut Self {
|
|
534
|
+
self.inner.register_activities::<AI>(instance);
|
|
535
|
+
self
|
|
523
536
|
}
|
|
524
537
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
538
|
+
#[allow(unused)]
|
|
539
|
+
pub(crate) fn register_workflow<WI: WorkflowImplementer>(&mut self) -> &mut Self {
|
|
540
|
+
self.inner.register_workflow::<WI>();
|
|
541
|
+
self
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
pub(crate) fn register_workflow_with_factory<W, F>(&mut self, factory: F) -> &mut Self
|
|
545
|
+
where
|
|
546
|
+
W: WorkflowImplementation,
|
|
547
|
+
<W::Run as WorkflowDefinition>::Input: Send,
|
|
548
|
+
F: Fn() -> W + Send + Sync + 'static,
|
|
549
|
+
{
|
|
550
|
+
self.inner.register_workflow_with_factory::<W, F>(factory);
|
|
551
|
+
self
|
|
531
552
|
}
|
|
532
553
|
|
|
533
554
|
/// Create a handle that can be used to submit workflows. Useful when workflows need to be
|
|
@@ -535,7 +556,6 @@ impl TestWorker {
|
|
|
535
556
|
pub(crate) fn get_submitter_handle(&self) -> TestWorkerSubmitterHandle {
|
|
536
557
|
TestWorkerSubmitterHandle {
|
|
537
558
|
client: self.client.clone().expect("client must be set"),
|
|
538
|
-
tq: self.inner.task_queue().to_string(),
|
|
539
559
|
started_workflows: self.started_workflows.clone(),
|
|
540
560
|
}
|
|
541
561
|
}
|
|
@@ -548,10 +568,9 @@ impl TestWorker {
|
|
|
548
568
|
/// Returns the run id of the started workflow (if no client has initialized returns a fake id)
|
|
549
569
|
pub(crate) async fn submit_wf(
|
|
550
570
|
&self,
|
|
551
|
-
workflow_id: impl Into<String>,
|
|
552
571
|
workflow_type: impl Into<String>,
|
|
553
572
|
input: Vec<Payload>,
|
|
554
|
-
mut options:
|
|
573
|
+
mut options: WorkflowStartOptions,
|
|
555
574
|
) -> Result<String, anyhow::Error> {
|
|
556
575
|
if self.client.is_none() {
|
|
557
576
|
return Ok("fake_run_id".to_string());
|
|
@@ -562,41 +581,34 @@ impl TestWorker {
|
|
|
562
581
|
options.execution_timeout = Some(Duration::from_secs(60 * 5));
|
|
563
582
|
}
|
|
564
583
|
self.get_submitter_handle()
|
|
565
|
-
.submit_wf(
|
|
584
|
+
.submit_wf(workflow_type, input, options)
|
|
566
585
|
.await
|
|
567
586
|
}
|
|
568
587
|
|
|
569
|
-
///
|
|
570
|
-
|
|
571
|
-
/// Note that this does not guarantee that the worker will execute this task eagerly.
|
|
572
|
-
pub(crate) async fn eager_submit_wf(
|
|
588
|
+
/// Start a workflow returning a handle to the started workflow.
|
|
589
|
+
pub(crate) async fn submit_workflow<W>(
|
|
573
590
|
&self,
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
options,
|
|
589
|
-
)
|
|
590
|
-
.await?;
|
|
591
|
-
res.eager_workflow_task
|
|
592
|
-
.as_ref()
|
|
593
|
-
.context("no eager workflow task")?;
|
|
591
|
+
workflow: W,
|
|
592
|
+
input: W::Input,
|
|
593
|
+
mut options: WorkflowStartOptions,
|
|
594
|
+
) -> Result<WorkflowHandle<Client, W>, WorkflowStartError>
|
|
595
|
+
where
|
|
596
|
+
W: WorkflowDefinition,
|
|
597
|
+
W::Input: Send,
|
|
598
|
+
{
|
|
599
|
+
let c = self.client.as_ref().expect("client must be set");
|
|
600
|
+
if options.execution_timeout.is_none() {
|
|
601
|
+
options.execution_timeout = Some(Duration::from_secs(60 * 5));
|
|
602
|
+
}
|
|
603
|
+
let wfid = options.workflow_id.clone();
|
|
604
|
+
let handle = c.start_workflow(workflow, input, options).await?;
|
|
594
605
|
self.started_workflows.lock().push(WorkflowExecutionInfo {
|
|
595
|
-
namespace: c.namespace()
|
|
606
|
+
namespace: c.namespace(),
|
|
596
607
|
workflow_id: wfid,
|
|
597
|
-
run_id:
|
|
608
|
+
run_id: handle.info().run_id.clone(),
|
|
609
|
+
first_execution_run_id: None,
|
|
598
610
|
});
|
|
599
|
-
Ok(
|
|
611
|
+
Ok(handle)
|
|
600
612
|
}
|
|
601
613
|
|
|
602
614
|
pub(crate) fn expect_workflow_completion(
|
|
@@ -612,6 +624,7 @@ impl TestWorker {
|
|
|
612
624
|
.unwrap_or(NAMESPACE.to_owned()),
|
|
613
625
|
workflow_id: wf_id.into(),
|
|
614
626
|
run_id,
|
|
627
|
+
first_execution_run_id: None,
|
|
615
628
|
});
|
|
616
629
|
}
|
|
617
630
|
|
|
@@ -645,11 +658,14 @@ impl TestWorker {
|
|
|
645
658
|
tokio::try_join!(self.inner.run(), get_results_waiter)?;
|
|
646
659
|
Ok(())
|
|
647
660
|
}
|
|
661
|
+
|
|
662
|
+
pub(crate) fn core_worker(&self) -> Arc<temporalio_sdk_core::Worker> {
|
|
663
|
+
self.inner.core_worker()
|
|
664
|
+
}
|
|
648
665
|
}
|
|
649
666
|
|
|
650
667
|
pub(crate) struct TestWorkerSubmitterHandle {
|
|
651
|
-
client:
|
|
652
|
-
tq: String,
|
|
668
|
+
client: Client,
|
|
653
669
|
started_workflows: Arc<Mutex<Vec<WorkflowExecutionInfo>>>,
|
|
654
670
|
}
|
|
655
671
|
impl TestWorkerSubmitterHandle {
|
|
@@ -661,34 +677,32 @@ impl TestWorkerSubmitterHandle {
|
|
|
661
677
|
/// Returns the run id of the started workflow
|
|
662
678
|
pub(crate) async fn submit_wf(
|
|
663
679
|
&self,
|
|
664
|
-
workflow_id: impl Into<String>,
|
|
665
680
|
workflow_type: impl Into<String>,
|
|
666
681
|
input: Vec<Payload>,
|
|
667
|
-
options:
|
|
682
|
+
options: WorkflowStartOptions,
|
|
668
683
|
) -> Result<String, anyhow::Error> {
|
|
669
|
-
let wfid = workflow_id.
|
|
670
|
-
let
|
|
684
|
+
let wfid = options.workflow_id.clone();
|
|
685
|
+
let handle = self
|
|
671
686
|
.client
|
|
672
687
|
.start_workflow(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
wfid.clone(),
|
|
676
|
-
workflow_type.into(),
|
|
677
|
-
None,
|
|
688
|
+
UntypedWorkflow::new(workflow_type.into()),
|
|
689
|
+
RawValue::new(input),
|
|
678
690
|
options,
|
|
679
691
|
)
|
|
680
692
|
.await?;
|
|
693
|
+
let run_id = handle.run_id().unwrap().to_string();
|
|
681
694
|
self.started_workflows.lock().push(WorkflowExecutionInfo {
|
|
682
|
-
namespace: self.client.namespace()
|
|
695
|
+
namespace: self.client.namespace(),
|
|
683
696
|
workflow_id: wfid,
|
|
684
|
-
run_id: Some(
|
|
697
|
+
run_id: Some(run_id.clone()),
|
|
698
|
+
first_execution_run_id: None,
|
|
685
699
|
});
|
|
686
|
-
Ok(
|
|
700
|
+
Ok(run_id)
|
|
687
701
|
}
|
|
688
702
|
}
|
|
689
703
|
|
|
690
704
|
pub(crate) enum TestWorkerShutdownCond {
|
|
691
|
-
GetResults(Vec<WorkflowExecutionInfo>,
|
|
705
|
+
GetResults(Vec<WorkflowExecutionInfo>, Client),
|
|
692
706
|
NoAutoShutdown,
|
|
693
707
|
}
|
|
694
708
|
/// Implements calling the shutdown handle when the expected number of test workflows has completed
|
|
@@ -710,7 +724,7 @@ impl TestWorkerCompletionIceptor {
|
|
|
710
724
|
if let TestWorkerShutdownCond::GetResults(ref mut wfs, ref client) = self.condition {
|
|
711
725
|
let wfs = std::mem::take(wfs);
|
|
712
726
|
let shutdown_h = self.shutdown_handle.clone();
|
|
713
|
-
let client =
|
|
727
|
+
let client = client.clone();
|
|
714
728
|
let stream = stream::iter(
|
|
715
729
|
wfs.into_iter()
|
|
716
730
|
.map(move |info| info.bind_untyped(client.clone())),
|
|
@@ -719,7 +733,11 @@ impl TestWorkerCompletionIceptor {
|
|
|
719
733
|
future::Either::Left(async move {
|
|
720
734
|
stream
|
|
721
735
|
.try_for_each_concurrent(None, |wh| async move {
|
|
722
|
-
wh.
|
|
736
|
+
if let Err(e) = wh.get_result(Default::default()).await
|
|
737
|
+
&& !e.is_workflow_outcome()
|
|
738
|
+
{
|
|
739
|
+
return Err(e.into());
|
|
740
|
+
}
|
|
723
741
|
Ok::<_, anyhow::Error>(())
|
|
724
742
|
})
|
|
725
743
|
.await?;
|
|
@@ -755,8 +773,8 @@ impl WorkerInterceptor for TestWorkerCompletionIceptor {
|
|
|
755
773
|
}
|
|
756
774
|
}
|
|
757
775
|
|
|
758
|
-
/// Returns the
|
|
759
|
-
pub(crate) fn get_integ_server_options() ->
|
|
776
|
+
/// Returns the connection options used to connect to the server used for integration tests.
|
|
777
|
+
pub(crate) fn get_integ_server_options() -> ConnectionOptions {
|
|
760
778
|
let temporal_server_address = env::var(INTEG_SERVER_TARGET_ENV_VAR)
|
|
761
779
|
.unwrap_or_else(|_| "http://localhost:7233".to_owned());
|
|
762
780
|
let url = Url::try_from(&*temporal_server_address).unwrap();
|
|
@@ -765,9 +783,8 @@ pub(crate) fn get_integ_server_options() -> ClientOptions {
|
|
|
765
783
|
.map(|key_file| std::fs::read_to_string(key_file).unwrap());
|
|
766
784
|
let tls_cfg = get_integ_tls_config();
|
|
767
785
|
|
|
768
|
-
|
|
786
|
+
ConnectionOptions::new(url)
|
|
769
787
|
.identity(INTEG_CLIENT_IDENTITY.to_string())
|
|
770
|
-
.target_url(url)
|
|
771
788
|
.client_name(INTEG_CLIENT_NAME.to_string())
|
|
772
789
|
.client_version(INTEG_CLIENT_VERSION.to_string())
|
|
773
790
|
.maybe_api_key(api_key)
|
|
@@ -775,6 +792,25 @@ pub(crate) fn get_integ_server_options() -> ClientOptions {
|
|
|
775
792
|
.build()
|
|
776
793
|
}
|
|
777
794
|
|
|
795
|
+
/// Helper to create a connection using the default integ test options
|
|
796
|
+
pub(crate) async fn get_integ_connection(
|
|
797
|
+
meter: Option<temporalio_common::telemetry::metrics::TemporalMeter>,
|
|
798
|
+
) -> Connection {
|
|
799
|
+
let mut opts = get_integ_server_options();
|
|
800
|
+
opts.metrics_meter = meter;
|
|
801
|
+
Connection::connect(opts).await.expect("Must connect")
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/// Helper to create a namespaced client using the default integ test options
|
|
805
|
+
pub(crate) async fn get_integ_client(
|
|
806
|
+
namespace: String,
|
|
807
|
+
meter: Option<temporalio_common::telemetry::metrics::TemporalMeter>,
|
|
808
|
+
) -> Client {
|
|
809
|
+
let connection = get_integ_connection(meter).await;
|
|
810
|
+
let client_opts = temporalio_client::ClientOptions::new(namespace).build();
|
|
811
|
+
Client::new(connection, client_opts).unwrap()
|
|
812
|
+
}
|
|
813
|
+
|
|
778
814
|
pub(crate) fn get_integ_tls_config() -> Option<TlsOptions> {
|
|
779
815
|
if env::var(INTEG_USE_TLS_ENV_VAR).is_ok() {
|
|
780
816
|
let root = std::fs::read("../.cloud_certs/ca.pem").unwrap();
|
|
@@ -794,41 +830,47 @@ pub(crate) fn get_integ_tls_config() -> Option<TlsOptions> {
|
|
|
794
830
|
}
|
|
795
831
|
|
|
796
832
|
pub(crate) fn get_integ_telem_options() -> TelemetryOptions {
|
|
797
|
-
let mut ob = TelemetryOptionsBuilder::default();
|
|
798
833
|
let filter_string =
|
|
799
834
|
env::var("RUST_LOG").unwrap_or_else(|_| "INFO,temporalio_sdk_core=INFO".to_string());
|
|
835
|
+
|
|
800
836
|
if let Some(url) = env::var(OTEL_URL_ENV_VAR)
|
|
801
837
|
.ok()
|
|
802
838
|
.map(|x| x.parse::<Url>().unwrap())
|
|
803
839
|
{
|
|
804
|
-
let opts =
|
|
805
|
-
|
|
840
|
+
let opts = OtelCollectorOptions::builder().url(url).build();
|
|
841
|
+
TelemetryOptions::builder()
|
|
842
|
+
.metrics(Arc::new(build_otlp_metric_exporter(opts).unwrap()) as Arc<dyn CoreMeter>)
|
|
843
|
+
.logging(Logger::Console {
|
|
844
|
+
filter: filter_string,
|
|
845
|
+
})
|
|
806
846
|
.build()
|
|
807
|
-
|
|
808
|
-
ob.metrics(Arc::new(build_otlp_metric_exporter(opts).unwrap()) as Arc<dyn CoreMeter>);
|
|
809
|
-
}
|
|
810
|
-
if let Some(addr) = env::var(PROM_ENABLE_ENV_VAR)
|
|
847
|
+
} else if let Some(addr) = env::var(PROM_ENABLE_ENV_VAR)
|
|
811
848
|
.ok()
|
|
812
849
|
.map(|x| SocketAddr::new([127, 0, 0, 1].into(), x.parse().unwrap()))
|
|
813
850
|
{
|
|
814
851
|
let prom_info = start_prometheus_metric_exporter(
|
|
815
|
-
|
|
852
|
+
PrometheusExporterOptions::builder()
|
|
816
853
|
.socket_addr(addr)
|
|
817
|
-
.build()
|
|
818
|
-
.unwrap(),
|
|
854
|
+
.build(),
|
|
819
855
|
)
|
|
820
856
|
.unwrap();
|
|
821
|
-
|
|
857
|
+
TelemetryOptions::builder()
|
|
858
|
+
.metrics(prom_info.meter as Arc<dyn CoreMeter>)
|
|
859
|
+
.logging(Logger::Console {
|
|
860
|
+
filter: filter_string,
|
|
861
|
+
})
|
|
862
|
+
.build()
|
|
863
|
+
} else {
|
|
864
|
+
TelemetryOptions::builder()
|
|
865
|
+
.logging(Logger::Console {
|
|
866
|
+
filter: filter_string,
|
|
867
|
+
})
|
|
868
|
+
.build()
|
|
822
869
|
}
|
|
823
|
-
ob.logging(Logger::Console {
|
|
824
|
-
filter: filter_string,
|
|
825
|
-
})
|
|
826
|
-
.build()
|
|
827
|
-
.unwrap()
|
|
828
870
|
}
|
|
829
871
|
|
|
830
872
|
pub(crate) fn get_integ_runtime_options(telemopts: TelemetryOptions) -> RuntimeOptions {
|
|
831
|
-
|
|
873
|
+
RuntimeOptions::builder()
|
|
832
874
|
.telemetry_options(telemopts)
|
|
833
875
|
.build()
|
|
834
876
|
.unwrap()
|
|
@@ -843,27 +885,21 @@ pub(crate) trait WorkflowHandleExt {
|
|
|
843
885
|
}
|
|
844
886
|
|
|
845
887
|
#[async_trait::async_trait(?Send)]
|
|
846
|
-
impl<
|
|
888
|
+
impl<W> WorkflowHandleExt for WorkflowHandle<Client, W>
|
|
847
889
|
where
|
|
848
|
-
|
|
890
|
+
W: WorkflowDefinition,
|
|
849
891
|
{
|
|
850
892
|
async fn fetch_history_and_replay(
|
|
851
893
|
&self,
|
|
852
894
|
worker: &mut Worker,
|
|
853
895
|
) -> Result<Option<Payload>, anyhow::Error> {
|
|
854
896
|
let wf_id = self.info().workflow_id.clone();
|
|
855
|
-
let
|
|
856
|
-
let
|
|
857
|
-
.client()
|
|
858
|
-
.get_workflow_execution_history(wf_id.clone(), run_id, vec![])
|
|
859
|
-
.await?
|
|
860
|
-
.history
|
|
861
|
-
.expect("history field must be populated");
|
|
862
|
-
let with_id = HistoryForReplay::new(history, wf_id);
|
|
897
|
+
let events = self.fetch_history(Default::default()).await?.into_events();
|
|
898
|
+
let with_id = HistoryForReplay::new(events, wf_id);
|
|
863
899
|
let replay_worker = init_core_replay_preloaded(worker.task_queue(), [with_id]);
|
|
864
|
-
worker.with_new_core_worker(replay_worker);
|
|
900
|
+
worker.with_new_core_worker(Arc::new(replay_worker));
|
|
865
901
|
let retval_icept = ReturnWorkflowExitValueInterceptor::default();
|
|
866
|
-
let retval_handle = retval_icept.
|
|
902
|
+
let retval_handle = retval_icept.result_handle();
|
|
867
903
|
let mut top_icept = InterceptorWithNext::new(Box::new(FailOnNondeterminismInterceptor {}));
|
|
868
904
|
top_icept.set_next(Box::new(retval_icept));
|
|
869
905
|
worker.set_worker_interceptor(top_icept);
|
|
@@ -886,10 +922,9 @@ pub(crate) fn prom_metrics(
|
|
|
886
922
|
options_override: Option<PrometheusExporterOptions>,
|
|
887
923
|
) -> (TelemetryOptions, SocketAddr, AbortOnDrop) {
|
|
888
924
|
let prom_exp_opts = options_override.unwrap_or_else(|| {
|
|
889
|
-
|
|
925
|
+
PrometheusExporterOptions::builder()
|
|
890
926
|
.socket_addr(ANY_PORT.parse().unwrap())
|
|
891
927
|
.build()
|
|
892
|
-
.unwrap()
|
|
893
928
|
});
|
|
894
929
|
let mut telemopts = get_integ_telem_options();
|
|
895
930
|
let prom_info = start_prometheus_metric_exporter(prom_exp_opts).unwrap();
|
|
@@ -913,9 +948,12 @@ impl Drop for AbortOnDrop {
|
|
|
913
948
|
}
|
|
914
949
|
}
|
|
915
950
|
|
|
916
|
-
pub(crate) async fn eventually<F, Fut, T, E>(
|
|
951
|
+
pub(crate) async fn eventually<F, Fut, T, E>(
|
|
952
|
+
mut func: F,
|
|
953
|
+
timeout: Duration,
|
|
954
|
+
) -> Result<T, anyhow::Error>
|
|
917
955
|
where
|
|
918
|
-
F:
|
|
956
|
+
F: FnMut() -> Fut,
|
|
919
957
|
Fut: Future<Output = Result<T, E>>,
|
|
920
958
|
{
|
|
921
959
|
let start = Instant::now();
|
|
@@ -937,7 +975,8 @@ pub(crate) fn build_fake_sdk(mock_cfg: MockPollCfg) -> temporalio_sdk::Worker {
|
|
|
937
975
|
c.ignore_evicts_on_shutdown = false;
|
|
938
976
|
});
|
|
939
977
|
let core = mock_worker(mock);
|
|
940
|
-
let mut worker =
|
|
978
|
+
let mut worker =
|
|
979
|
+
temporalio_sdk::Worker::new_from_core(Arc::new(core), DataConverter::default());
|
|
941
980
|
worker.set_worker_interceptor(FailOnNondeterminismInterceptor {});
|
|
942
981
|
worker
|
|
943
982
|
}
|
|
@@ -954,7 +993,10 @@ pub(crate) fn mock_sdk_cfg(
|
|
|
954
993
|
let mut mock = build_mock_pollers(poll_cfg);
|
|
955
994
|
mock.worker_cfg(mutator);
|
|
956
995
|
let core = mock_worker(mock);
|
|
957
|
-
TestWorker::new(
|
|
996
|
+
TestWorker::new(temporalio_sdk::Worker::new_from_core(
|
|
997
|
+
Arc::new(core),
|
|
998
|
+
DataConverter::default(),
|
|
999
|
+
))
|
|
958
1000
|
}
|
|
959
1001
|
|
|
960
1002
|
#[derive(Default)]
|
|
@@ -998,13 +1040,14 @@ impl Drop for ActivationAssertionsInterceptor {
|
|
|
998
1040
|
|
|
999
1041
|
#[cfg(feature = "ephemeral-server")]
|
|
1000
1042
|
use temporalio_sdk_core::ephemeral_server::{
|
|
1001
|
-
EphemeralExe, EphemeralExeVersion,
|
|
1043
|
+
EphemeralExe, EphemeralExeVersion, TemporalDevServerConfig, default_cached_download,
|
|
1002
1044
|
};
|
|
1003
1045
|
|
|
1004
1046
|
#[cfg(feature = "ephemeral-server")]
|
|
1005
1047
|
pub(crate) fn integ_dev_server_config(
|
|
1006
1048
|
mut extra_args: Vec<String>,
|
|
1007
|
-
|
|
1049
|
+
ui: bool,
|
|
1050
|
+
) -> TemporalDevServerConfig {
|
|
1008
1051
|
let cli_version = if let Ok(ver_override) = env::var(CLI_VERSION_OVERRIDE_ENV_VAR) {
|
|
1009
1052
|
EphemeralExe::CachedDownload {
|
|
1010
1053
|
version: EphemeralExeVersion::Fixed(ver_override.to_owned()),
|
|
@@ -1041,7 +1084,9 @@ pub(crate) fn integ_dev_server_config(
|
|
|
1041
1084
|
.map(Into::into),
|
|
1042
1085
|
);
|
|
1043
1086
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1087
|
+
TemporalDevServerConfig::builder()
|
|
1088
|
+
.exe(cli_version)
|
|
1089
|
+
.extra_args(extra_args)
|
|
1090
|
+
.ui(ui)
|
|
1091
|
+
.build()
|
|
1047
1092
|
}
|