Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ jobs:
- name: Instantiate sample project using verdaccio artifacts - Fetch ESM
run: |
node scripts/init-from-verdaccio.js --registry-dir ${{ steps.tmp-dir.outputs.dir }}/npm-registry --sample https://github.com/temporalio/samples-typescript/tree/main/fetch-esm --target-dir ${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm"
node scripts/test-example.js --work-dir "${{ steps.tmp-dir.outputs.dir }}/sample-fetch-esm" --script-name workflow-local --expected-output "Hello World And Hello Wonderful Temporal!"

# End samples

Expand Down
2 changes: 1 addition & 1 deletion packages/core-bridge/sdk-core
Submodule sdk-core updated 40 files
+2 −2 .github/workflows/per-pr.yml
+8 −0 crates/client/src/raw.rs
+512 −39 crates/client/src/worker_registry/mod.rs
+7 −0 crates/common/src/errors.rs
+2 −2 crates/common/src/lib.rs
+72 −4 crates/common/src/worker.rs
+100 −0 crates/common/tests/worker_task_types_test.rs
+7 −1 crates/sdk-core-c-bridge/include/temporal-sdk-core-c-bridge.h
+21 −2 crates/sdk-core-c-bridge/src/worker.rs
+2 −2 crates/sdk-core/src/core_tests/activity_tasks.rs
+208 −4 crates/sdk-core/src/core_tests/workers.rs
+5 −5 crates/sdk-core/src/core_tests/workflow_tasks.rs
+2 −2 crates/sdk-core/src/replay/mod.rs
+103 −15 crates/sdk-core/src/test_help/integ_helpers.rs
+2 −2 crates/sdk-core/src/worker/heartbeat.rs
+272 −175 crates/sdk-core/src/worker/mod.rs
+1 −1 crates/sdk-core/src/worker/workflow/mod.rs
+4 −3 crates/sdk-core/tests/common/mod.rs
+3 −1 crates/sdk-core/tests/heavy_tests.rs
+19 −5 crates/sdk-core/tests/integ_tests/metrics_tests.rs
+16 −5 crates/sdk-core/tests/integ_tests/update_tests.rs
+6 −2 crates/sdk-core/tests/integ_tests/worker_tests.rs
+4 −2 crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs
+8 −3 crates/sdk-core/tests/integ_tests/workflow_tests.rs
+4 −1 crates/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs
+4 −1 crates/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs
+13 −4 crates/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs
+5 −2 crates/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs
+4 −1 crates/sdk-core/tests/integ_tests/workflow_tests/determinism.rs
+7 −2 crates/sdk-core/tests/integ_tests/workflow_tests/eager.rs
+4 −1 crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs
+26 −5 crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs
+18 −6 crates/sdk-core/tests/integ_tests/workflow_tests/patches.rs
+8 −2 crates/sdk-core/tests/integ_tests/workflow_tests/resets.rs
+14 −4 crates/sdk-core/tests/integ_tests/workflow_tests/signals.rs
+6 −4 crates/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs
+14 −6 crates/sdk-core/tests/integ_tests/workflow_tests/timers.rs
+4 −1 crates/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs
+2 −1 crates/sdk-core/tests/manual_tests.rs
+4 −1 crates/sdk-core/tests/shared_tests/mod.rs
18 changes: 15 additions & 3 deletions packages/core-bridge/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ pub fn worker_complete_workflow_activation(
),
}
}
CompleteWfError::WorkflowNotEnabled => {
BridgeError::UnexpectedError(format!("{err}"))
}
})
})
}
Expand Down Expand Up @@ -225,6 +228,9 @@ pub fn worker_complete_activity_task(
field: None,
message: format!("Malformed Activity Completion: {reason:?}"),
},
CompleteActivityError::ActivityNotEnabled => {
BridgeError::UnexpectedError(format!("{err}"))
}
})
})
}
Expand Down Expand Up @@ -470,7 +476,7 @@ mod config {
ActivitySlotKind, LocalActivitySlotKind, NexusSlotKind,
PollerBehavior as CorePollerBehavior, SlotKind, WorkerConfig, WorkerConfigBuilder,
WorkerConfigBuilderError, WorkerDeploymentOptions as CoreWorkerDeploymentOptions,
WorkerDeploymentVersion as CoreWorkerDeploymentVersion, WorkflowSlotKind,
WorkerDeploymentVersion as CoreWorkerDeploymentVersion, WorkerTaskTypes, WorkflowSlotKind,
};
use temporalio_sdk_core::{
ResourceBasedSlotsOptions, ResourceBasedSlotsOptionsBuilder, ResourceSlotOptions,
Expand Down Expand Up @@ -499,7 +505,9 @@ mod config {
workflow_task_poller_behavior: PollerBehavior,
activity_task_poller_behavior: PollerBehavior,
nexus_task_poller_behavior: PollerBehavior,
enable_non_local_activities: bool,
enable_workflow_tasks: bool,
enable_activity_tasks: bool,
enable_nexus_tasks: bool,
sticky_queue_schedule_to_start_timeout: Duration,
max_cached_workflows: usize,
max_heartbeat_throttle_interval: Duration,
Expand Down Expand Up @@ -566,14 +574,18 @@ mod config {
.workflow_task_poller_behavior(self.workflow_task_poller_behavior)
.activity_task_poller_behavior(self.activity_task_poller_behavior)
.nexus_task_poller_behavior(self.nexus_task_poller_behavior)
.no_remote_activities(!self.enable_non_local_activities)
.sticky_queue_schedule_to_start_timeout(self.sticky_queue_schedule_to_start_timeout)
.max_cached_workflows(self.max_cached_workflows)
.max_heartbeat_throttle_interval(self.max_heartbeat_throttle_interval)
.default_heartbeat_throttle_interval(self.default_heartbeat_throttle_interval)
.max_task_queue_activities_per_second(self.max_task_queue_activities_per_second)
.max_worker_activities_per_second(self.max_activities_per_second)
.graceful_shutdown_period(self.shutdown_grace_time)
.task_types(WorkerTaskTypes {
enable_workflows: self.enable_workflow_tasks,
enable_activities: self.enable_activity_tasks,
enable_nexus: self.enable_nexus_tasks,
})
.build()
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core-bridge/ts/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export interface WorkerOptions {
workflowTaskPollerBehavior: PollerBehavior;
activityTaskPollerBehavior: PollerBehavior;
nexusTaskPollerBehavior: PollerBehavior;
enableNonLocalActivities: boolean;
enableWorkflowTasks: boolean;
enableActivityTasks: boolean;
enableNexusTasks: boolean;
stickyQueueScheduleToStartTimeout: number;
maxCachedWorkflows: number;
maxHeartbeatThrottleInterval: number;
Expand Down
4 changes: 3 additions & 1 deletion packages/test/src/test-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ const GenericConfigs = {
initial: 5,
maximum: 100,
},
enableNonLocalActivities: false,
enableWorkflowTasks: true,
enableActivityTasks: true,
enableNexusTasks: true,
stickyQueueScheduleToStartTimeout: 1000,
maxCachedWorkflows: 1000,
maxHeartbeatThrottleInterval: 1000,
Expand Down
2 changes: 1 addition & 1 deletion packages/test/src/test-integration-workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ test('root execution is exposed', async (t) => {
}
}
};
await waitUntil(childStarted, 5000);
await waitUntil(childStarted, 8000);
const childDesc = await childHandle.describe();
const parentDesc = await handle.describe();

Expand Down
15 changes: 11 additions & 4 deletions packages/test/src/test-prometheus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,22 @@ test.serial('Exporting Prometheus metrics from Core works with lots of options',
'temporal_workflow_task_replay_latency_seconds_bucket{namespace="default",' +
'service_name="temporal-core-sdk",task_queue="test-prometheus",' +
'workflow_type="successString",my_tag="my_value",le="0.001"}'
)
),
`Actual: \n-------\n${text}\n-------`
);

// Verify histogram overrides
t.assert(text.match(/temporal_request_latency_seconds_bucket\{.*,le="31415"/));
t.assert(text.match(/workflow_task_execution_latency_seconds_bucket\{.*,le="31415"/));
t.assert(
text.match(/temporal_request_latency_seconds_bucket\{.*,le="31415"/),
`Actual: \n-------\n${text}\n-------`
);
t.assert(
text.match(/workflow_task_execution_latency_seconds_bucket\{.*,le="31415"/),
`Actual: \n-------\n${text}\n-------`
);

// Verify prefix exists on client request metrics
t.assert(text.includes('temporal_long_request{'));
t.assert(text.includes('temporal_long_request{'), `Actual: \n-------\n${text}\n-------`);
});
} finally {
await localEnv.teardown();
Expand Down
4 changes: 3 additions & 1 deletion packages/worker/src/worker-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,9 @@ export function toNativeWorkerOptions(opts: CompiledWorkerOptionsWithBuildId): n
workflowTaskPollerBehavior: toNativeTaskPollerBehavior(opts.workflowTaskPollerBehavior),
activityTaskPollerBehavior: toNativeTaskPollerBehavior(opts.activityTaskPollerBehavior),
nexusTaskPollerBehavior: toNativeTaskPollerBehavior(opts.nexusTaskPollerBehavior),
enableNonLocalActivities: opts.enableNonLocalActivities,
enableWorkflowTasks: opts.workflowBundle !== undefined || opts.workflowsPath !== undefined,
enableActivityTasks: opts.activities.size > 0 && opts.enableNonLocalActivities,
enableNexusTasks: opts.nexusServiceRegistry !== undefined,
stickyQueueScheduleToStartTimeout: msToNumber(opts.stickyQueueScheduleToStartTimeout),
maxCachedWorkflows: opts.maxCachedWorkflows,
maxHeartbeatThrottleInterval: msToNumber(opts.maxHeartbeatThrottleInterval),
Expand Down
12 changes: 8 additions & 4 deletions scripts/test-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ async function withWorker(workdir, fn) {
}
}

async function test(workdir) {
const { status, output } = spawnSync(npm, ['run', 'workflow'], {
async function test(workdir, scriptName, expectedOutput) {
const { status, output } = spawnSync(npm, ['run', scriptName], {
cwd: workdir,
shell,
encoding: 'utf8',
Expand All @@ -33,21 +33,25 @@ async function test(workdir) {
if (status !== 0) {
throw new Error('Failed to run workflow');
}
if (!output[1].includes('Hello, Temporal!\n')) {
if (!output[1].includes(`${expectedOutput}\n`)) {
throw new Error(`Invalid output: "${output[1]}"`);
}
}

async function main() {
const opts = arg({
'--work-dir': String,
'--script-name': String,
'--expected-output': String,
});
const workdir = opts['--work-dir'];
if (!workdir) {
throw new Error('Missing required option --work-dir');
}
const scriptName = opts['--script-name'] ?? 'workflow';
const expectedOutput = opts['--expected-output'] ?? 'Hello, Temporal!';

await withWorker(workdir, () => test(workdir));
await withWorker(workdir, () => test(workdir, scriptName, expectedOutput));
}

main()
Expand Down
Loading