@temporalio/core-bridge 1.12.0 → 1.12.2
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 +64 -119
- package/Cargo.toml +1 -1
- package/index.js +3 -2
- package/package.json +3 -3
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/sdk-core/.cargo/config.toml +1 -2
- package/sdk-core/.github/workflows/per-pr.yml +2 -0
- package/sdk-core/AGENTS.md +7 -0
- package/sdk-core/Cargo.toml +9 -5
- package/sdk-core/README.md +6 -5
- package/sdk-core/client/Cargo.toml +3 -2
- package/sdk-core/client/src/lib.rs +17 -8
- package/sdk-core/client/src/metrics.rs +57 -23
- package/sdk-core/client/src/raw.rs +33 -15
- package/sdk-core/core/Cargo.toml +11 -9
- package/sdk-core/core/benches/workflow_replay.rs +114 -15
- package/sdk-core/core/src/core_tests/activity_tasks.rs +18 -18
- package/sdk-core/core/src/core_tests/child_workflows.rs +4 -4
- package/sdk-core/core/src/core_tests/determinism.rs +6 -6
- package/sdk-core/core/src/core_tests/local_activities.rs +20 -20
- package/sdk-core/core/src/core_tests/mod.rs +40 -5
- package/sdk-core/core/src/core_tests/queries.rs +25 -16
- package/sdk-core/core/src/core_tests/replay_flag.rs +3 -3
- package/sdk-core/core/src/core_tests/updates.rs +3 -3
- package/sdk-core/core/src/core_tests/workers.rs +9 -7
- package/sdk-core/core/src/core_tests/workflow_tasks.rs +40 -42
- package/sdk-core/core/src/ephemeral_server/mod.rs +1 -19
- package/sdk-core/core/src/lib.rs +10 -1
- package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
- package/sdk-core/core/src/replay/mod.rs +3 -3
- package/sdk-core/core/src/telemetry/metrics.rs +306 -152
- package/sdk-core/core/src/telemetry/mod.rs +11 -4
- package/sdk-core/core/src/telemetry/otel.rs +134 -131
- package/sdk-core/core/src/telemetry/prometheus_meter.rs +885 -0
- package/sdk-core/core/src/telemetry/prometheus_server.rs +48 -28
- package/sdk-core/core/src/test_help/mod.rs +27 -12
- package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +7 -7
- package/sdk-core/core/src/worker/activities.rs +4 -4
- package/sdk-core/core/src/worker/client/mocks.rs +10 -3
- package/sdk-core/core/src/worker/client.rs +68 -5
- package/sdk-core/core/src/worker/heartbeat.rs +229 -0
- package/sdk-core/core/src/worker/mod.rs +35 -14
- package/sdk-core/core/src/worker/tuner/resource_based.rs +4 -4
- package/sdk-core/core/src/worker/workflow/history_update.rs +71 -19
- package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -2
- package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -1
- package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +31 -48
- package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -2
- package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +3 -3
- package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +4 -1
- package/sdk-core/core/src/worker/workflow/managed_run.rs +1 -1
- package/sdk-core/core/src/worker/workflow/mod.rs +15 -15
- package/sdk-core/core-api/Cargo.toml +2 -2
- package/sdk-core/core-api/src/envconfig.rs +204 -99
- package/sdk-core/core-api/src/lib.rs +9 -0
- package/sdk-core/core-api/src/telemetry/metrics.rs +548 -100
- package/sdk-core/core-api/src/worker.rs +11 -5
- package/sdk-core/core-c-bridge/Cargo.toml +49 -0
- package/sdk-core/core-c-bridge/build.rs +26 -0
- package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +817 -0
- package/sdk-core/core-c-bridge/src/client.rs +679 -0
- package/sdk-core/core-c-bridge/src/lib.rs +245 -0
- package/sdk-core/core-c-bridge/src/metric.rs +682 -0
- package/sdk-core/core-c-bridge/src/random.rs +61 -0
- package/sdk-core/core-c-bridge/src/runtime.rs +445 -0
- package/sdk-core/core-c-bridge/src/testing.rs +282 -0
- package/sdk-core/core-c-bridge/src/tests/context.rs +644 -0
- package/sdk-core/core-c-bridge/src/tests/mod.rs +178 -0
- package/sdk-core/core-c-bridge/src/tests/utils.rs +108 -0
- package/sdk-core/core-c-bridge/src/worker.rs +1069 -0
- package/sdk-core/etc/deps.svg +64 -64
- package/sdk-core/sdk/src/activity_context.rs +6 -4
- package/sdk-core/sdk/src/lib.rs +49 -27
- package/sdk-core/sdk/src/workflow_future.rs +18 -25
- package/sdk-core/sdk-core-protos/protos/api_upstream/README.md +4 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/buf.yaml +0 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +630 -83
- package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +632 -78
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/batch/v1/message.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/command/v1/message.proto +6 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +32 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/common.proto +10 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/deployment.proto +26 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/enums/v1/reset.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/history/v1/message.proto +47 -31
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/nexus/v1/message.proto +4 -4
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/schedule/v1/message.proto +7 -1
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/worker/v1/message.proto +134 -0
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflow/v1/message.proto +14 -11
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +148 -37
- package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +21 -0
- package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -4
- package/sdk-core/sdk-core-protos/src/history_builder.rs +9 -5
- package/sdk-core/sdk-core-protos/src/lib.rs +96 -6
- package/sdk-core/test-utils/src/lib.rs +11 -3
- package/sdk-core/tests/cloud_tests.rs +3 -3
- package/sdk-core/tests/heavy_tests.rs +11 -3
- package/sdk-core/tests/integ_tests/client_tests.rs +12 -13
- package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/metrics_tests.rs +188 -83
- package/sdk-core/tests/integ_tests/polling_tests.rs +1 -1
- package/sdk-core/tests/integ_tests/queries_tests.rs +56 -40
- package/sdk-core/tests/integ_tests/update_tests.rs +2 -7
- package/sdk-core/tests/integ_tests/worker_tests.rs +3 -4
- package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +3 -7
- package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +3 -5
- package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +24 -17
- package/src/client.rs +6 -0
- package/src/metrics.rs +6 -6
|
@@ -4,7 +4,7 @@ use crate::{
|
|
|
4
4
|
MockPollCfg, ResponseType, build_fake_sdk, canned_histories, mock_sdk, mock_sdk_cfg,
|
|
5
5
|
mock_worker, single_hist_mock_sg,
|
|
6
6
|
},
|
|
7
|
-
worker::client::mocks::
|
|
7
|
+
worker::client::mocks::mock_worker_client,
|
|
8
8
|
};
|
|
9
9
|
use temporal_client::WorkflowOptions;
|
|
10
10
|
use temporal_sdk::{ChildWorkflowOptions, Signal, WfContext, WorkflowResult};
|
|
@@ -32,7 +32,7 @@ async fn signal_child_workflow(#[case] serial: bool) {
|
|
|
32
32
|
let wf_id = "fakeid";
|
|
33
33
|
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
34
34
|
let t = canned_histories::single_child_workflow_signaled("child-id-1", SIGNAME);
|
|
35
|
-
let mock =
|
|
35
|
+
let mock = mock_worker_client();
|
|
36
36
|
let mut worker = mock_sdk(MockPollCfg::from_resp_batches(
|
|
37
37
|
wf_id,
|
|
38
38
|
t,
|
|
@@ -130,7 +130,7 @@ async fn cancel_child_workflow_lang_thinks_not_started_but_is(
|
|
|
130
130
|
}
|
|
131
131
|
_ => canned_histories::single_child_workflow_cancelled("child-id-1"),
|
|
132
132
|
};
|
|
133
|
-
let mock =
|
|
133
|
+
let mock = mock_worker_client();
|
|
134
134
|
let mock = single_hist_mock_sg("fakeid", t, [ResponseType::AllHistory], mock, true);
|
|
135
135
|
let core = mock_worker(mock);
|
|
136
136
|
let act = core.poll_workflow_activation().await.unwrap();
|
|
@@ -179,7 +179,7 @@ async fn cancel_child_workflow_lang_thinks_not_started_but_is(
|
|
|
179
179
|
#[tokio::test]
|
|
180
180
|
async fn cancel_already_complete_child_ignored() {
|
|
181
181
|
let t = canned_histories::single_child_workflow("child-id-1");
|
|
182
|
-
let mock =
|
|
182
|
+
let mock = mock_worker_client();
|
|
183
183
|
let mock = single_hist_mock_sg("fakeid", t, [ResponseType::AllHistory], mock, true);
|
|
184
184
|
let core = mock_worker(mock);
|
|
185
185
|
let act = core.poll_workflow_activation().await.unwrap();
|
|
@@ -2,7 +2,7 @@ use crate::{
|
|
|
2
2
|
internal_flags::CoreInternalFlags,
|
|
3
3
|
replay::DEFAULT_WORKFLOW_TYPE,
|
|
4
4
|
test_help::{MockPollCfg, ResponseType, canned_histories, mock_sdk, mock_sdk_cfg},
|
|
5
|
-
worker::client::mocks::
|
|
5
|
+
worker::client::mocks::mock_worker_client,
|
|
6
6
|
};
|
|
7
7
|
use std::{
|
|
8
8
|
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
|
|
@@ -40,7 +40,7 @@ async fn test_panic_wf_task_rejected_properly() {
|
|
|
40
40
|
let wf_id = "fakeid";
|
|
41
41
|
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
42
42
|
let t = canned_histories::workflow_fails_with_failure_after_timer("1");
|
|
43
|
-
let mock =
|
|
43
|
+
let mock = mock_worker_client();
|
|
44
44
|
let mut mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2, 2], mock);
|
|
45
45
|
// We should see one wft failure which has unspecified cause, since panics don't have a defined
|
|
46
46
|
// type.
|
|
@@ -72,7 +72,7 @@ async fn test_wf_task_rejected_properly_due_to_nondeterminism(#[case] use_cache:
|
|
|
72
72
|
let wf_id = "fakeid";
|
|
73
73
|
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
74
74
|
let t = canned_histories::single_timer_wf_completes("1");
|
|
75
|
-
let mock =
|
|
75
|
+
let mock = mock_worker_client();
|
|
76
76
|
let mut mh = MockPollCfg::from_resp_batches(
|
|
77
77
|
wf_id,
|
|
78
78
|
t,
|
|
@@ -131,7 +131,7 @@ async fn activity_id_or_type_change_is_nondeterministic(
|
|
|
131
131
|
canned_histories::single_activity("1")
|
|
132
132
|
};
|
|
133
133
|
t.set_flags_first_wft(&[CoreInternalFlags::IdAndTypeDeterminismChecks as u32], &[]);
|
|
134
|
-
let mock =
|
|
134
|
+
let mock = mock_worker_client();
|
|
135
135
|
let mut mh = MockPollCfg::from_resp_batches(
|
|
136
136
|
wf_id,
|
|
137
137
|
t,
|
|
@@ -214,7 +214,7 @@ async fn child_wf_id_or_type_change_is_nondeterministic(
|
|
|
214
214
|
let wf_type = DEFAULT_WORKFLOW_TYPE;
|
|
215
215
|
let mut t = canned_histories::single_child_workflow("1");
|
|
216
216
|
t.set_flags_first_wft(&[CoreInternalFlags::IdAndTypeDeterminismChecks as u32], &[]);
|
|
217
|
-
let mock =
|
|
217
|
+
let mock = mock_worker_client();
|
|
218
218
|
let mut mh = MockPollCfg::from_resp_batches(
|
|
219
219
|
wf_id,
|
|
220
220
|
t,
|
|
@@ -289,7 +289,7 @@ async fn repro_channel_missing_because_nondeterminism() {
|
|
|
289
289
|
let _ts = t.add_by_type(EventType::TimerStarted);
|
|
290
290
|
t.add_workflow_task_scheduled_and_started();
|
|
291
291
|
|
|
292
|
-
let mock =
|
|
292
|
+
let mock = mock_worker_client();
|
|
293
293
|
let mut mh =
|
|
294
294
|
MockPollCfg::from_resp_batches(wf_id, t, [1.into(), ResponseType::AllHistory], mock);
|
|
295
295
|
mh.num_expected_fails = 1;
|
|
@@ -5,7 +5,7 @@ use crate::{
|
|
|
5
5
|
MockPollCfg, ResponseType, WorkerExt, build_mock_pollers, hist_to_poll_resp, mock_sdk,
|
|
6
6
|
mock_sdk_cfg, mock_worker, single_hist_mock_sg,
|
|
7
7
|
},
|
|
8
|
-
worker::{LEGACY_QUERY_ID, client::mocks::
|
|
8
|
+
worker::{LEGACY_QUERY_ID, client::mocks::mock_worker_client},
|
|
9
9
|
};
|
|
10
10
|
use anyhow::anyhow;
|
|
11
11
|
use crossbeam_queue::SegQueue;
|
|
@@ -69,7 +69,7 @@ async fn local_act_two_wfts_before_marker(#[case] replay: bool, #[case] cached:
|
|
|
69
69
|
t.add_workflow_execution_completed();
|
|
70
70
|
|
|
71
71
|
let wf_id = "fakeid";
|
|
72
|
-
let mock =
|
|
72
|
+
let mock = mock_worker_client();
|
|
73
73
|
let resps = if replay {
|
|
74
74
|
vec![ResponseType::AllHistory]
|
|
75
75
|
} else {
|
|
@@ -140,7 +140,7 @@ async fn local_act_many_concurrent() {
|
|
|
140
140
|
t.add_workflow_execution_completed();
|
|
141
141
|
|
|
142
142
|
let wf_id = "fakeid";
|
|
143
|
-
let mock =
|
|
143
|
+
let mock = mock_worker_client();
|
|
144
144
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2, 3], mock);
|
|
145
145
|
let mut worker = mock_sdk(mh);
|
|
146
146
|
|
|
@@ -178,7 +178,7 @@ async fn local_act_heartbeat(#[case] shutdown_middle: bool) {
|
|
|
178
178
|
t.add_workflow_task_scheduled_and_started();
|
|
179
179
|
|
|
180
180
|
let wf_id = "fakeid";
|
|
181
|
-
let mock =
|
|
181
|
+
let mock = mock_worker_client();
|
|
182
182
|
let mut mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2, 2, 2], mock);
|
|
183
183
|
mh.enforce_correct_number_of_polls = false;
|
|
184
184
|
let mut worker = mock_sdk_cfg(mh, |wc| {
|
|
@@ -240,7 +240,7 @@ async fn local_act_fail_and_retry(#[case] eventually_pass: bool) {
|
|
|
240
240
|
t.add_workflow_task_scheduled_and_started();
|
|
241
241
|
|
|
242
242
|
let wf_id = "fakeid";
|
|
243
|
-
let mock =
|
|
243
|
+
let mock = mock_worker_client();
|
|
244
244
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [1], mock);
|
|
245
245
|
let mut worker = mock_sdk(mh);
|
|
246
246
|
|
|
@@ -316,7 +316,7 @@ async fn local_act_retry_long_backoff_uses_timer() {
|
|
|
316
316
|
t.add_workflow_execution_completed();
|
|
317
317
|
|
|
318
318
|
let wf_id = "fakeid";
|
|
319
|
-
let mock =
|
|
319
|
+
let mock = mock_worker_client();
|
|
320
320
|
let mh = MockPollCfg::from_resp_batches(
|
|
321
321
|
wf_id,
|
|
322
322
|
t,
|
|
@@ -376,7 +376,7 @@ async fn local_act_null_result() {
|
|
|
376
376
|
t.add_workflow_execution_completed();
|
|
377
377
|
|
|
378
378
|
let wf_id = "fakeid";
|
|
379
|
-
let mock =
|
|
379
|
+
let mock = mock_worker_client();
|
|
380
380
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [ResponseType::AllHistory], mock);
|
|
381
381
|
let mut worker = mock_sdk_cfg(mh, |w| w.max_cached_workflows = 1);
|
|
382
382
|
|
|
@@ -418,7 +418,7 @@ async fn local_act_command_immediately_follows_la_marker() {
|
|
|
418
418
|
t.add_full_wf_task();
|
|
419
419
|
|
|
420
420
|
let wf_id = "fakeid";
|
|
421
|
-
let mock =
|
|
421
|
+
let mock = mock_worker_client();
|
|
422
422
|
// Bug only repros when seeing history up to third wft
|
|
423
423
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [3], mock);
|
|
424
424
|
let mut worker = mock_sdk_cfg(mh, |w| w.max_cached_workflows = 0);
|
|
@@ -489,7 +489,7 @@ async fn query_during_wft_heartbeat_doesnt_accidentally_fail_to_continue_heartbe
|
|
|
489
489
|
),
|
|
490
490
|
),
|
|
491
491
|
];
|
|
492
|
-
let mock =
|
|
492
|
+
let mock = mock_worker_client();
|
|
493
493
|
let mut mock = single_hist_mock_sg(wfid, t, tasks, mock, true);
|
|
494
494
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 1);
|
|
495
495
|
let core = mock_worker(mock);
|
|
@@ -605,7 +605,7 @@ async fn la_resolve_during_legacy_query_does_not_combine(#[case] impossible_quer
|
|
|
605
605
|
pr
|
|
606
606
|
},
|
|
607
607
|
];
|
|
608
|
-
let mut mock =
|
|
608
|
+
let mut mock = mock_worker_client();
|
|
609
609
|
if impossible_query_in_task {
|
|
610
610
|
mock.expect_respond_legacy_query()
|
|
611
611
|
.times(1)
|
|
@@ -712,7 +712,7 @@ async fn test_schedule_to_start_timeout() {
|
|
|
712
712
|
t.add_full_wf_task();
|
|
713
713
|
|
|
714
714
|
let wf_id = "fakeid";
|
|
715
|
-
let mock =
|
|
715
|
+
let mock = mock_worker_client();
|
|
716
716
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [ResponseType::ToTaskNum(1)], mock);
|
|
717
717
|
let mut worker = mock_sdk_cfg(mh, |w| w.max_cached_workflows = 1);
|
|
718
718
|
|
|
@@ -791,7 +791,7 @@ async fn test_schedule_to_start_timeout_not_based_on_original_time(
|
|
|
791
791
|
t.add_workflow_task_scheduled_and_started();
|
|
792
792
|
|
|
793
793
|
let wf_id = "fakeid";
|
|
794
|
-
let mock =
|
|
794
|
+
let mock = mock_worker_client();
|
|
795
795
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [ResponseType::AllHistory], mock);
|
|
796
796
|
let mut worker = mock_sdk_cfg(mh, |w| w.max_cached_workflows = 1);
|
|
797
797
|
|
|
@@ -868,7 +868,7 @@ async fn start_to_close_timeout_allows_retries(#[values(true, false)] la_complet
|
|
|
868
868
|
t.add_workflow_execution_completed();
|
|
869
869
|
|
|
870
870
|
let wf_id = "fakeid";
|
|
871
|
-
let mock =
|
|
871
|
+
let mock = mock_worker_client();
|
|
872
872
|
let mh = MockPollCfg::from_resp_batches(
|
|
873
873
|
wf_id,
|
|
874
874
|
t,
|
|
@@ -947,7 +947,7 @@ async fn wft_failure_cancels_running_las() {
|
|
|
947
947
|
t.add_workflow_task_scheduled_and_started();
|
|
948
948
|
|
|
949
949
|
let wf_id = "fakeid";
|
|
950
|
-
let mock =
|
|
950
|
+
let mock = mock_worker_client();
|
|
951
951
|
let mut mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2], mock);
|
|
952
952
|
mh.num_expected_fails = 1;
|
|
953
953
|
let mut worker = mock_sdk_cfg(mh, |w| w.max_cached_workflows = 1);
|
|
@@ -1007,7 +1007,7 @@ async fn resolved_las_not_recorded_if_wft_fails_many_times() {
|
|
|
1007
1007
|
t.add_workflow_task_scheduled_and_started();
|
|
1008
1008
|
|
|
1009
1009
|
let wf_id = "fakeid";
|
|
1010
|
-
let mock =
|
|
1010
|
+
let mock = mock_worker_client();
|
|
1011
1011
|
let mut mh = MockPollCfg::from_resp_batches(
|
|
1012
1012
|
wf_id,
|
|
1013
1013
|
t,
|
|
@@ -1058,7 +1058,7 @@ async fn local_act_records_nonfirst_attempts_ok() {
|
|
|
1058
1058
|
t.add_workflow_task_scheduled_and_started();
|
|
1059
1059
|
|
|
1060
1060
|
let wf_id = "fakeid";
|
|
1061
|
-
let mock =
|
|
1061
|
+
let mock = mock_worker_client();
|
|
1062
1062
|
let mut mh = MockPollCfg::from_resp_batches(wf_id, t, [1, 2, 3], mock);
|
|
1063
1063
|
let nonfirst_counts = Arc::new(SegQueue::new());
|
|
1064
1064
|
let nfc_c = nonfirst_counts.clone();
|
|
@@ -1125,7 +1125,7 @@ async fn local_activities_can_be_delivered_during_shutdown() {
|
|
|
1125
1125
|
t.add_timer_fired(timer_started_event_id, "1".to_string());
|
|
1126
1126
|
t.add_workflow_task_scheduled_and_started();
|
|
1127
1127
|
|
|
1128
|
-
let mock =
|
|
1128
|
+
let mock = mock_worker_client();
|
|
1129
1129
|
let mut mock = single_hist_mock_sg(
|
|
1130
1130
|
wfid,
|
|
1131
1131
|
t,
|
|
@@ -1214,7 +1214,7 @@ async fn queries_can_be_received_while_heartbeating() {
|
|
|
1214
1214
|
pr
|
|
1215
1215
|
},
|
|
1216
1216
|
];
|
|
1217
|
-
let mut mock =
|
|
1217
|
+
let mut mock = mock_worker_client();
|
|
1218
1218
|
mock.expect_respond_legacy_query()
|
|
1219
1219
|
.times(1)
|
|
1220
1220
|
.returning(move |_, _| Ok(Default::default()));
|
|
@@ -1291,7 +1291,7 @@ async fn local_activity_after_wf_complete_is_discarded() {
|
|
|
1291
1291
|
t.add_full_wf_task();
|
|
1292
1292
|
t.add_workflow_task_scheduled_and_started();
|
|
1293
1293
|
|
|
1294
|
-
let mock =
|
|
1294
|
+
let mock = mock_worker_client();
|
|
1295
1295
|
let mut mock_cfg = MockPollCfg::from_resp_batches(
|
|
1296
1296
|
wfid,
|
|
1297
1297
|
t,
|
|
@@ -1385,7 +1385,7 @@ async fn local_act_retry_explicit_delay() {
|
|
|
1385
1385
|
t.add_workflow_task_scheduled_and_started();
|
|
1386
1386
|
|
|
1387
1387
|
let wf_id = "fakeid";
|
|
1388
|
-
let mock =
|
|
1388
|
+
let mock = mock_worker_client();
|
|
1389
1389
|
let mh = MockPollCfg::from_resp_batches(wf_id, t, [1], mock);
|
|
1390
1390
|
let mut worker = mock_sdk(mh);
|
|
1391
1391
|
|
|
@@ -12,19 +12,31 @@ mod workflow_tasks;
|
|
|
12
12
|
use crate::{
|
|
13
13
|
Worker,
|
|
14
14
|
errors::PollError,
|
|
15
|
-
test_help::{
|
|
16
|
-
|
|
15
|
+
test_help::{
|
|
16
|
+
MockPollCfg, build_mock_pollers, canned_histories, mock_worker, single_hist_mock_sg,
|
|
17
|
+
test_worker_cfg,
|
|
18
|
+
},
|
|
19
|
+
worker::client::mocks::{mock_manual_worker_client, mock_worker_client},
|
|
17
20
|
};
|
|
18
21
|
use futures_util::FutureExt;
|
|
19
22
|
use std::{sync::LazyLock, time::Duration};
|
|
20
23
|
use temporal_sdk_core_api::{Worker as WorkerTrait, worker::PollerBehavior};
|
|
21
|
-
use temporal_sdk_core_protos::
|
|
24
|
+
use temporal_sdk_core_protos::{
|
|
25
|
+
TestHistoryBuilder,
|
|
26
|
+
coresdk::{
|
|
27
|
+
workflow_activation::{WorkflowActivationJob, workflow_activation_job},
|
|
28
|
+
workflow_completion::WorkflowActivationCompletion,
|
|
29
|
+
},
|
|
30
|
+
temporal::api::{
|
|
31
|
+
enums::v1::EventType, history::v1::WorkflowExecutionOptionsUpdatedEventAttributes,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
22
34
|
use tokio::{sync::Barrier, time::sleep};
|
|
23
35
|
|
|
24
36
|
#[tokio::test]
|
|
25
37
|
async fn after_shutdown_server_is_not_polled() {
|
|
26
38
|
let t = canned_histories::single_timer("fake_timer");
|
|
27
|
-
let mh = MockPollCfg::from_resp_batches("fake_wf_id", t, [1],
|
|
39
|
+
let mh = MockPollCfg::from_resp_batches("fake_wf_id", t, [1], mock_worker_client());
|
|
28
40
|
let mut mock = build_mock_pollers(mh);
|
|
29
41
|
// Just so we don't have to deal w/ cache overflow
|
|
30
42
|
mock.worker_cfg(|cfg| cfg.max_cached_workflows = 1);
|
|
@@ -49,7 +61,7 @@ static BARR: LazyLock<Barrier> = LazyLock::new(|| Barrier::new(3));
|
|
|
49
61
|
|
|
50
62
|
#[tokio::test]
|
|
51
63
|
async fn shutdown_interrupts_both_polls() {
|
|
52
|
-
let mut mock_client =
|
|
64
|
+
let mut mock_client = mock_manual_worker_client();
|
|
53
65
|
mock_client
|
|
54
66
|
.expect_poll_activity_task()
|
|
55
67
|
.times(1)
|
|
@@ -98,3 +110,26 @@ async fn shutdown_interrupts_both_polls() {
|
|
|
98
110
|
}
|
|
99
111
|
};
|
|
100
112
|
}
|
|
113
|
+
|
|
114
|
+
#[tokio::test]
|
|
115
|
+
async fn ignores_workflow_options_updated_event() {
|
|
116
|
+
temporal_sdk_core_test_utils::init_integ_telem();
|
|
117
|
+
|
|
118
|
+
let mut t = TestHistoryBuilder::default();
|
|
119
|
+
t.add_by_type(EventType::WorkflowExecutionStarted);
|
|
120
|
+
t.add(WorkflowExecutionOptionsUpdatedEventAttributes::default());
|
|
121
|
+
t.last_event().unwrap().worker_may_ignore = true;
|
|
122
|
+
t.add_full_wf_task();
|
|
123
|
+
|
|
124
|
+
let mock = mock_worker_client();
|
|
125
|
+
let mut mock = single_hist_mock_sg("whatever", t, [1], mock, true);
|
|
126
|
+
mock.worker_cfg(|w| w.max_cached_workflows = 1);
|
|
127
|
+
let core = mock_worker(mock);
|
|
128
|
+
let act = core.poll_workflow_activation().await.unwrap();
|
|
129
|
+
assert_matches!(
|
|
130
|
+
act.jobs.as_slice(),
|
|
131
|
+
[WorkflowActivationJob {
|
|
132
|
+
variant: Some(workflow_activation_job::Variant::InitializeWorkflow(_)),
|
|
133
|
+
}]
|
|
134
|
+
);
|
|
135
|
+
}
|
|
@@ -3,7 +3,10 @@ use crate::{
|
|
|
3
3
|
MockPollCfg, MocksHolder, ResponseType, WorkerExt, build_mock_pollers, canned_histories,
|
|
4
4
|
hist_to_poll_resp, mock_worker, single_hist_mock_sg,
|
|
5
5
|
},
|
|
6
|
-
worker::{
|
|
6
|
+
worker::{
|
|
7
|
+
LEGACY_QUERY_ID,
|
|
8
|
+
client::{LegacyQueryResult, mocks::mock_worker_client},
|
|
9
|
+
},
|
|
7
10
|
};
|
|
8
11
|
use futures_util::stream;
|
|
9
12
|
use std::{
|
|
@@ -25,7 +28,7 @@ use temporal_sdk_core_protos::{
|
|
|
25
28
|
},
|
|
26
29
|
temporal::api::{
|
|
27
30
|
common::v1::Payload,
|
|
28
|
-
enums::v1::{CommandType, EventType},
|
|
31
|
+
enums::v1::{CommandType, EventType, WorkflowTaskFailedCause},
|
|
29
32
|
failure::v1::Failure,
|
|
30
33
|
history::v1::{ActivityTaskCancelRequestedEventAttributes, History, history_event},
|
|
31
34
|
query::v1::WorkflowQuery,
|
|
@@ -64,7 +67,7 @@ async fn legacy_query(#[case] include_history: bool) {
|
|
|
64
67
|
},
|
|
65
68
|
hist_to_poll_resp(&t, wfid.to_owned(), 2.into()),
|
|
66
69
|
];
|
|
67
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
70
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
68
71
|
mock.num_expected_legacy_query_resps = 1;
|
|
69
72
|
let mut mock = build_mock_pollers(mock);
|
|
70
73
|
if !include_history {
|
|
@@ -156,9 +159,9 @@ async fn new_queries(#[values(1, 3)] num_queries: usize) {
|
|
|
156
159
|
}
|
|
157
160
|
pr
|
|
158
161
|
}]);
|
|
159
|
-
let mut mock_client =
|
|
162
|
+
let mut mock_client = mock_worker_client();
|
|
160
163
|
mock_client.expect_respond_legacy_query().times(0);
|
|
161
|
-
let mut mh = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
164
|
+
let mut mh = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
162
165
|
mh.completion_mock_fn = Some(Box::new(move |c| {
|
|
163
166
|
// If the completion is the one ending the workflow, make sure it includes the query resps
|
|
164
167
|
if c.commands[0].command_type() == CommandType::CompleteWorkflowExecution {
|
|
@@ -235,7 +238,7 @@ async fn legacy_query_failure_on_wft_failure() {
|
|
|
235
238
|
pr.history = Some(History { events: vec![] });
|
|
236
239
|
pr
|
|
237
240
|
}]);
|
|
238
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
241
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
239
242
|
mock.num_expected_legacy_query_resps = 1;
|
|
240
243
|
let mut mock = build_mock_pollers(mock);
|
|
241
244
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 10);
|
|
@@ -298,8 +301,14 @@ async fn query_failure_because_nondeterminism(#[values(true, false)] legacy: boo
|
|
|
298
301
|
}
|
|
299
302
|
pr
|
|
300
303
|
}];
|
|
301
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
304
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
302
305
|
if legacy {
|
|
306
|
+
mock.expect_legacy_query_matcher = Box::new(|_, f| match f {
|
|
307
|
+
LegacyQueryResult::Failed(f) => {
|
|
308
|
+
f.force_cause() == WorkflowTaskFailedCause::NonDeterministicError
|
|
309
|
+
}
|
|
310
|
+
_ => false,
|
|
311
|
+
});
|
|
303
312
|
mock.num_expected_legacy_query_resps = 1;
|
|
304
313
|
} else {
|
|
305
314
|
mock.num_expected_fails = 1;
|
|
@@ -350,7 +359,7 @@ async fn legacy_query_after_complete(#[values(false, true)] full_history: bool)
|
|
|
350
359
|
};
|
|
351
360
|
tasks.extend([query_with_hist_task.clone(), query_with_hist_task]);
|
|
352
361
|
|
|
353
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
362
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
354
363
|
mock.num_expected_legacy_query_resps = 2;
|
|
355
364
|
let mut mock = build_mock_pollers(mock);
|
|
356
365
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 10);
|
|
@@ -443,7 +452,7 @@ async fn query_cache_miss_causes_page_fetch_dont_reply_wft_too_early(
|
|
|
443
452
|
);
|
|
444
453
|
pr
|
|
445
454
|
}]);
|
|
446
|
-
let mut mock_client =
|
|
455
|
+
let mut mock_client = mock_worker_client();
|
|
447
456
|
if !matches!(hist_type, QueryHists::Full) {
|
|
448
457
|
mock_client
|
|
449
458
|
.expect_get_workflow_execution_history()
|
|
@@ -534,7 +543,7 @@ async fn query_replay_with_continue_as_new_doesnt_reply_empty_command() {
|
|
|
534
543
|
pr
|
|
535
544
|
};
|
|
536
545
|
let tasks = VecDeque::from(vec![query_with_hist_task]);
|
|
537
|
-
let mut mock_client =
|
|
546
|
+
let mut mock_client = mock_worker_client();
|
|
538
547
|
mock_client
|
|
539
548
|
.expect_complete_workflow_task()
|
|
540
549
|
.times(1)
|
|
@@ -618,7 +627,7 @@ async fn legacy_query_response_gets_not_found_not_fatal() {
|
|
|
618
627
|
});
|
|
619
628
|
pr
|
|
620
629
|
}];
|
|
621
|
-
let mut mock =
|
|
630
|
+
let mut mock = mock_worker_client();
|
|
622
631
|
mock.expect_respond_legacy_query()
|
|
623
632
|
.times(1)
|
|
624
633
|
.returning(move |_, _| Err(tonic::Status::not_found("Query gone boi")));
|
|
@@ -671,7 +680,7 @@ async fn new_query_fail() {
|
|
|
671
680
|
);
|
|
672
681
|
pr
|
|
673
682
|
}]);
|
|
674
|
-
let mut mock_client =
|
|
683
|
+
let mut mock_client = mock_worker_client();
|
|
675
684
|
mock_client
|
|
676
685
|
.expect_complete_workflow_task()
|
|
677
686
|
.times(1)
|
|
@@ -774,7 +783,7 @@ async fn legacy_query_combined_with_timer_fire_repro() {
|
|
|
774
783
|
pr
|
|
775
784
|
},
|
|
776
785
|
];
|
|
777
|
-
let mut mock =
|
|
786
|
+
let mut mock = mock_worker_client();
|
|
778
787
|
mock.expect_respond_legacy_query()
|
|
779
788
|
.times(1)
|
|
780
789
|
.returning(move |_, _| Ok(Default::default()));
|
|
@@ -875,9 +884,9 @@ async fn build_id_set_properly_on_query_on_first_task() {
|
|
|
875
884
|
);
|
|
876
885
|
pr
|
|
877
886
|
}]);
|
|
878
|
-
let mut mock_client =
|
|
887
|
+
let mut mock_client = mock_worker_client();
|
|
879
888
|
mock_client.expect_respond_legacy_query().times(0);
|
|
880
|
-
let mh = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
889
|
+
let mh = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
881
890
|
let mut mock = build_mock_pollers(mh);
|
|
882
891
|
mock.worker_cfg(|wc| {
|
|
883
892
|
wc.max_cached_workflows = 10;
|
|
@@ -962,7 +971,7 @@ async fn queries_arent_lost_in_buffer_void(#[values(false, true)] buffered_becau
|
|
|
962
971
|
hist_to_poll_resp(&t, wfid.to_owned(), 2.into()),
|
|
963
972
|
]);
|
|
964
973
|
|
|
965
|
-
let mut mock =
|
|
974
|
+
let mut mock = mock_worker_client();
|
|
966
975
|
mock.expect_complete_workflow_task()
|
|
967
976
|
.returning(|_| Ok(Default::default()));
|
|
968
977
|
mock.expect_respond_legacy_query()
|
|
@@ -3,7 +3,7 @@ use crate::{
|
|
|
3
3
|
MockPollCfg, ResponseType, build_fake_sdk, build_mock_pollers, canned_histories,
|
|
4
4
|
hist_to_poll_resp, mock_worker,
|
|
5
5
|
},
|
|
6
|
-
worker::{LEGACY_QUERY_ID, client::mocks::
|
|
6
|
+
worker::{LEGACY_QUERY_ID, client::mocks::mock_worker_client},
|
|
7
7
|
};
|
|
8
8
|
use rstest::{fixture, rstest};
|
|
9
9
|
use std::{collections::VecDeque, time::Duration};
|
|
@@ -94,7 +94,7 @@ async fn replay_flag_correct_with_query() {
|
|
|
94
94
|
},
|
|
95
95
|
hist_to_poll_resp(&t, wfid.to_owned(), 2.into()),
|
|
96
96
|
]);
|
|
97
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks,
|
|
97
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, tasks, mock_worker_client());
|
|
98
98
|
mock.num_expected_legacy_query_resps = 1;
|
|
99
99
|
let mut mock = build_mock_pollers(mock);
|
|
100
100
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 10);
|
|
@@ -139,7 +139,7 @@ async fn replay_flag_correct_signal_before_query_ending_on_wft_completed() {
|
|
|
139
139
|
pr
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
let mut mock = MockPollCfg::from_resp_batches(wfid, t, [task],
|
|
142
|
+
let mut mock = MockPollCfg::from_resp_batches(wfid, t, [task], mock_worker_client());
|
|
143
143
|
mock.num_expected_legacy_query_resps = 1;
|
|
144
144
|
let mut mock = build_mock_pollers(mock);
|
|
145
145
|
mock.worker_cfg(|wc| wc.max_cached_workflows = 10);
|
|
@@ -4,7 +4,7 @@ use crate::{
|
|
|
4
4
|
MockPollCfg, PollWFTRespExt, ResponseType, build_mock_pollers, hist_to_poll_resp,
|
|
5
5
|
mock_worker,
|
|
6
6
|
},
|
|
7
|
-
worker::client::mocks::
|
|
7
|
+
worker::client::mocks::mock_worker_client,
|
|
8
8
|
};
|
|
9
9
|
use temporal_sdk_core_api::Worker;
|
|
10
10
|
use temporal_sdk_core_protos::{
|
|
@@ -108,7 +108,7 @@ async fn initial_request_sent_back(#[values(false, true)] reject: bool) {
|
|
|
108
108
|
let mut poll_resp = hist_to_poll_resp(&t, wfid, ResponseType::AllHistory);
|
|
109
109
|
let upd_req_body = poll_resp.add_update_request(update_id, 1);
|
|
110
110
|
|
|
111
|
-
let mut mock_client =
|
|
111
|
+
let mut mock_client = mock_worker_client();
|
|
112
112
|
mock_client
|
|
113
113
|
.expect_complete_workflow_task()
|
|
114
114
|
.times(1)
|
|
@@ -171,7 +171,7 @@ async fn speculative_wft_with_command_event() {
|
|
|
171
171
|
EventType::ActivityTaskScheduled as i32
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
let mock_client =
|
|
174
|
+
let mock_client = mock_worker_client();
|
|
175
175
|
let mut mh = MockPollCfg::from_resp_batches(
|
|
176
176
|
wfid,
|
|
177
177
|
real_hist,
|
|
@@ -8,7 +8,7 @@ use crate::{
|
|
|
8
8
|
self,
|
|
9
9
|
client::{
|
|
10
10
|
MockWorkerClient,
|
|
11
|
-
mocks::{DEFAULT_TEST_CAPABILITIES, DEFAULT_WORKERS_REGISTRY,
|
|
11
|
+
mocks::{DEFAULT_TEST_CAPABILITIES, DEFAULT_WORKERS_REGISTRY, mock_worker_client},
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
};
|
|
@@ -106,7 +106,7 @@ async fn worker_shutdown_during_poll_doesnt_deadlock() {
|
|
|
106
106
|
))
|
|
107
107
|
});
|
|
108
108
|
let mw = MockWorkerInputs::new(stream.boxed());
|
|
109
|
-
let mut mock_client =
|
|
109
|
+
let mut mock_client = mock_worker_client();
|
|
110
110
|
mock_client
|
|
111
111
|
.expect_complete_workflow_task()
|
|
112
112
|
.returning(|_| Ok(RespondWorkflowTaskCompletedResponse::default()));
|
|
@@ -126,7 +126,7 @@ async fn worker_shutdown_during_poll_doesnt_deadlock() {
|
|
|
126
126
|
#[tokio::test]
|
|
127
127
|
async fn can_shutdown_local_act_only_worker_when_act_polling() {
|
|
128
128
|
let t = canned_histories::single_timer("1");
|
|
129
|
-
let mock =
|
|
129
|
+
let mock = mock_worker_client();
|
|
130
130
|
let mh = MockPollCfg::from_resp_batches("fakeid", t, [1], mock);
|
|
131
131
|
let mut mock = build_mock_pollers(mh);
|
|
132
132
|
mock.worker_cfg(|w| {
|
|
@@ -166,7 +166,7 @@ async fn can_shutdown_local_act_only_worker_when_act_polling() {
|
|
|
166
166
|
#[tokio::test]
|
|
167
167
|
async fn complete_with_task_not_found_during_shutdown() {
|
|
168
168
|
let t = canned_histories::single_timer("1");
|
|
169
|
-
let mut mock =
|
|
169
|
+
let mut mock = mock_worker_client();
|
|
170
170
|
mock.expect_complete_workflow_task()
|
|
171
171
|
.times(1)
|
|
172
172
|
.returning(|_| Err(tonic::Status::not_found("Workflow task not found.")));
|
|
@@ -209,7 +209,7 @@ async fn complete_eviction_after_shutdown_doesnt_panic() {
|
|
|
209
209
|
"fakeid",
|
|
210
210
|
t,
|
|
211
211
|
[1],
|
|
212
|
-
|
|
212
|
+
mock_worker_client(),
|
|
213
213
|
));
|
|
214
214
|
mh.make_wft_stream_interminable();
|
|
215
215
|
let core = mock_worker(mh);
|
|
@@ -236,7 +236,7 @@ async fn complete_eviction_after_shutdown_doesnt_panic() {
|
|
|
236
236
|
#[tokio::test]
|
|
237
237
|
async fn worker_does_not_panic_on_retry_exhaustion_of_nonfatal_net_err() {
|
|
238
238
|
let t = canned_histories::single_timer("1");
|
|
239
|
-
let mut mock =
|
|
239
|
+
let mut mock = mock_worker_client();
|
|
240
240
|
// Return a failure that counts as retryable, and hence we want to be swallowed
|
|
241
241
|
mock.expect_complete_workflow_task()
|
|
242
242
|
.times(1)
|
|
@@ -264,7 +264,7 @@ async fn worker_does_not_panic_on_retry_exhaustion_of_nonfatal_net_err() {
|
|
|
264
264
|
#[rstest::rstest]
|
|
265
265
|
#[tokio::test]
|
|
266
266
|
async fn worker_can_shutdown_after_never_polling_ok(#[values(true, false)] poll_workflow: bool) {
|
|
267
|
-
let mut mock =
|
|
267
|
+
let mut mock = mock_worker_client();
|
|
268
268
|
mock.expect_poll_activity_task()
|
|
269
269
|
.returning(|_, _| Err(tonic::Status::permission_denied("you shall not pass")));
|
|
270
270
|
if poll_workflow {
|
|
@@ -314,6 +314,8 @@ async fn worker_shutdown_api(#[case] use_cache: bool, #[case] api_success: bool)
|
|
|
314
314
|
mock.expect_is_mock().returning(|| true);
|
|
315
315
|
mock.expect_sdk_name_and_version()
|
|
316
316
|
.returning(|| ("test-core".to_string(), "0.0.0".to_string()));
|
|
317
|
+
mock.expect_get_identity()
|
|
318
|
+
.returning(|| "test-identity".to_string());
|
|
317
319
|
if use_cache {
|
|
318
320
|
if api_success {
|
|
319
321
|
mock.expect_shutdown_worker()
|