@temporalio/core-bridge 1.13.0 → 1.13.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.
Files changed (181) hide show
  1. package/Cargo.lock +239 -382
  2. package/Cargo.toml +11 -11
  3. package/lib/native.d.ts +10 -3
  4. package/package.json +3 -3
  5. package/releases/aarch64-apple-darwin/index.node +0 -0
  6. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  7. package/releases/x86_64-apple-darwin/index.node +0 -0
  8. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  9. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  10. package/sdk-core/.cargo/config.toml +71 -11
  11. package/sdk-core/.clippy.toml +1 -0
  12. package/sdk-core/.github/workflows/heavy.yml +2 -0
  13. package/sdk-core/.github/workflows/per-pr.yml +50 -18
  14. package/sdk-core/ARCHITECTURE.md +44 -48
  15. package/sdk-core/Cargo.toml +26 -7
  16. package/sdk-core/README.md +4 -0
  17. package/sdk-core/arch_docs/diagrams/TimerMachine_Coverage.puml +14 -0
  18. package/sdk-core/arch_docs/diagrams/initial_event_history.png +0 -0
  19. package/sdk-core/arch_docs/sdks_intro.md +299 -0
  20. package/sdk-core/client/Cargo.toml +8 -7
  21. package/sdk-core/client/src/callback_based.rs +1 -2
  22. package/sdk-core/client/src/lib.rs +485 -299
  23. package/sdk-core/client/src/metrics.rs +32 -8
  24. package/sdk-core/client/src/proxy.rs +124 -5
  25. package/sdk-core/client/src/raw.rs +598 -307
  26. package/sdk-core/client/src/replaceable.rs +253 -0
  27. package/sdk-core/client/src/retry.rs +9 -6
  28. package/sdk-core/client/src/worker_registry/mod.rs +19 -3
  29. package/sdk-core/client/src/workflow_handle/mod.rs +20 -17
  30. package/sdk-core/core/Cargo.toml +100 -31
  31. package/sdk-core/core/src/core_tests/activity_tasks.rs +55 -225
  32. package/sdk-core/core/src/core_tests/mod.rs +2 -8
  33. package/sdk-core/core/src/core_tests/queries.rs +3 -5
  34. package/sdk-core/core/src/core_tests/replay_flag.rs +3 -62
  35. package/sdk-core/core/src/core_tests/updates.rs +4 -5
  36. package/sdk-core/core/src/core_tests/workers.rs +4 -3
  37. package/sdk-core/core/src/core_tests/workflow_cancels.rs +10 -7
  38. package/sdk-core/core/src/core_tests/workflow_tasks.rs +28 -291
  39. package/sdk-core/core/src/ephemeral_server/mod.rs +15 -3
  40. package/sdk-core/core/src/internal_flags.rs +11 -1
  41. package/sdk-core/core/src/lib.rs +50 -36
  42. package/sdk-core/core/src/pollers/mod.rs +5 -5
  43. package/sdk-core/core/src/pollers/poll_buffer.rs +2 -2
  44. package/sdk-core/core/src/protosext/mod.rs +13 -5
  45. package/sdk-core/core/src/protosext/protocol_messages.rs +4 -11
  46. package/sdk-core/core/src/retry_logic.rs +256 -108
  47. package/sdk-core/core/src/telemetry/metrics.rs +1 -0
  48. package/sdk-core/core/src/telemetry/mod.rs +8 -2
  49. package/sdk-core/core/src/telemetry/prometheus_meter.rs +2 -2
  50. package/sdk-core/core/src/test_help/integ_helpers.rs +971 -0
  51. package/sdk-core/core/src/test_help/mod.rs +10 -1100
  52. package/sdk-core/core/src/test_help/unit_helpers.rs +218 -0
  53. package/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +42 -6
  54. package/sdk-core/core/src/worker/activities/local_activities.rs +19 -19
  55. package/sdk-core/core/src/worker/activities.rs +10 -3
  56. package/sdk-core/core/src/worker/client/mocks.rs +3 -3
  57. package/sdk-core/core/src/worker/client.rs +130 -93
  58. package/sdk-core/core/src/worker/heartbeat.rs +12 -13
  59. package/sdk-core/core/src/worker/mod.rs +31 -21
  60. package/sdk-core/core/src/worker/nexus.rs +14 -3
  61. package/sdk-core/core/src/worker/slot_provider.rs +9 -0
  62. package/sdk-core/core/src/worker/tuner.rs +159 -0
  63. package/sdk-core/core/src/worker/workflow/history_update.rs +3 -265
  64. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -54
  65. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -82
  66. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -67
  67. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -192
  68. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -43
  69. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +6 -554
  70. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -71
  71. package/sdk-core/core/src/worker/workflow/machines/nexus_operation_state_machine.rs +102 -3
  72. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +10 -539
  73. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -139
  74. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -119
  75. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +6 -63
  76. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +9 -4
  77. package/sdk-core/core/src/worker/workflow/mod.rs +5 -1
  78. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +8 -3
  79. package/sdk-core/core-api/Cargo.toml +4 -4
  80. package/sdk-core/core-api/src/envconfig.rs +153 -54
  81. package/sdk-core/core-api/src/lib.rs +68 -0
  82. package/sdk-core/core-api/src/telemetry/metrics.rs +2 -1
  83. package/sdk-core/core-api/src/telemetry.rs +13 -0
  84. package/sdk-core/core-c-bridge/Cargo.toml +13 -8
  85. package/sdk-core/core-c-bridge/include/temporal-sdk-core-c-bridge.h +184 -22
  86. package/sdk-core/core-c-bridge/src/client.rs +462 -184
  87. package/sdk-core/core-c-bridge/src/envconfig.rs +314 -0
  88. package/sdk-core/core-c-bridge/src/lib.rs +1 -0
  89. package/sdk-core/core-c-bridge/src/random.rs +4 -4
  90. package/sdk-core/core-c-bridge/src/runtime.rs +22 -23
  91. package/sdk-core/core-c-bridge/src/testing.rs +1 -4
  92. package/sdk-core/core-c-bridge/src/tests/context.rs +31 -31
  93. package/sdk-core/core-c-bridge/src/tests/mod.rs +32 -28
  94. package/sdk-core/core-c-bridge/src/tests/utils.rs +7 -7
  95. package/sdk-core/core-c-bridge/src/worker.rs +319 -66
  96. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +6 -1
  97. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +5 -5
  98. package/sdk-core/sdk/Cargo.toml +8 -2
  99. package/sdk-core/sdk/src/activity_context.rs +1 -1
  100. package/sdk-core/sdk/src/app_data.rs +1 -1
  101. package/sdk-core/sdk/src/interceptors.rs +1 -4
  102. package/sdk-core/sdk/src/lib.rs +1 -5
  103. package/sdk-core/sdk/src/workflow_context/options.rs +10 -1
  104. package/sdk-core/sdk/src/workflow_future.rs +1 -1
  105. package/sdk-core/sdk-core-protos/Cargo.toml +6 -6
  106. package/sdk-core/sdk-core-protos/build.rs +10 -23
  107. package/sdk-core/sdk-core-protos/protos/api_upstream/.github/workflows/create-release.yml +9 -1
  108. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv2.json +254 -5
  109. package/sdk-core/sdk-core-protos/protos/api_upstream/openapi/openapiv3.yaml +234 -5
  110. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/common/v1/message.proto +1 -1
  111. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/deployment/v1/message.proto +6 -0
  112. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -2
  113. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -2
  114. package/sdk-core/sdk-core-protos/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +30 -6
  115. package/sdk-core/sdk-core-protos/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  116. package/sdk-core/{test-utils → sdk-core-protos}/src/canned_histories.rs +5 -5
  117. package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -2
  118. package/sdk-core/sdk-core-protos/src/lib.rs +25 -9
  119. package/sdk-core/sdk-core-protos/src/test_utils.rs +89 -0
  120. package/sdk-core/sdk-core-protos/src/utilities.rs +14 -5
  121. package/sdk-core/tests/c_bridge_smoke_test.c +10 -0
  122. package/sdk-core/tests/cloud_tests.rs +10 -8
  123. package/sdk-core/tests/common/http_proxy.rs +134 -0
  124. package/sdk-core/{test-utils/src/lib.rs → tests/common/mod.rs} +214 -281
  125. package/sdk-core/{test-utils/src → tests/common}/workflows.rs +4 -3
  126. package/sdk-core/tests/fuzzy_workflow.rs +1 -1
  127. package/sdk-core/tests/global_metric_tests.rs +8 -7
  128. package/sdk-core/tests/heavy_tests.rs +7 -3
  129. package/sdk-core/tests/integ_tests/client_tests.rs +111 -24
  130. package/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +14 -9
  131. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +4 -4
  132. package/sdk-core/tests/integ_tests/metrics_tests.rs +114 -14
  133. package/sdk-core/tests/integ_tests/pagination_tests.rs +273 -0
  134. package/sdk-core/tests/integ_tests/polling_tests.rs +311 -93
  135. package/sdk-core/tests/integ_tests/queries_tests.rs +4 -4
  136. package/sdk-core/tests/integ_tests/update_tests.rs +13 -7
  137. package/sdk-core/tests/integ_tests/visibility_tests.rs +26 -9
  138. package/sdk-core/tests/integ_tests/worker_tests.rs +668 -13
  139. package/sdk-core/tests/integ_tests/worker_versioning_tests.rs +40 -24
  140. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +244 -11
  141. package/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +1 -1
  142. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +78 -2
  143. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +61 -2
  144. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +465 -7
  145. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +41 -2
  146. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +315 -3
  147. package/sdk-core/tests/integ_tests/workflow_tests/eager.rs +1 -1
  148. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +1990 -14
  149. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +65 -2
  150. package/sdk-core/tests/integ_tests/workflow_tests/nexus.rs +123 -23
  151. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +525 -3
  152. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +65 -16
  153. package/sdk-core/tests/integ_tests/workflow_tests/resets.rs +32 -23
  154. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +126 -5
  155. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +1 -2
  156. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +124 -8
  157. package/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +62 -2
  158. package/sdk-core/tests/integ_tests/workflow_tests.rs +67 -8
  159. package/sdk-core/tests/main.rs +26 -17
  160. package/sdk-core/tests/manual_tests.rs +5 -1
  161. package/sdk-core/tests/runner.rs +22 -40
  162. package/sdk-core/tests/shared_tests/mod.rs +1 -1
  163. package/sdk-core/tests/shared_tests/priority.rs +1 -1
  164. package/sdk-core/{core/benches/workflow_replay.rs → tests/workflow_replay_bench.rs} +10 -5
  165. package/src/client.rs +97 -20
  166. package/src/helpers/callbacks.rs +4 -4
  167. package/src/helpers/errors.rs +7 -1
  168. package/src/helpers/handles.rs +1 -0
  169. package/src/helpers/try_from_js.rs +4 -3
  170. package/src/lib.rs +3 -2
  171. package/src/metrics.rs +3 -0
  172. package/src/runtime.rs +5 -2
  173. package/src/worker.rs +9 -12
  174. package/ts/native.ts +13 -3
  175. package/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
  176. package/sdk-core/core/src/core_tests/child_workflows.rs +0 -281
  177. package/sdk-core/core/src/core_tests/determinism.rs +0 -318
  178. package/sdk-core/core/src/core_tests/local_activities.rs +0 -1442
  179. package/sdk-core/test-utils/Cargo.toml +0 -38
  180. package/sdk-core/test-utils/src/histfetch.rs +0 -28
  181. package/sdk-core/test-utils/src/interceptors.rs +0 -46
@@ -96,70 +96,3 @@ impl WFMachinesAdapter for CancelWorkflowMachine {
96
96
  Ok(vec![])
97
97
  }
98
98
  }
99
-
100
- #[cfg(test)]
101
- mod tests {
102
- use super::*;
103
- use crate::test_help::{MockPollCfg, build_fake_sdk, canned_histories};
104
- use std::time::Duration;
105
- use temporal_sdk::{WfContext, WfExitValue, WorkflowResult};
106
- use temporal_sdk_core_protos::{
107
- DEFAULT_WORKFLOW_TYPE,
108
- coresdk::workflow_activation::{WorkflowActivationJob, workflow_activation_job},
109
- };
110
- use temporal_sdk_core_test_utils::interceptors::ActivationAssertionsInterceptor;
111
-
112
- async fn wf_with_timer(ctx: WfContext) -> WorkflowResult<()> {
113
- ctx.timer(Duration::from_millis(500)).await;
114
- Ok(WfExitValue::Cancelled)
115
- }
116
-
117
- #[tokio::test]
118
- async fn wf_completing_with_cancelled() {
119
- let t = canned_histories::timer_wf_cancel_req_cancelled("1");
120
-
121
- let mut aai = ActivationAssertionsInterceptor::default();
122
- aai.then(|a| {
123
- assert_matches!(
124
- a.jobs.as_slice(),
125
- [WorkflowActivationJob {
126
- variant: Some(workflow_activation_job::Variant::InitializeWorkflow(_)),
127
- }]
128
- )
129
- });
130
- aai.then(|a| {
131
- assert_matches!(
132
- a.jobs.as_slice(),
133
- [
134
- WorkflowActivationJob {
135
- variant: Some(workflow_activation_job::Variant::FireTimer(_)),
136
- },
137
- WorkflowActivationJob {
138
- variant: Some(workflow_activation_job::Variant::CancelWorkflow(_)),
139
- }
140
- ]
141
- );
142
- });
143
-
144
- let mut mock_cfg = MockPollCfg::from_hist_builder(t);
145
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
146
- asserts
147
- .then(|wft| {
148
- assert_eq!(wft.commands.len(), 1);
149
- assert_matches!(wft.commands[0].command_type(), CommandType::StartTimer);
150
- })
151
- .then(move |wft| {
152
- assert_eq!(wft.commands.len(), 1);
153
- assert_matches!(
154
- wft.commands[0].command_type(),
155
- CommandType::CancelWorkflowExecution
156
- );
157
- });
158
- });
159
-
160
- let mut worker = build_fake_sdk(mock_cfg);
161
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, wf_with_timer);
162
- worker.set_worker_interceptor(aai);
163
- worker.run().await.unwrap();
164
- }
165
- }
@@ -779,199 +779,8 @@ fn convert_payloads(
779
779
  #[cfg(test)]
780
780
  mod test {
781
781
  use super::*;
782
- use crate::{
783
- internal_flags::InternalFlags,
784
- replay::TestHistoryBuilder,
785
- test_help::{MockPollCfg, build_fake_sdk, canned_histories},
786
- };
787
- use anyhow::anyhow;
788
- use rstest::{fixture, rstest};
782
+ use crate::internal_flags::InternalFlags;
789
783
  use std::{cell::RefCell, mem::discriminant, rc::Rc};
790
- use temporal_sdk::{CancellableFuture, ChildWorkflowOptions, WfContext, WorkflowResult};
791
- use temporal_sdk_core_protos::{
792
- DEFAULT_WORKFLOW_TYPE,
793
- coresdk::{
794
- child_workflow::child_workflow_result,
795
- workflow_activation::resolve_child_workflow_execution_start::Status as StartStatus,
796
- },
797
- temporal::api::history::v1::StartChildWorkflowExecutionInitiatedEventAttributes,
798
- };
799
-
800
- #[derive(Clone, Copy)]
801
- enum Expectation {
802
- Success,
803
- Failure,
804
- StartFailure,
805
- }
806
-
807
- impl Expectation {
808
- const fn try_from_u8(x: u8) -> Option<Self> {
809
- Some(match x {
810
- 0 => Self::Success,
811
- 1 => Self::Failure,
812
- 2 => Self::StartFailure,
813
- _ => return None,
814
- })
815
- }
816
- }
817
-
818
- #[fixture]
819
- fn child_workflow_happy_hist() -> MockPollCfg {
820
- let mut t = canned_histories::single_child_workflow("child-id-1");
821
- t.set_wf_input(Payload::from([Expectation::Success as u8]));
822
- MockPollCfg::from_hist_builder(t)
823
- }
824
-
825
- #[fixture]
826
- fn child_workflow_fail_hist() -> MockPollCfg {
827
- let mut t = canned_histories::single_child_workflow_fail("child-id-1");
828
- t.set_wf_input(Payload::from([Expectation::Failure as u8]));
829
- MockPollCfg::from_hist_builder(t)
830
- }
831
-
832
- async fn parent_wf(ctx: WfContext) -> WorkflowResult<()> {
833
- let expectation = Expectation::try_from_u8(ctx.get_args()[0].data[0]).unwrap();
834
- let child = ctx.child_workflow(ChildWorkflowOptions {
835
- workflow_id: "child-id-1".to_string(),
836
- workflow_type: "child".to_string(),
837
- ..Default::default()
838
- });
839
-
840
- let start_res = child.start(&ctx).await;
841
- match (expectation, &start_res.status) {
842
- (Expectation::Success | Expectation::Failure, StartStatus::Succeeded(_)) => {}
843
- (Expectation::StartFailure, StartStatus::Failed(_)) => return Ok(().into()),
844
- _ => return Err(anyhow!("Unexpected start status")),
845
- };
846
- match (
847
- expectation,
848
- start_res.into_started().unwrap().result().await.status,
849
- ) {
850
- (Expectation::Success, Some(child_workflow_result::Status::Completed(_))) => {
851
- Ok(().into())
852
- }
853
- (Expectation::Failure, _) => Ok(().into()),
854
- _ => Err(anyhow!("Unexpected child WF status")),
855
- }
856
- }
857
-
858
- #[rstest(
859
- mock_cfg,
860
- case::success(child_workflow_happy_hist()),
861
- case::failure(child_workflow_fail_hist())
862
- )]
863
- #[tokio::test]
864
- async fn single_child_workflow_until_completion(mut mock_cfg: MockPollCfg) {
865
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
866
- asserts
867
- .then(|wft| {
868
- assert_eq!(wft.commands.len(), 1);
869
- assert_matches!(
870
- wft.commands[0].command_type(),
871
- CommandType::StartChildWorkflowExecution
872
- );
873
- })
874
- .then(move |wft| {
875
- assert_eq!(wft.commands.len(), 0);
876
- })
877
- .then(move |wft| {
878
- assert_eq!(wft.commands.len(), 1);
879
- assert_matches!(
880
- wft.commands[0].command_type(),
881
- CommandType::CompleteWorkflowExecution
882
- );
883
- });
884
- });
885
-
886
- let mut worker = build_fake_sdk(mock_cfg);
887
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, parent_wf);
888
- worker.run().await.unwrap();
889
- }
890
-
891
- #[tokio::test]
892
- async fn single_child_workflow_start_fail() {
893
- let child_wf_id = "child-id-1";
894
- let mut t = TestHistoryBuilder::default();
895
- t.add_by_type(EventType::WorkflowExecutionStarted);
896
- t.set_wf_input(Payload::from([Expectation::StartFailure as u8]));
897
- t.add_full_wf_task();
898
- let initiated_event_id = t.add(StartChildWorkflowExecutionInitiatedEventAttributes {
899
- workflow_id: child_wf_id.to_owned(),
900
- workflow_type: Some("child".into()),
901
- ..Default::default()
902
- });
903
- t.add(StartChildWorkflowExecutionFailedEventAttributes {
904
- workflow_id: child_wf_id.to_owned(),
905
- initiated_event_id,
906
- cause: StartChildWorkflowExecutionFailedCause::WorkflowAlreadyExists as i32,
907
- ..Default::default()
908
- });
909
- t.add_full_wf_task();
910
- t.add_workflow_execution_completed();
911
-
912
- let mut mock_cfg = MockPollCfg::from_hist_builder(t);
913
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
914
- asserts
915
- .then(|wft| {
916
- assert_eq!(wft.commands.len(), 1);
917
- assert_matches!(
918
- wft.commands[0].command_type(),
919
- CommandType::StartChildWorkflowExecution
920
- );
921
- })
922
- .then(move |wft| {
923
- assert_eq!(wft.commands.len(), 1);
924
- assert_matches!(
925
- wft.commands[0].command_type(),
926
- CommandType::CompleteWorkflowExecution
927
- );
928
- });
929
- });
930
-
931
- let mut worker = build_fake_sdk(mock_cfg);
932
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, parent_wf);
933
- worker.run().await.unwrap();
934
- }
935
-
936
- async fn cancel_before_send_wf(ctx: WfContext) -> WorkflowResult<()> {
937
- let workflow_id = "child-id-1";
938
- let child = ctx.child_workflow(ChildWorkflowOptions {
939
- workflow_id: workflow_id.to_string(),
940
- workflow_type: "child".to_string(),
941
- ..Default::default()
942
- });
943
- let start = child.start(&ctx);
944
- start.cancel(&ctx);
945
- match start.await.status {
946
- StartStatus::Cancelled(_) => Ok(().into()),
947
- _ => Err(anyhow!("Unexpected start status")),
948
- }
949
- }
950
-
951
- #[tokio::test]
952
- async fn single_child_workflow_cancel_before_sent() {
953
- let mut t = TestHistoryBuilder::default();
954
- t.add_by_type(EventType::WorkflowExecutionStarted);
955
- t.add_full_wf_task();
956
- t.add_workflow_execution_completed();
957
-
958
- let mut mock_cfg = MockPollCfg::from_hist_builder(t);
959
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
960
- asserts.then(move |wft| {
961
- // Workflow starts and cancels the child workflow, no commands should be sent besides
962
- // workflow completion
963
- assert_eq!(wft.commands.len(), 1);
964
- assert_matches!(
965
- wft.commands[0].command_type(),
966
- CommandType::CompleteWorkflowExecution
967
- );
968
- });
969
- });
970
-
971
- let mut worker = build_fake_sdk(mock_cfg);
972
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, cancel_before_send_wf);
973
- worker.run().await.unwrap();
974
- }
975
784
 
976
785
  #[test]
977
786
  fn cancels_ignored_terminal() {
@@ -104,46 +104,3 @@ impl WFMachinesAdapter for ContinueAsNewWorkflowMachine {
104
104
  Ok(vec![])
105
105
  }
106
106
  }
107
-
108
- #[cfg(test)]
109
- mod tests {
110
- use super::*;
111
- use crate::test_help::{MockPollCfg, build_fake_sdk, canned_histories};
112
- use std::time::Duration;
113
- use temporal_sdk::{WfContext, WfExitValue, WorkflowResult};
114
- use temporal_sdk_core_protos::DEFAULT_WORKFLOW_TYPE;
115
-
116
- async fn wf_with_timer(ctx: WfContext) -> WorkflowResult<()> {
117
- ctx.timer(Duration::from_millis(500)).await;
118
- Ok(WfExitValue::continue_as_new(
119
- ContinueAsNewWorkflowExecution {
120
- arguments: vec![[1].into()],
121
- ..Default::default()
122
- },
123
- ))
124
- }
125
-
126
- #[tokio::test]
127
- async fn wf_completing_with_continue_as_new() {
128
- let t = canned_histories::timer_then_continue_as_new("1");
129
- let mut mock_cfg = MockPollCfg::from_hist_builder(t);
130
- mock_cfg.completion_asserts_from_expectations(|mut asserts| {
131
- asserts
132
- .then(|wft| {
133
- assert_eq!(wft.commands.len(), 1);
134
- assert_matches!(wft.commands[0].command_type(), CommandType::StartTimer);
135
- })
136
- .then(move |wft| {
137
- assert_eq!(wft.commands.len(), 1);
138
- assert_matches!(
139
- wft.commands[0].command_type(),
140
- CommandType::ContinueAsNewWorkflowExecution
141
- );
142
- });
143
- });
144
-
145
- let mut worker = build_fake_sdk(mock_cfg);
146
- worker.register_wf(DEFAULT_WORKFLOW_TYPE, wf_with_timer);
147
- worker.run().await.unwrap();
148
- }
149
- }