Skip to content

test(amber): add unit test coverage for ExecutionUtils#4570

Merged
aglinxinyuan merged 4 commits intoapache:mainfrom
aglinxinyuan:xinyuan-test-execution-utils-spec
Apr 30, 2026
Merged

test(amber): add unit test coverage for ExecutionUtils#4570
aglinxinyuan merged 4 commits intoapache:mainfrom
aglinxinyuan:xinyuan-test-execution-utils-spec

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Add ExecutionUtilsSpec covering the three pure aggregator functions exposed by ExecutionUtils (amber/src/main/scala/org/apache/texera/amber/engine/architecture/controller/execution/ExecutionUtils.scala):

  • aggregateStates — empty, all-completed, all-terminated, has-running, all-uninitialized, all-paused, all-ready (maps to RUNNING), and mixed (UNKNOWN)
  • aggregatePortMetrics — empty, single mapping, sum on same port, group by port id when ports differ
  • aggregateMetrics — empty defaults, scalar sums and per-port merges across operators, and internal-port filtering

Any related issues, documentation, discussions?

Closes #4569

How was this PR tested?

sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.controller.execution.ExecutionUtilsSpec" — 15/15 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 `ExecutionUtilsSpec` covering the three pure aggregator functions
exposed by `ExecutionUtils`:

- `aggregateStates` — empty, all-completed, all-terminated,
  has-running, all-uninitialized, all-paused, all-ready (maps to
  RUNNING), and mixed (UNKNOWN)
- `aggregatePortMetrics` — empty, single mapping, sum on same port,
  group by port id when ports differ
- `aggregateMetrics` — empty defaults, scalar sums and per-port merges
  across operators, and internal-port filtering

### Any related issues, documentation, discussions?

Closes apache#4569

### How was this PR tested?

`sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.controller.execution.ExecutionUtilsSpec"` — 15/15 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.

can you add some anti cases that should be prevented?

Address review feedback on PR apache#4570: cover defensive and precedence
cases that previously had no assertions.

aggregateStates:
- mixed completed + terminated falls through to UNKNOWN (neither
  forall branch matches)
- running takes precedence over completed and terminated; single
  running input also resolves to RUNNING
- no-completed inputs still classify as PAUSED / UNINITIALIZED /
  RUNNING (all-ready)
- a value matching none of the sentinels resolves to UNKNOWN rather
  than being silently classified

aggregatePortMetrics:
- three or more mappings on the same port are summed without loss
- multiple ports each with multiple mappings are summed
  independently per port
- a zero-count, zero-size mapping is preserved, not dropped

aggregateMetrics:
- a single operator's statistics are preserved (modulo internal-port
  filtering)
- a running + completed operator pair aggregates to RUNNING
- two completed operators aggregate to COMPLETED with summed scalars
- operators with empty per-port stats coexist with non-empty operators
  while scalar sums still update
@aglinxinyuan
Copy link
Copy Markdown
Contributor Author

aglinxinyuan commented Apr 30, 2026

Thanks for the review @Yicong-Huang. Pushed 3675f94 with 11 additional cases (15 → 26 tests, all passing):

aggregateStates — defensive / precedence:

  • Mixed completed + terminated falls through to UNKNOWN (neither forall branch matches; surfaces a subtle contract that "completed and terminated together" is not the same as "all completed").
  • Running takes precedence over completed/terminated; single running also resolves to RUNNING.
  • No-completed inputs still classify as PAUSED / UNINITIALIZED / RUNNING (all-ready).
  • A value matching none of the sentinels resolves to UNKNOWN rather than being silently classified.

aggregatePortMetrics:

  • Three+ mappings on the same port summed without loss.
  • Multiple ports each with multiple mappings summed independently per port.
  • Zero-count, zero-size mapping preserved, not dropped.

aggregateMetrics:

  • Single operator's stats preserved (modulo internal-port filter).
  • Running + completed pair → RUNNING.
  • All-completed → COMPLETED with summed scalars.
  • Operators with empty per-port stats coexist with non-empty ones while scalars still sum.

@aglinxinyuan aglinxinyuan enabled auto-merge (squash) April 30, 2026 22:53
@aglinxinyuan aglinxinyuan merged commit 20cce23 into apache:main Apr 30, 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.

test(amber): add unit test coverage for ExecutionUtils

2 participants