Skip to content
Draft
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
38 changes: 38 additions & 0 deletions temporalio/test/testing/workflow_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,43 @@ def test_start_local_search_attributes
assert_equal attrs, handle.describe.search_attributes
end
end

class SimpleWorkflow < Temporalio::Workflow::Definition
def execute(input)
Temporalio::Workflow.wait_condition { @complete }
input
end

workflow_signal
def complete
@complete = true
end
end

def test_multiple_local_servers
# Start 20 local servers
envs = 20.times.map { Temporalio::Testing::WorkflowEnvironment.start_local }

# Run workers for each
tq_prefix = "tq-#{SecureRandom.uuid}-"
workers = envs.map.with_index do |env, i|
Temporalio::Worker.new(client: env.client, task_queue: "#{tq_prefix}#{i}", workflows: [SimpleWorkflow])
end
Temporalio::Worker.run_all(*workers) do
# Start all workflows
handles = envs.map.with_index do |env, i|
env.client.start_workflow(
SimpleWorkflow, "input-#{i}",
id: "wf-#{SecureRandom.uuid}", task_queue: "#{tq_prefix}#{i}"
)
end
# Signal all workflows
handles.each { |h| h.signal(SimpleWorkflow.complete) }
# Confirm results
assert_equal envs.map.with_index { |_, i| "input-#{i}" }, handles.map(&:result)
end
ensure
envs.each(&:shutdown)
end
end
end
Loading