@temporalio/core-bridge 1.15.0 → 1.16.1
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 +172 -70
- package/lib/native.d.ts +1 -1
- package/package.json +2 -2
- 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 +41 -30
- package/sdk-core/Cargo.toml +3 -0
- package/sdk-core/README.md +15 -9
- 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} +280 -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} +1 -1
- package/sdk-core/crates/client/src/workflow_handle.rs +826 -0
- package/sdk-core/crates/common/Cargo.toml +61 -2
- 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/Makefile +2 -1
- package/sdk-core/crates/common/protos/api_upstream/buf.yaml +0 -3
- 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 +1166 -770
- package/sdk-core/crates/common/protos/api_upstream/openapi/openapiv3.yaml +1243 -750
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/deployment/v1/message.proto +2 -2
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/enums/v1/workflow.proto +4 -3
- 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 +4 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/nexus/v1/message.proto +16 -1
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +64 -6
- package/sdk-core/crates/common/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +88 -33
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/nexus/nexus.proto +4 -2
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -0
- package/sdk-core/crates/common/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +5 -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 +3 -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 +122 -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 +5 -7
- package/sdk-core/crates/common/src/telemetry/metrics/core.rs +125 -0
- package/sdk-core/crates/common/src/telemetry/metrics.rs +268 -223
- 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 +264 -4
- package/sdk-core/crates/common/src/worker.rs +68 -603
- 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 +757 -442
- package/sdk-core/crates/sdk/src/workflow_context/options.rs +45 -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 +57 -64
- package/sdk-core/crates/sdk-core/benches/workflow_replay_bench.rs +41 -35
- 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 +13 -15
- 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 +493 -26
- package/sdk-core/crates/sdk-core/src/core_tests/workflow_tasks.rs +4 -8
- package/sdk-core/crates/sdk-core/src/ephemeral_server/mod.rs +7 -7
- package/sdk-core/crates/sdk-core/src/histfetch.rs +20 -10
- package/sdk-core/crates/sdk-core/src/lib.rs +41 -111
- package/sdk-core/crates/sdk-core/src/pollers/mod.rs +4 -9
- package/sdk-core/crates/sdk-core/src/pollers/poll_buffer.rs +118 -19
- 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 +179 -196
- package/sdk-core/crates/sdk-core/src/telemetry/mod.rs +3 -280
- package/sdk-core/crates/sdk-core/src/test_help/integ_helpers.rs +6 -9
- package/sdk-core/crates/sdk-core/src/test_help/unit_helpers.rs +3 -6
- 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 +9 -5
- package/sdk-core/crates/sdk-core/src/worker/client.rs +103 -81
- package/sdk-core/crates/sdk-core/src/worker/heartbeat.rs +7 -11
- package/sdk-core/crates/sdk-core/src/worker/mod.rs +1124 -229
- package/sdk-core/crates/sdk-core/src/worker/nexus.rs +145 -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 +13 -13
- package/sdk-core/crates/sdk-core/src/worker/tuner.rs +28 -8
- package/sdk-core/crates/sdk-core/src/worker/workflow/driven_workflow.rs +9 -3
- 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 +19 -4
- package/sdk-core/crates/sdk-core/src/worker/workflow/managed_run.rs +14 -18
- package/sdk-core/crates/sdk-core/src/worker/workflow/mod.rs +4 -6
- 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 +241 -196
- package/sdk-core/crates/sdk-core/tests/common/workflows.rs +41 -28
- package/sdk-core/crates/sdk-core/tests/global_metric_tests.rs +3 -5
- package/sdk-core/crates/sdk-core/tests/heavy_tests/fuzzy_workflow.rs +73 -64
- package/sdk-core/crates/sdk-core/tests/heavy_tests.rs +298 -252
- 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 +16 -12
- package/sdk-core/crates/sdk-core/tests/integ_tests/heartbeat_tests.rs +48 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/metrics_tests.rs +327 -255
- 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 +147 -126
- 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 -453
- 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 +360 -231
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_tests.rs +248 -185
- package/sdk-core/crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs +52 -43
- 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 +428 -315
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +82 -56
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +56 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +364 -243
- 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 +101 -42
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +243 -147
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs +98 -28
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1475 -1036
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +73 -41
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +397 -238
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs +414 -189
- 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 +154 -137
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs +183 -105
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +85 -38
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs +142 -40
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +73 -54
- package/sdk-core/crates/sdk-core/tests/integ_tests/workflow_tests.rs +363 -226
- package/sdk-core/crates/sdk-core/tests/main.rs +17 -15
- package/sdk-core/crates/sdk-core/tests/manual_tests.rs +207 -152
- package/sdk-core/crates/sdk-core/tests/shared_tests/mod.rs +65 -34
- 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 +7 -1
- package/sdk-core/crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h +14 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/client.rs +83 -74
- package/sdk-core/crates/sdk-core-c-bridge/src/metric.rs +9 -14
- package/sdk-core/crates/sdk-core-c-bridge/src/runtime.rs +1 -2
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/context.rs +13 -13
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/mod.rs +6 -6
- package/sdk-core/crates/sdk-core-c-bridge/src/tests/utils.rs +3 -4
- package/sdk-core/crates/sdk-core-c-bridge/src/worker.rs +62 -75
- package/sdk-core/rustfmt.toml +2 -1
- package/src/client.rs +205 -318
- package/src/metrics.rs +22 -30
- package/src/runtime.rs +4 -5
- package/src/worker.rs +16 -19
- package/ts/native.ts +1 -1
- 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/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,42 +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
51
|
Logger, OtelCollectorOptions, PrometheusExporterOptions, TelemetryOptions,
|
|
50
|
-
metrics::CoreMeter,
|
|
52
|
+
build_otlp_metric_exporter, metrics::CoreMeter, start_prometheus_metric_exporter,
|
|
51
53
|
},
|
|
52
|
-
worker::{
|
|
54
|
+
worker::{WorkerDeploymentOptions, WorkerDeploymentVersion, WorkerTaskTypes},
|
|
53
55
|
};
|
|
54
56
|
use temporalio_sdk::{
|
|
55
|
-
|
|
57
|
+
Worker, WorkerOptions,
|
|
58
|
+
activities::ActivityImplementer,
|
|
56
59
|
interceptors::{
|
|
57
60
|
FailOnNondeterminismInterceptor, InterceptorWithNext, ReturnWorkflowExitValueInterceptor,
|
|
58
61
|
WorkerInterceptor,
|
|
59
62
|
},
|
|
63
|
+
workflows::{WorkflowImplementation, WorkflowImplementer},
|
|
60
64
|
};
|
|
61
65
|
#[cfg(any(feature = "test-utilities", test))]
|
|
62
66
|
pub(crate) use temporalio_sdk_core::test_help::NAMESPACE;
|
|
63
67
|
use temporalio_sdk_core::{
|
|
64
|
-
|
|
68
|
+
CoreRuntime, RuntimeOptions, Worker as CoreWorker, WorkerConfig, WorkerVersioningStrategy,
|
|
69
|
+
init_replay_worker, init_worker,
|
|
65
70
|
replay::{HistoryForReplay, ReplayWorkerInput},
|
|
66
|
-
telemetry::{build_otlp_metric_exporter, start_prometheus_metric_exporter},
|
|
67
71
|
test_help::{MockPollCfg, build_mock_pollers, mock_worker},
|
|
68
72
|
};
|
|
69
73
|
use tokio::{sync::OnceCell, task::AbortHandle};
|
|
@@ -99,9 +103,13 @@ pub(crate) async fn init_core_and_create_wf(test_name: &str) -> CoreWfStarter {
|
|
|
99
103
|
starter
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
pub(crate) fn integ_namespace() -> String {
|
|
107
|
+
env::var(INTEG_NAMESPACE_ENV_VAR).unwrap_or(NAMESPACE.to_string())
|
|
108
|
+
}
|
|
109
|
+
|
|
102
110
|
pub(crate) fn integ_worker_config(tq: &str) -> WorkerConfig {
|
|
103
111
|
WorkerConfig::builder()
|
|
104
|
-
.namespace(
|
|
112
|
+
.namespace(integ_namespace())
|
|
105
113
|
.task_queue(tq)
|
|
106
114
|
.max_outstanding_activities(100_usize)
|
|
107
115
|
.max_outstanding_local_activities(100_usize)
|
|
@@ -115,23 +123,35 @@ pub(crate) fn integ_worker_config(tq: &str) -> WorkerConfig {
|
|
|
115
123
|
.expect("Configuration options construct properly")
|
|
116
124
|
}
|
|
117
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()
|
|
137
|
+
}
|
|
138
|
+
|
|
118
139
|
/// Create a worker replay instance preloaded with provided histories. Returns the worker impl.
|
|
119
|
-
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
|
|
120
141
|
where
|
|
121
142
|
I: IntoIterator<Item = HistoryForReplay> + 'static,
|
|
122
143
|
<I as IntoIterator>::IntoIter: Send,
|
|
123
144
|
{
|
|
124
145
|
init_core_replay_stream(test_name, stream::iter(histories))
|
|
125
146
|
}
|
|
126
|
-
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
|
|
127
148
|
where
|
|
128
149
|
I: Stream<Item = HistoryForReplay> + Send + 'static,
|
|
129
150
|
{
|
|
130
151
|
init_integ_telem();
|
|
131
152
|
let worker_cfg = integ_worker_config(test_name);
|
|
132
|
-
|
|
133
|
-
.expect("Replay worker must init properly")
|
|
134
|
-
Arc::new(worker)
|
|
153
|
+
init_replay_worker(ReplayWorkerInput::new(worker_cfg, histories))
|
|
154
|
+
.expect("Replay worker must init properly")
|
|
135
155
|
}
|
|
136
156
|
pub(crate) fn replay_sdk_worker<I>(histories: I) -> Worker
|
|
137
157
|
where
|
|
@@ -145,7 +165,8 @@ where
|
|
|
145
165
|
I: Stream<Item = HistoryForReplay> + Send + 'static,
|
|
146
166
|
{
|
|
147
167
|
let core = init_core_replay_stream("replay_worker_test", histories);
|
|
148
|
-
|
|
168
|
+
// TODO [rust-sdk-branch]: Needs DC passed in
|
|
169
|
+
let mut worker = Worker::new_from_core(Arc::new(core), DataConverter::default());
|
|
149
170
|
worker.set_worker_interceptor(FailOnNondeterminismInterceptor {});
|
|
150
171
|
worker
|
|
151
172
|
}
|
|
@@ -187,7 +208,7 @@ pub(crate) fn init_integ_telem() -> Option<&'static CoreRuntime> {
|
|
|
187
208
|
}))
|
|
188
209
|
}
|
|
189
210
|
|
|
190
|
-
pub(crate) async fn get_cloud_client() ->
|
|
211
|
+
pub(crate) async fn get_cloud_client() -> Client {
|
|
191
212
|
let cloud_addr = env::var("TEMPORAL_CLOUD_ADDRESS").unwrap();
|
|
192
213
|
let cloud_key = env::var("TEMPORAL_CLIENT_KEY").unwrap();
|
|
193
214
|
|
|
@@ -196,8 +217,7 @@ pub(crate) async fn get_cloud_client() -> RetryClient<Client> {
|
|
|
196
217
|
.replace("\\n", "\n")
|
|
197
218
|
.into_bytes();
|
|
198
219
|
let client_private_key = cloud_key.replace("\\n", "\n").into_bytes();
|
|
199
|
-
let
|
|
200
|
-
.target_url(Url::from_str(&cloud_addr).unwrap())
|
|
220
|
+
let connection_opts = ConnectionOptions::new(Url::from_str(&cloud_addr).unwrap())
|
|
201
221
|
.client_name("sdk-core-integ-tests")
|
|
202
222
|
.client_version("clientver")
|
|
203
223
|
.identity("sdk-test-client")
|
|
@@ -209,29 +229,31 @@ pub(crate) async fn get_cloud_client() -> RetryClient<Client> {
|
|
|
209
229
|
..Default::default()
|
|
210
230
|
})
|
|
211
231
|
.build();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
)
|
|
216
|
-
.await
|
|
217
|
-
.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()
|
|
218
236
|
}
|
|
219
237
|
|
|
220
238
|
/// Implements a builder pattern to help integ tests initialize core and create workflows
|
|
221
239
|
pub(crate) struct CoreWfStarter {
|
|
222
240
|
/// Used for both the task queue and workflow id
|
|
223
241
|
task_queue_name: String,
|
|
224
|
-
pub
|
|
225
|
-
/// Options to use when starting workflow(s)
|
|
226
|
-
|
|
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,
|
|
227
246
|
initted_worker: OnceCell<InitializedWorker>,
|
|
228
247
|
runtime_override: Option<Arc<CoreRuntime>>,
|
|
229
|
-
client_override: Option<
|
|
248
|
+
client_override: Option<Client>,
|
|
230
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)>>,
|
|
231
253
|
}
|
|
232
254
|
struct InitializedWorker {
|
|
233
|
-
worker: Arc<
|
|
234
|
-
client:
|
|
255
|
+
worker: Arc<CoreWorker>,
|
|
256
|
+
client: Client,
|
|
235
257
|
}
|
|
236
258
|
|
|
237
259
|
impl CoreWfStarter {
|
|
@@ -260,10 +282,9 @@ impl CoreWfStarter {
|
|
|
260
282
|
let mut s = Self::new_with_overrides(test_name, None, client);
|
|
261
283
|
|
|
262
284
|
if check_mlsv && !version_req.is_empty() {
|
|
263
|
-
let clustinfo =
|
|
285
|
+
let clustinfo = s
|
|
264
286
|
.get_client()
|
|
265
|
-
.
|
|
266
|
-
.workflow_svc()
|
|
287
|
+
.await
|
|
267
288
|
.get_cluster_info(GetClusterInfoRequest::default().into_request())
|
|
268
289
|
.await;
|
|
269
290
|
let srv_ver = semver::Version::parse(
|
|
@@ -291,20 +312,20 @@ impl CoreWfStarter {
|
|
|
291
312
|
pub(crate) fn new_with_overrides(
|
|
292
313
|
test_name: &str,
|
|
293
314
|
runtime_override: Option<CoreRuntime>,
|
|
294
|
-
client_override: Option<
|
|
315
|
+
client_override: Option<Client>,
|
|
295
316
|
) -> Self {
|
|
296
317
|
let task_q_salt = rand_6_chars();
|
|
297
318
|
let task_queue = format!("{test_name}_{task_q_salt}");
|
|
298
|
-
let
|
|
299
|
-
worker_config.max_cached_workflows = 1000_usize;
|
|
319
|
+
let sdk_config = integ_sdk_config(&task_queue);
|
|
300
320
|
Self {
|
|
301
|
-
task_queue_name: task_queue,
|
|
302
|
-
|
|
321
|
+
task_queue_name: task_queue.clone(),
|
|
322
|
+
sdk_config,
|
|
303
323
|
initted_worker: OnceCell::new(),
|
|
304
|
-
workflow_options:
|
|
324
|
+
workflow_options: WorkflowStartOptions::new(task_queue.clone(), task_queue).build(),
|
|
305
325
|
runtime_override: runtime_override.map(Arc::new),
|
|
306
|
-
client_override
|
|
326
|
+
client_override,
|
|
307
327
|
min_local_server_version: None,
|
|
328
|
+
core_config_mutator: None,
|
|
308
329
|
}
|
|
309
330
|
}
|
|
310
331
|
|
|
@@ -313,32 +334,44 @@ impl CoreWfStarter {
|
|
|
313
334
|
pub(crate) fn clone_no_worker(&self) -> Self {
|
|
314
335
|
Self {
|
|
315
336
|
task_queue_name: self.task_queue_name.clone(),
|
|
316
|
-
|
|
337
|
+
sdk_config: self.sdk_config.clone(),
|
|
317
338
|
workflow_options: self.workflow_options.clone(),
|
|
318
339
|
runtime_override: self.runtime_override.clone(),
|
|
319
340
|
client_override: self.client_override.clone(),
|
|
320
341
|
min_local_server_version: self.min_local_server_version.clone(),
|
|
321
342
|
initted_worker: Default::default(),
|
|
343
|
+
core_config_mutator: self.core_config_mutator.clone(),
|
|
322
344
|
}
|
|
323
345
|
}
|
|
324
346
|
|
|
325
347
|
pub(crate) async fn worker(&mut self) -> TestWorker {
|
|
326
|
-
let
|
|
327
|
-
let
|
|
328
|
-
|
|
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);
|
|
329
358
|
|
|
330
359
|
w
|
|
331
360
|
}
|
|
332
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
|
+
|
|
333
366
|
pub(crate) async fn shutdown(&mut self) {
|
|
334
367
|
self.get_worker().await.shutdown().await;
|
|
335
368
|
}
|
|
336
369
|
|
|
337
|
-
pub(crate) async fn get_worker(&mut self) -> Arc<
|
|
370
|
+
pub(crate) async fn get_worker(&mut self) -> Arc<CoreWorker> {
|
|
338
371
|
self.get_or_init().await.worker.clone()
|
|
339
372
|
}
|
|
340
373
|
|
|
341
|
-
pub(crate) async fn get_client(&mut self) ->
|
|
374
|
+
pub(crate) async fn get_client(&mut self) -> Client {
|
|
342
375
|
self.get_or_init().await.client.clone()
|
|
343
376
|
}
|
|
344
377
|
|
|
@@ -352,38 +385,17 @@ impl CoreWfStarter {
|
|
|
352
385
|
&self,
|
|
353
386
|
wf_name: impl Into<String>,
|
|
354
387
|
worker: &mut TestWorker,
|
|
355
|
-
) ->
|
|
356
|
-
let
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
wf_name.into(),
|
|
360
|
-
vec![],
|
|
361
|
-
self.workflow_options.clone(),
|
|
362
|
-
)
|
|
388
|
+
) -> UntypedWorkflowHandle<Client> {
|
|
389
|
+
let wf_name = wf_name.into();
|
|
390
|
+
worker
|
|
391
|
+
.submit_wf(&wf_name, vec![], self.workflow_options.clone())
|
|
363
392
|
.await
|
|
364
393
|
.unwrap();
|
|
365
394
|
self.initted_worker
|
|
366
395
|
.get()
|
|
367
396
|
.unwrap()
|
|
368
397
|
.client
|
|
369
|
-
.
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
pub(crate) async fn eager_start_with_worker(
|
|
373
|
-
&self,
|
|
374
|
-
wf_name: impl Into<String>,
|
|
375
|
-
worker: &mut TestWorker,
|
|
376
|
-
) -> StartWorkflowExecutionResponse {
|
|
377
|
-
assert!(self.workflow_options.enable_eager_workflow_start);
|
|
378
|
-
worker
|
|
379
|
-
.eager_submit_wf(
|
|
380
|
-
self.task_queue_name.clone(),
|
|
381
|
-
wf_name.into(),
|
|
382
|
-
vec![],
|
|
383
|
-
self.workflow_options.clone(),
|
|
384
|
-
)
|
|
385
|
-
.await
|
|
386
|
-
.unwrap()
|
|
398
|
+
.get_workflow_handle::<UntypedWorkflow>(&self.task_queue_name)
|
|
387
399
|
}
|
|
388
400
|
|
|
389
401
|
pub(crate) async fn start_wf_with_id(&self, workflow_id: String) -> String {
|
|
@@ -391,18 +403,19 @@ impl CoreWfStarter {
|
|
|
391
403
|
"Worker must be initted before starting a workflow.\
|
|
392
404
|
Tests must call `get_worker` first.",
|
|
393
405
|
);
|
|
406
|
+
let mut options = self.workflow_options.clone();
|
|
407
|
+
options.workflow_id = workflow_id;
|
|
394
408
|
iw.client
|
|
395
409
|
.start_workflow(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
self.task_queue_name.clone(),
|
|
400
|
-
None,
|
|
401
|
-
self.workflow_options.clone(),
|
|
410
|
+
UntypedWorkflow::new(&self.task_queue_name),
|
|
411
|
+
RawValue::empty(),
|
|
412
|
+
options,
|
|
402
413
|
)
|
|
403
414
|
.await
|
|
404
415
|
.unwrap()
|
|
405
|
-
.run_id
|
|
416
|
+
.run_id()
|
|
417
|
+
.unwrap()
|
|
418
|
+
.to_string()
|
|
406
419
|
}
|
|
407
420
|
|
|
408
421
|
pub(crate) fn get_task_queue(&self) -> &str {
|
|
@@ -416,26 +429,33 @@ impl CoreWfStarter {
|
|
|
416
429
|
/// Fetch the history of the default workflow for this starter. IE: The one that would
|
|
417
430
|
/// be started by [CoreWfStarter::start_wf].
|
|
418
431
|
pub(crate) async fn get_history(&self) -> History {
|
|
419
|
-
self
|
|
432
|
+
let client = &self
|
|
433
|
+
.initted_worker
|
|
420
434
|
.get()
|
|
421
435
|
.expect("Starter must be initialized")
|
|
422
|
-
.client
|
|
423
|
-
|
|
436
|
+
.client;
|
|
437
|
+
let events = client
|
|
438
|
+
.get_workflow_handle::<UntypedWorkflow>(self.get_wf_id())
|
|
439
|
+
.fetch_history(Default::default())
|
|
424
440
|
.await
|
|
425
441
|
.unwrap()
|
|
426
|
-
.
|
|
427
|
-
|
|
442
|
+
.into_events();
|
|
443
|
+
History { events }
|
|
428
444
|
}
|
|
429
445
|
|
|
430
446
|
pub(crate) async fn wait_for_default_wf_finish(
|
|
431
447
|
&self,
|
|
432
|
-
) -> Result<
|
|
448
|
+
) -> Result<RawValue, WorkflowGetResultError> {
|
|
433
449
|
self.initted_worker
|
|
434
450
|
.get()
|
|
435
451
|
.unwrap()
|
|
436
452
|
.client
|
|
437
|
-
.
|
|
438
|
-
.
|
|
453
|
+
.get_workflow_handle::<UntypedWorkflow>(&self.task_queue_name)
|
|
454
|
+
.get_result(
|
|
455
|
+
WorkflowGetResultOptions::builder()
|
|
456
|
+
.follow_runs(false)
|
|
457
|
+
.build(),
|
|
458
|
+
)
|
|
439
459
|
.await
|
|
440
460
|
}
|
|
441
461
|
|
|
@@ -447,21 +467,29 @@ impl CoreWfStarter {
|
|
|
447
467
|
} else {
|
|
448
468
|
init_integ_telem().unwrap()
|
|
449
469
|
};
|
|
450
|
-
let
|
|
451
|
-
|
|
452
|
-
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)
|
|
453
474
|
} else {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
)
|
|
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)
|
|
463
483
|
};
|
|
464
|
-
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");
|
|
465
493
|
InitializedWorker {
|
|
466
494
|
worker: Arc::new(worker),
|
|
467
495
|
client,
|
|
@@ -474,8 +502,7 @@ impl CoreWfStarter {
|
|
|
474
502
|
/// Provides conveniences for running integ tests with the SDK (against real server or mocks)
|
|
475
503
|
pub(crate) struct TestWorker {
|
|
476
504
|
inner: Worker,
|
|
477
|
-
|
|
478
|
-
client: Option<Arc<RetryClient<Client>>>,
|
|
505
|
+
client: Option<Client>,
|
|
479
506
|
pub started_workflows: Arc<Mutex<Vec<WorkflowExecutionInfo>>>,
|
|
480
507
|
/// If set true (default), and a client is available, we will fetch workflow results to
|
|
481
508
|
/// determine when they have all completed.
|
|
@@ -483,14 +510,9 @@ pub(crate) struct TestWorker {
|
|
|
483
510
|
}
|
|
484
511
|
impl TestWorker {
|
|
485
512
|
/// Create a new test worker
|
|
486
|
-
pub(crate) fn new(
|
|
487
|
-
let inner = Worker::new_from_core(
|
|
488
|
-
core_worker.clone(),
|
|
489
|
-
core_worker.get_config().task_queue.clone(),
|
|
490
|
-
);
|
|
513
|
+
pub(crate) fn new(sdk: Worker) -> Self {
|
|
491
514
|
Self {
|
|
492
|
-
inner,
|
|
493
|
-
core_worker,
|
|
515
|
+
inner: sdk,
|
|
494
516
|
client: None,
|
|
495
517
|
started_workflows: Arc::new(Mutex::new(vec![])),
|
|
496
518
|
fetch_results: true,
|
|
@@ -502,24 +524,31 @@ impl TestWorker {
|
|
|
502
524
|
}
|
|
503
525
|
|
|
504
526
|
pub(crate) fn worker_instance_key(&self) -> Uuid {
|
|
505
|
-
self.
|
|
527
|
+
self.inner.worker_instance_key()
|
|
506
528
|
}
|
|
507
529
|
|
|
508
|
-
|
|
509
|
-
pub(crate) fn register_wf<F: Into<WorkflowFunction>>(
|
|
530
|
+
pub(crate) fn register_activities<AI: ActivityImplementer>(
|
|
510
531
|
&mut self,
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
self
|
|
532
|
+
instance: AI,
|
|
533
|
+
) -> &mut Self {
|
|
534
|
+
self.inner.register_activities::<AI>(instance);
|
|
535
|
+
self
|
|
515
536
|
}
|
|
516
537
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
|
523
552
|
}
|
|
524
553
|
|
|
525
554
|
/// Create a handle that can be used to submit workflows. Useful when workflows need to be
|
|
@@ -527,7 +556,6 @@ impl TestWorker {
|
|
|
527
556
|
pub(crate) fn get_submitter_handle(&self) -> TestWorkerSubmitterHandle {
|
|
528
557
|
TestWorkerSubmitterHandle {
|
|
529
558
|
client: self.client.clone().expect("client must be set"),
|
|
530
|
-
tq: self.inner.task_queue().to_string(),
|
|
531
559
|
started_workflows: self.started_workflows.clone(),
|
|
532
560
|
}
|
|
533
561
|
}
|
|
@@ -540,10 +568,9 @@ impl TestWorker {
|
|
|
540
568
|
/// Returns the run id of the started workflow (if no client has initialized returns a fake id)
|
|
541
569
|
pub(crate) async fn submit_wf(
|
|
542
570
|
&self,
|
|
543
|
-
workflow_id: impl Into<String>,
|
|
544
571
|
workflow_type: impl Into<String>,
|
|
545
572
|
input: Vec<Payload>,
|
|
546
|
-
mut options:
|
|
573
|
+
mut options: WorkflowStartOptions,
|
|
547
574
|
) -> Result<String, anyhow::Error> {
|
|
548
575
|
if self.client.is_none() {
|
|
549
576
|
return Ok("fake_run_id".to_string());
|
|
@@ -554,41 +581,34 @@ impl TestWorker {
|
|
|
554
581
|
options.execution_timeout = Some(Duration::from_secs(60 * 5));
|
|
555
582
|
}
|
|
556
583
|
self.get_submitter_handle()
|
|
557
|
-
.submit_wf(
|
|
584
|
+
.submit_wf(workflow_type, input, options)
|
|
558
585
|
.await
|
|
559
586
|
}
|
|
560
587
|
|
|
561
|
-
///
|
|
562
|
-
|
|
563
|
-
/// Note that this does not guarantee that the worker will execute this task eagerly.
|
|
564
|
-
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>(
|
|
565
590
|
&self,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
options,
|
|
581
|
-
)
|
|
582
|
-
.await?;
|
|
583
|
-
res.eager_workflow_task
|
|
584
|
-
.as_ref()
|
|
585
|
-
.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?;
|
|
586
605
|
self.started_workflows.lock().push(WorkflowExecutionInfo {
|
|
587
|
-
namespace: c.namespace()
|
|
606
|
+
namespace: c.namespace(),
|
|
588
607
|
workflow_id: wfid,
|
|
589
|
-
run_id:
|
|
608
|
+
run_id: handle.info().run_id.clone(),
|
|
609
|
+
first_execution_run_id: None,
|
|
590
610
|
});
|
|
591
|
-
Ok(
|
|
611
|
+
Ok(handle)
|
|
592
612
|
}
|
|
593
613
|
|
|
594
614
|
pub(crate) fn expect_workflow_completion(
|
|
@@ -604,6 +624,7 @@ impl TestWorker {
|
|
|
604
624
|
.unwrap_or(NAMESPACE.to_owned()),
|
|
605
625
|
workflow_id: wf_id.into(),
|
|
606
626
|
run_id,
|
|
627
|
+
first_execution_run_id: None,
|
|
607
628
|
});
|
|
608
629
|
}
|
|
609
630
|
|
|
@@ -637,11 +658,14 @@ impl TestWorker {
|
|
|
637
658
|
tokio::try_join!(self.inner.run(), get_results_waiter)?;
|
|
638
659
|
Ok(())
|
|
639
660
|
}
|
|
661
|
+
|
|
662
|
+
pub(crate) fn core_worker(&self) -> Arc<temporalio_sdk_core::Worker> {
|
|
663
|
+
self.inner.core_worker()
|
|
664
|
+
}
|
|
640
665
|
}
|
|
641
666
|
|
|
642
667
|
pub(crate) struct TestWorkerSubmitterHandle {
|
|
643
|
-
client:
|
|
644
|
-
tq: String,
|
|
668
|
+
client: Client,
|
|
645
669
|
started_workflows: Arc<Mutex<Vec<WorkflowExecutionInfo>>>,
|
|
646
670
|
}
|
|
647
671
|
impl TestWorkerSubmitterHandle {
|
|
@@ -653,34 +677,32 @@ impl TestWorkerSubmitterHandle {
|
|
|
653
677
|
/// Returns the run id of the started workflow
|
|
654
678
|
pub(crate) async fn submit_wf(
|
|
655
679
|
&self,
|
|
656
|
-
workflow_id: impl Into<String>,
|
|
657
680
|
workflow_type: impl Into<String>,
|
|
658
681
|
input: Vec<Payload>,
|
|
659
|
-
options:
|
|
682
|
+
options: WorkflowStartOptions,
|
|
660
683
|
) -> Result<String, anyhow::Error> {
|
|
661
|
-
let wfid = workflow_id.
|
|
662
|
-
let
|
|
684
|
+
let wfid = options.workflow_id.clone();
|
|
685
|
+
let handle = self
|
|
663
686
|
.client
|
|
664
687
|
.start_workflow(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
wfid.clone(),
|
|
668
|
-
workflow_type.into(),
|
|
669
|
-
None,
|
|
688
|
+
UntypedWorkflow::new(workflow_type.into()),
|
|
689
|
+
RawValue::new(input),
|
|
670
690
|
options,
|
|
671
691
|
)
|
|
672
692
|
.await?;
|
|
693
|
+
let run_id = handle.run_id().unwrap().to_string();
|
|
673
694
|
self.started_workflows.lock().push(WorkflowExecutionInfo {
|
|
674
|
-
namespace: self.client.namespace()
|
|
695
|
+
namespace: self.client.namespace(),
|
|
675
696
|
workflow_id: wfid,
|
|
676
|
-
run_id: Some(
|
|
697
|
+
run_id: Some(run_id.clone()),
|
|
698
|
+
first_execution_run_id: None,
|
|
677
699
|
});
|
|
678
|
-
Ok(
|
|
700
|
+
Ok(run_id)
|
|
679
701
|
}
|
|
680
702
|
}
|
|
681
703
|
|
|
682
704
|
pub(crate) enum TestWorkerShutdownCond {
|
|
683
|
-
GetResults(Vec<WorkflowExecutionInfo>,
|
|
705
|
+
GetResults(Vec<WorkflowExecutionInfo>, Client),
|
|
684
706
|
NoAutoShutdown,
|
|
685
707
|
}
|
|
686
708
|
/// Implements calling the shutdown handle when the expected number of test workflows has completed
|
|
@@ -702,7 +724,7 @@ impl TestWorkerCompletionIceptor {
|
|
|
702
724
|
if let TestWorkerShutdownCond::GetResults(ref mut wfs, ref client) = self.condition {
|
|
703
725
|
let wfs = std::mem::take(wfs);
|
|
704
726
|
let shutdown_h = self.shutdown_handle.clone();
|
|
705
|
-
let client =
|
|
727
|
+
let client = client.clone();
|
|
706
728
|
let stream = stream::iter(
|
|
707
729
|
wfs.into_iter()
|
|
708
730
|
.map(move |info| info.bind_untyped(client.clone())),
|
|
@@ -711,7 +733,11 @@ impl TestWorkerCompletionIceptor {
|
|
|
711
733
|
future::Either::Left(async move {
|
|
712
734
|
stream
|
|
713
735
|
.try_for_each_concurrent(None, |wh| async move {
|
|
714
|
-
wh.
|
|
736
|
+
if let Err(e) = wh.get_result(Default::default()).await
|
|
737
|
+
&& !e.is_workflow_outcome()
|
|
738
|
+
{
|
|
739
|
+
return Err(e.into());
|
|
740
|
+
}
|
|
715
741
|
Ok::<_, anyhow::Error>(())
|
|
716
742
|
})
|
|
717
743
|
.await?;
|
|
@@ -747,8 +773,8 @@ impl WorkerInterceptor for TestWorkerCompletionIceptor {
|
|
|
747
773
|
}
|
|
748
774
|
}
|
|
749
775
|
|
|
750
|
-
/// Returns the
|
|
751
|
-
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 {
|
|
752
778
|
let temporal_server_address = env::var(INTEG_SERVER_TARGET_ENV_VAR)
|
|
753
779
|
.unwrap_or_else(|_| "http://localhost:7233".to_owned());
|
|
754
780
|
let url = Url::try_from(&*temporal_server_address).unwrap();
|
|
@@ -757,9 +783,8 @@ pub(crate) fn get_integ_server_options() -> ClientOptions {
|
|
|
757
783
|
.map(|key_file| std::fs::read_to_string(key_file).unwrap());
|
|
758
784
|
let tls_cfg = get_integ_tls_config();
|
|
759
785
|
|
|
760
|
-
|
|
786
|
+
ConnectionOptions::new(url)
|
|
761
787
|
.identity(INTEG_CLIENT_IDENTITY.to_string())
|
|
762
|
-
.target_url(url)
|
|
763
788
|
.client_name(INTEG_CLIENT_NAME.to_string())
|
|
764
789
|
.client_version(INTEG_CLIENT_VERSION.to_string())
|
|
765
790
|
.maybe_api_key(api_key)
|
|
@@ -767,6 +792,25 @@ pub(crate) fn get_integ_server_options() -> ClientOptions {
|
|
|
767
792
|
.build()
|
|
768
793
|
}
|
|
769
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
|
+
|
|
770
814
|
pub(crate) fn get_integ_tls_config() -> Option<TlsOptions> {
|
|
771
815
|
if env::var(INTEG_USE_TLS_ENV_VAR).is_ok() {
|
|
772
816
|
let root = std::fs::read("../.cloud_certs/ca.pem").unwrap();
|
|
@@ -841,27 +885,21 @@ pub(crate) trait WorkflowHandleExt {
|
|
|
841
885
|
}
|
|
842
886
|
|
|
843
887
|
#[async_trait::async_trait(?Send)]
|
|
844
|
-
impl<
|
|
888
|
+
impl<W> WorkflowHandleExt for WorkflowHandle<Client, W>
|
|
845
889
|
where
|
|
846
|
-
|
|
890
|
+
W: WorkflowDefinition,
|
|
847
891
|
{
|
|
848
892
|
async fn fetch_history_and_replay(
|
|
849
893
|
&self,
|
|
850
894
|
worker: &mut Worker,
|
|
851
895
|
) -> Result<Option<Payload>, anyhow::Error> {
|
|
852
896
|
let wf_id = self.info().workflow_id.clone();
|
|
853
|
-
let
|
|
854
|
-
let
|
|
855
|
-
.client()
|
|
856
|
-
.get_workflow_execution_history(wf_id.clone(), run_id, vec![])
|
|
857
|
-
.await?
|
|
858
|
-
.history
|
|
859
|
-
.expect("history field must be populated");
|
|
860
|
-
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);
|
|
861
899
|
let replay_worker = init_core_replay_preloaded(worker.task_queue(), [with_id]);
|
|
862
|
-
worker.with_new_core_worker(replay_worker);
|
|
900
|
+
worker.with_new_core_worker(Arc::new(replay_worker));
|
|
863
901
|
let retval_icept = ReturnWorkflowExitValueInterceptor::default();
|
|
864
|
-
let retval_handle = retval_icept.
|
|
902
|
+
let retval_handle = retval_icept.result_handle();
|
|
865
903
|
let mut top_icept = InterceptorWithNext::new(Box::new(FailOnNondeterminismInterceptor {}));
|
|
866
904
|
top_icept.set_next(Box::new(retval_icept));
|
|
867
905
|
worker.set_worker_interceptor(top_icept);
|
|
@@ -910,9 +948,12 @@ impl Drop for AbortOnDrop {
|
|
|
910
948
|
}
|
|
911
949
|
}
|
|
912
950
|
|
|
913
|
-
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>
|
|
914
955
|
where
|
|
915
|
-
F:
|
|
956
|
+
F: FnMut() -> Fut,
|
|
916
957
|
Fut: Future<Output = Result<T, E>>,
|
|
917
958
|
{
|
|
918
959
|
let start = Instant::now();
|
|
@@ -934,7 +975,8 @@ pub(crate) fn build_fake_sdk(mock_cfg: MockPollCfg) -> temporalio_sdk::Worker {
|
|
|
934
975
|
c.ignore_evicts_on_shutdown = false;
|
|
935
976
|
});
|
|
936
977
|
let core = mock_worker(mock);
|
|
937
|
-
let mut worker =
|
|
978
|
+
let mut worker =
|
|
979
|
+
temporalio_sdk::Worker::new_from_core(Arc::new(core), DataConverter::default());
|
|
938
980
|
worker.set_worker_interceptor(FailOnNondeterminismInterceptor {});
|
|
939
981
|
worker
|
|
940
982
|
}
|
|
@@ -951,7 +993,10 @@ pub(crate) fn mock_sdk_cfg(
|
|
|
951
993
|
let mut mock = build_mock_pollers(poll_cfg);
|
|
952
994
|
mock.worker_cfg(mutator);
|
|
953
995
|
let core = mock_worker(mock);
|
|
954
|
-
TestWorker::new(
|
|
996
|
+
TestWorker::new(temporalio_sdk::Worker::new_from_core(
|
|
997
|
+
Arc::new(core),
|
|
998
|
+
DataConverter::default(),
|
|
999
|
+
))
|
|
955
1000
|
}
|
|
956
1001
|
|
|
957
1002
|
#[derive(Default)]
|