Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Problem: Testing Temporal Workflows with Signals in Ruby SDK Time-Skipping Environment

未关闭
#360 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
ruby
领域
testing

调研方向

使用 wait_condition、customer_replied signal 和 workflow_handle.result,重现 Temporalio::Testing::WorkflowEnvironment.start_time_skipping 中的工作流。跟踪 signal 传递和时间跳过如何恢复执行,然后比较 start_workflow 和 execute_workflow 的行为。确定原因并记录经过验证的测试方法或所需的 SDK 更改后,即视为完成。

由索引模型根据 Issue 内容生成。

描述

enhancement

Problem: Testing Temporal Workflows with Signals in Ruby SDK Time-Skipping Environment

Context

I'm testing a workflow in the Temporalio Ruby SDK that uses wait_condition to wait for signals. The workflow works correctly in production, but I cannot test the signal-driven continuation in the time-skipping test environment (Temporalio::Testing::WorkflowEnvironment.start_time_skipping).

Workflow Pattern (Simplified)

class PipelineExecutionWorkflow < Temporalio::Workflow
  workflow_signal
  def customer_replied
    @customer_replied = true
  end

  def execute(opportunity_id, pipeline_id)
    # Step 1: Send initial email
    send_email_activity(opportunity_id)
    
    # Step 2: Wait for customer reply signal
    Temporalio::Workflow.timeout(48.hours) do
      Temporalio::Workflow.wait_condition { @customer_replied }
    end
    
    # Step 3: Process customer reply (extract data, send AI response)
    if @customer_replied
      extract_and_respond(opportunity_id)
    end
    
    { "success" => true }
  end
end

What I've Tried in Tests

Temporalio::Testing::WorkflowEnvironment.start_time_skipping do |env|
  worker = Temporalio::Worker.new(
    client: env.client,
    task_queue: "test-queue",
    workflows: [PipelineExecutionWorkflow],
    activities: [SendEmailActivity, ExtractActivity]
  )
  
  worker.run do
    # Start workflow (doesn't wait for completion)
    workflow_handle = env.client.start_workflow(
      PipelineExecutionWorkflow,
      opportunity_id,
      pipeline_id,
      id: "test-pipeline-#{opportunity_id}",
      task_queue: "test-queue"
    )
    
    # Give time for initial email to be sent
    sleep 0.5
    
    # Check workflow state - shows it's waiting
    state = workflow_handle.query("get_state")
    # => {"waiting_for_signal" => true, "customer_replied" => false}
    
    # Send the signal
    workflow_handle.signal("customer_replied")
    
    # Check state again - signal was received!
    state_after = workflow_handle.query("get_state")
    # => {"waiting_for_signal" => false, "customer_replied" => true}
    
    # But when I try to get the result, it times out or returns nil
    result = workflow_handle.result  # ← TIMES OUT or returns nil
    # The workflow doesn't continue executing after receiving the signal
  end
end

Observed Behavior

  1. ✅ Workflow starts successfully
  2. ✅ Initial email activity executes
  3. ✅ Workflow enters wait state (wait_condition)
  4. ✅ Signal is received (verified via query - @customer_replied becomes true)
  5. ❌ Workflow doesn't continue execution after signal received
  6. ❌ workflow_handle.result times out or workflow appears "stuck"

Questions

With the Temporal Ruby SDK source code available:

  1. Is this a known limitation of the time-skipping test environment with wait_condition and signals?

  2. What is the correct way to test workflows that use wait_condition with signals in the time-skipping environment?

  3. Should I use a different testing approach for signal-driven workflows? (e.g., real Temporal server, different test helper methods)

  4. Is there a way to manually advance time or "wake up" the workflow after sending a signal in the test environment?

  5. Are there any special considerations or setup required for testing signal-driven workflows that use wait_condition?

Additional Context

  • Ruby SDK version: 1.0.0 (from Gemfile)
  • The workflow works perfectly in production with real Temporal server
  • Synchronous workflows (without signals/wait) test fine in time-skipping environment
  • I've tried both start_workflow (non-blocking) and execute_workflow (blocking) - neither works for the signal continuation
主要语言
Ruby
星标
206
派生
42
平均合并
1 天 48 分钟
30 天内合并 PR
16

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

temporalio/sdk-ruby 的其他 Issue

查看 temporalio/sdk-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。