Skip to content

test(amber): add unit test coverage for WorkflowExecution#4572

Merged
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:xinyuan-test-workflow-execution-spec
May 1, 2026
Merged

test(amber): add unit test coverage for WorkflowExecution#4572
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:xinyuan-test-workflow-execution-spec

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Add WorkflowExecutionSpec covering the lifecycle and lookup contract of WorkflowExecution (amber/src/main/scala/org/apache/texera/amber/engine/architecture/controller/execution/WorkflowExecution.scala):

  • initRegionExecution creates a new RegionExecution; throws on re-init for the same region id
  • hasRegionExecution reflects init state
  • getRegionExecution throws NoSuchElementException for unknown ids
  • getAllRegionExecutions preserves insertion order (LinkedHashMap)
  • restartRegionExecution behaves like a fresh init when no prior region exists, and replaces a completed region with a fresh execution
  • getRunningRegionExecutions excludes completed regions
  • getState returns UNINITIALIZED on empty and COMPLETED when every initialized region is completed
  • getLatestOperatorExecutionOption returns None when none exists and the latest match across regions otherwise (uses reference identity because OperatorExecution is a no-field case class)

Any related issues, documentation, discussions?

Closes #4571

How was this PR tested?

sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.controller.execution.WorkflowExecutionSpec" — 12/12 tests pass.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.7)

### What changes were proposed in this PR?

Add `WorkflowExecutionSpec` covering the lifecycle and lookup contract
of `WorkflowExecution`:

- `initRegionExecution` creates a new `RegionExecution`; throws on
  re-init for the same region id
- `hasRegionExecution` reflects init state
- `getRegionExecution` throws `NoSuchElementException` for unknown ids
- `getAllRegionExecutions` preserves insertion order (LinkedHashMap)
- `restartRegionExecution` behaves like a fresh init when no prior
  region exists, and replaces a completed region with a fresh execution
- `getRunningRegionExecutions` excludes completed regions
- `getState` returns UNINITIALIZED on empty and COMPLETED when every
  initialized region is completed
- `getLatestOperatorExecutionOption` returns None when none exists and
  the latest match across regions otherwise (uses reference identity
  because `OperatorExecution` is a no-field case class)

### Any related issues, documentation, discussions?

Closes apache#4571

### How was this PR tested?

`sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.controller.execution.WorkflowExecutionSpec"` — 12/12 tests pass.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 4.7)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks. Tests look good, but I identified many todos in source code. That's why we needed those test cases!

@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 1, 2026 03:19
@aglinxinyuan aglinxinyuan merged commit 44bc12f into apache:main May 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for WorkflowExecution

2 participants