Skip to content

test(amber): add unit test coverage for PauseType#4914

Merged
aglinxinyuan merged 6 commits into
apache:mainfrom
aglinxinyuan:test-pause-type-spec
May 4, 2026
Merged

test(amber): add unit test coverage for PauseType#4914
aglinxinyuan merged 6 commits into
apache:mainfrom
aglinxinyuan:test-pause-type-spec

Conversation

@aglinxinyuan
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan commented May 4, 2026

What changes were proposed in this PR?

Adds PauseTypeSpec covering PauseType (amber/src/main/scala/org/apache/texera/amber/engine/architecture/worker/PauseType.scala), the small sealed trait used by the worker pause subsystem (three singleton kinds + one case-class subtype). It has no test coverage today.

The new spec pins:

  • The three pause singletons (UserPause, BackpressurePause, OperatorLogicPause) extend PauseType, are object-identity stable, and compare unequal to each other (widened to PauseType so the comparison is not folded away at compile time).
  • ECMPause is a case class that carries the EmbeddedControlMessageIdentity it was constructed with, supports value equality and consistent hashCode by id, and is distinct from every singleton PauseType.
  • Exhaustive match over PauseType distinguishes each subtype.
  • Set-based coexistence (the contract PauseManager actually relies on, since it stores active pauses in a HashSet[PauseType] with no priority): all four pause kinds coexist as distinct Set elements; identical pauses deduplicate (singletons collapse, same-id ECMPause collapses); ECMPause instances with different ids are independently tracked.

The multi-pause behavior through PauseManager.pause/resume/isPaused is covered separately in WorkerManagersSpec.

No production code changed; this is test-only.

Any related issues, documentation, discussions?

Closes #4913

How was this PR tested?

Added 10 new unit tests in PauseTypeSpec. Verified locally:

sbt 'WorkflowExecutionService/Test/testOnly org.apache.texera.amber.engine.architecture.worker.PauseTypeSpec'
# → Tests: succeeded 10, failed 0

sbt 'WorkflowExecutionService/Test/scalafmtCheck'
# → clean

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

Generated-by: Claude Code

Pin the sealed-trait contract for `PauseType`:
- The three pause singletons (UserPause, BackpressurePause,
  OperatorLogicPause) extend `PauseType`, are object-identity stable,
  and compare unequal to each other when widened to the trait.
- `ECMPause` is a case class that carries the
  `EmbeddedControlMessageIdentity` it was constructed with, supports
  value equality and consistent hashCode by id, and is distinct from
  every singleton PauseType.
- Exhaustive pattern matching distinguishes each subtype and ECMPause's
  id field destructures via match.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds focused unit coverage for PauseType, the sealed trait used by Amber's worker pause subsystem, to pin its subtype/equality/matching behavior and prevent regressions in this small but important control-flow contract.

Changes:

  • Added a new PauseTypeSpec covering the three singleton pause variants and the ECMPause case class.
  • Added assertions for identity/equality semantics, subtype distinctness, and exhaustive pattern matching/destructuring behavior.
  • Scoped the change entirely to tests; no production code was modified.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.59%. Comparing base (1c6021c) to head (a3a4906).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4914      +/-   ##
============================================
+ Coverage     42.04%   47.59%   +5.54%     
+ Complexity     2156     2150       -6     
============================================
  Files           980      817     -163     
  Lines         36292    25940   -10352     
  Branches       3783     2343    -1440     
============================================
- Hits          15259    12345    -2914     
+ Misses        20110    12845    -7265     
+ Partials        923      750     -173     
Flag Coverage Δ
amber 42.86% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…Spec

Address Yicong-Huang's review on apache#4914: the "destructure ECMPause's id
via match" test is redundant — the same `id` access is already covered
by "should carry the EmbeddedControlMessageIdentity it was constructed
with" (constructor → field) and "should support exhaustive pattern
matching" (the match itself). Drop it.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Address Yicong-Huang's review on apache#4914 about pause priorities. PauseType
itself has no priority — `PauseManager` stores active pauses in a
`HashSet[PauseType]` (additive, no override order; resuming one type
only removes that type). The data type's job is to behave well as Set
elements; the multi-pause behavior through `pause`/`resume`/`isPaused`
lives in `WorkerManagersSpec`.

Add three Set-based tests pinning what PauseManager actually relies on:
- All four pause kinds coexist as distinct Set elements (no aliasing).
- Set deduplicates identical pauses (singletons collapse, same-id
  ECMPause collapses), so PauseManager.pause(t) on a duplicate is a no-op.
- ECMPause instances with different ids are independently tracked, so
  resuming one checkpoint pause does not clear another.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Address Copilot feedback on apache#4914:
- Remove the "all extend the sealed trait PauseType" test entirely.
  Its `all: List[PauseType] = ...` ascription already proves the subtype
  relationship at compile time; the runtime `isInstanceOf` check could
  never fail (the file would not compile if it did). Replaced with a
  short comment block documenting the design choice for future
  maintainers.
- Drop the redundant `assert(p.isInstanceOf[PauseType])` from the
  ECMPause-vs-singleton cross-kind inequality test, for the same reason.
  Renamed the test to "not equal any of the singleton PauseTypes" so the
  assertion list matches the description.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aglinxinyuan aglinxinyuan merged commit 810263c into apache:main May 4, 2026
13 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 PauseType

4 participants