Skip to content

test(amber): add unit tests for OrderingEnforcer - #4721

Merged
aglinxinyuan merged 3 commits into
apache:mainfrom
Yicong-Huang:test-ordering-enforcer
May 3, 2026
Merged

test(amber): add unit tests for OrderingEnforcer#4721
aglinxinyuan merged 3 commits into
apache:mainfrom
Yicong-Huang:test-ordering-enforcer

Conversation

@Yicong-Huang

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds scalatest coverage for amber/src/main/scala/org/apache/texera/amber/engine/architecture/messaginglayer/OrderingEnforcer.scala. The FIFO/exactly-once helper had no dedicated spec.

Any related issues, documentation, discussions?

Closes #4720.

How was this PR tested?

sbt scalafmtCheckAll
sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.OrderingEnforcerSpec"

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

Generated-by: Claude Code (claude-opus-4-7)

@codecov-commenter

codecov-commenter commented May 3, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4721      +/-   ##
============================================
- Coverage     42.73%   41.70%   -1.04%     
- Complexity     2003     2015      +12     
============================================
  Files           957      978      +21     
  Lines         34077    34569     +492     
  Branches       3753     3779      +26     
============================================
- Hits          14564    14416     -148     
- Misses        18733    19373     +640     
  Partials        780      780              
Flag Coverage Δ
access-control-service ?
amber 40.57% <ø> (+0.07%) ⬆️
computing-unit-managing-service ?
config-service ?
file-service ?
python 84.10% <ø> (-0.06%) ⬇️
workflow-compiling-service ?

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.

Closes apache#4720

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Yicong-Huang
Yicong-Huang force-pushed the test-ordering-enforcer branch from f2a2a10 to e63887f Compare May 3, 2026 01:00
@aglinxinyuan
aglinxinyuan enabled auto-merge (squash) May 3, 2026 01:29
@aglinxinyuan
aglinxinyuan disabled auto-merge May 3, 2026 01:29
@aglinxinyuan
aglinxinyuan requested a review from Copilot May 3, 2026 01:29

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

Adds a dedicated ScalaTest spec for Amber’s OrderingEnforcer (FIFO / exactly-once helper) to improve regression protection and close the existing coverage gap noted in #4720.

Changes:

  • Introduces OrderingEnforcerSpec covering setCurrent, isDuplicated, isAhead, stash, and enforceFIFO behaviors.
  • Exercises key FIFO draining scenarios: empty stash, contiguous drain, drain-until-gap, and non-contiguous stash behavior.

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

@aglinxinyuan
aglinxinyuan enabled auto-merge (squash) May 3, 2026 01:31
@aglinxinyuan
aglinxinyuan merged commit 88c7a21 into apache:main May 3, 2026
15 checks passed
@Yicong-Huang
Yicong-Huang deleted the test-ordering-enforcer branch June 15, 2026 06:46
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
### What changes were proposed in this PR?

Adds scalatest coverage for
`amber/src/main/scala/org/apache/texera/amber/engine/architecture/messaginglayer/OrderingEnforcer.scala`.
The FIFO/exactly-once helper had no dedicated spec.

### Any related issues, documentation, discussions?

Closes apache#4720.

### How was this PR tested?

```
sbt scalafmtCheckAll
sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.OrderingEnforcerSpec"
```

### 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>
Co-authored-by: Xinyuan Lin <xinyual3@uci.edu>
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Jul 30, 2026
### What changes were proposed in this PR?

Deletes `OrderingEnforcer`, a generic helper in the amber engine with no
production caller. Pure deletion, no behaviour change: **−203 lines**.

| Removed | Lines | Why it is dead |
| --- | ---: | --- |
| `architecture/messaginglayer/OrderingEnforcer.scala` | 53 | last
caller removed by apache#2208 |
| `architecture/messaginglayer/OrderingEnforcerSpec.scala` | 150 |
covers only the above |

`OrderingEnforcer` was the extracted, generic form of the FIFO /
exactly-once reorder buffer. apache#2208 ("Refactoring of amber engine",
2023-11-15) inlined that logic into `AmberFIFOChannel`, which still
carries the identical header comment `/* The abstracted
FIFO/exactly-once logic */` and re-declares the same members:

```
OrderingEnforcer[T]  (deleted)        AmberFIFOChannel  (live, unchanged)
  ofoMap: LongMap[T]                    ofoMap: HashMap[Long, WorkflowFIFOMessage]
  current: Long                         current: Long
  isDuplicated / isAhead                isDuplicated / isAhead
  stash / enforceFIFO                   stash / enforceFIFO
```

The generic copy has been stranded for two and a half years.

> Reviewer note: there is a separate, **live** `OrderEnforcer` trait (no
`-ing`) in `architecture/logreplay/`, used by
`InputGateway`/`NetworkInputGateway`. It is unrelated and untouched —
only the `messaginglayer` `OrderingEnforcer` is removed here.

It acquired unit tests during the 2026 coverage work (apache#4721), which is
why it currently looks live despite having been unreachable since 2023.

**Scope change after review:** this PR originally also removed
`Utils.retry`. Per @Yicong-Huang's review it has been restored and is
untouched here — `Utils.scala` and `UtilsSpec.scala` are byte-identical
to `main`.

### Any related issues, documentation, discussions?

Closes apache#7027

### How was this PR tested?

Existing tests only — this PR adds none, since it removes code and the
spec that covered it.

Locally, from the repo root with Java 17:

- `sbt "scalafixAll --check"` — clean.
- `sbt scalafmtCheckAll` — clean.
- `sbt "WorkflowExecutionService/testOnly *UtilsSpec"` — 74 tests, all
pass (`Utils.retry` and its three tests are back and green).

Verification that nothing references the removed class, re-runnable by a
reviewer:

```
git grep -nw OrderingEnforcer      # only the two deleted files
```

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

Generated-by: Claude Code (Claude Opus 5)
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 tests for OrderingEnforcer

4 participants