Skip to content

test(amber): add unit test coverage for FutureBijection and ElidableStatement#5555

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-future-bijection-and-elidable-statement
Open

test(amber): add unit test coverage for FutureBijection and ElidableStatement#5555
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-future-bijection-and-elidable-statement

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Pin behavior of two utility modules in engine/common. No production-code changes.

Spec Source class Tests
FutureBijectionSpec FutureBijection 11
ElidableStatementSpec ElidableStatement 9

Both spec files follow the <srcClassName>Spec.scala one-to-one convention.

Behavior pinned — FutureBijection

Surface Contract
TwitterFuture.value.asScala resolves to the same value (type preserved, null preserved)
TwitterFuture.exception.asScala resolves with the same Throwable instance (type, message, eq identity)
ScalaFuture.successful.asTwitter resolves to the same value (type preserved, null preserved)
ScalaFuture.failed.asTwitter resolves with the same Throwable instance
Twitter → Scala on an already-resolved future the resulting Scala future is already completed when the implicit returns
Twitter → Scala → Twitter round-trip preserves both values and exceptions
Scala → Twitter → Scala round-trip preserves values

Behavior pinned — ElidableStatement

The texera build sets -Xelide-below WARNING (amber/build.sbt). Every ElidableStatement helper is annotated with an elide level strictly below WARNING (FINEST / FINER / FINE / INFO), so the Scala compiler replaces every CALL to these helpers with a () Unit value at compile time. The spec pins this silent-in-production contract:

Surface Contract
info / fine / finer / finest (with side-effect block) the side effect MUST NOT fire (counter stays at 0)
same methods (with throwing block) the exception MUST NOT propagate
1000 successive elided calls no side-effect accumulation
Return type Unit (compile-time enforced)
Parameter shape accepts a => Unit by-name block (compile-time enforced)

A regression that bumped a method's elide level above WARNING, removed the @elidable annotation, or relaxed -Xelide-below in the build would re-enable side effects in production — and this spec would catch it.

Any related issues, documentation, discussions?

Closes #5551.

How was this PR tested?

Pure unit-test additions; verified locally with:

  • sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.common.FutureBijectionSpec org.apache.texera.amber.engine.common.ElidableStatementSpec" — 20 tests, all green
  • sbt scalafmtCheckAll — clean
  • CI to confirm

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

Generated-by: Claude Code (Sonnet 4.5)

…tatement

Pins behavior of two utility modules in `engine/common`:
  - `FutureBijection` — implicit Twitter↔Scala Future conversions; pin
    the value and exception paths in both directions, plus
    round-trip preservation
  - `ElidableStatement` — pin the silent-in-production contract that
    every helper (FINEST/FINER/FINE/INFO) is elided under the build's
    `-Xelide-below WARNING` flag, so by-name blocks never execute

Closes apache#5551
Copilot AI review requested due to automatic review settings June 8, 2026 00:01
@github-actions github-actions Bot added the engine label Jun 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 ScalaTest unit specs under amber/src/test/scala/.../engine/common to pin and regress-test the behavior of two small but widely used utility modules (FutureBijection and ElidableStatement) in Amber’s common engine layer, without changing production code.

Changes:

  • Add FutureBijectionSpec covering Twitter Future ↔ Scala Future conversions for success/failure/null and round-trip behavior.
  • Add ElidableStatementSpec ensuring @elidable helpers remain compile-time-elided under -Xelide-below WARNING, so side-effecting/throwing blocks do not execute.

Reviewed changes

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

File Description
amber/src/test/scala/org/apache/texera/amber/engine/common/FutureBijectionSpec.scala Adds unit coverage for Twitter↔Scala Future conversions, including null/exception identity and round-trips.
amber/src/test/scala/org/apache/texera/amber/engine/common/ElidableStatementSpec.scala Adds unit coverage that elided logging helpers remain no-ops under the project’s -Xelide-below WARNING setting.

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

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.14%. Comparing base (afc5f98) to head (a297c1a).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5555      +/-   ##
============================================
+ Coverage     52.09%   52.14%   +0.04%     
- Complexity     2471     2479       +8     
============================================
  Files          1067     1067              
  Lines         41273    41273              
  Branches       4437     4437              
============================================
+ Hits          21502    21520      +18     
+ Misses        18509    18490      -19     
- Partials       1262     1263       +1     
Flag Coverage Δ *Carryforward flag
access-control-service 64.61% <ø> (ø) Carriedforward from afc5f98
agent-service 33.76% <ø> (ø) Carriedforward from afc5f98
amber 53.23% <ø> (+0.11%) ⬆️
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from afc5f98
config-service 56.06% <ø> (ø) Carriedforward from afc5f98
file-service 38.32% <ø> (ø) Carriedforward from afc5f98
frontend 46.40% <ø> (ø) Carriedforward from afc5f98
pyamber 90.69% <ø> (ø) Carriedforward from afc5f98
python 90.83% <ø> (ø) Carriedforward from afc5f98
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from afc5f98

*This pull request uses carry forward flags. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aglinxinyuan aglinxinyuan requested a review from Yicong-Huang June 8, 2026 05:22
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 FutureBijection and ElidableStatement

3 participants