Repository navigation
test(amber): add unit test coverage for InputManager - #5451
Merged
Merged
Conversation
Pins behavior of `InputManager` — the per-worker input broker that tracks WorkerPort registration, the active input batch cursor, and port-completion status. Was the only previously-uncovered module in the `messaginglayer` package. Closes apache#5450
Contributor
There was a problem hiding this comment.
Pull request overview
Adds missing unit-test coverage for InputManager in the Amber messaging layer, aligning it with the rest of the package’s existing specs and pinning expected port-registration and batch-cursor behavior.
Changes:
- Introduces
InputManagerSpec.scalawith a focused suite of unit tests covering port registration/lookup, reader-thread bookkeeping (empty URI path), batch initialization/cursor behavior, and non-materialized completion semantics. - Verifies
addPortidempotency (first call wins) and input validation (URI/partitioning size mismatch).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5451 +/- ##
============================================
+ Coverage 51.85% 51.90% +0.05%
- Complexity 2468 2473 +5
============================================
Files 1067 1067
Lines 41258 41258
Branches 4437 4437
============================================
+ Hits 21394 21415 +21
+ Misses 18607 18580 -27
- Partials 1257 1263 +6
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Address Copilot review feedback on apache#5451 — the test description says "reset the cursor" but the body only asserted `currentChannelId` and `hasUnfinishedInput`. Add the missing assertion by invoking `getNextTuple` and verifying it returns the first element of the new batch, which directly proves `currentInputIdx` was reset.
Yicong-Huang
approved these changes
Jun 7, 2026
ELin2025
pushed a commit
to ELin2025/texera
that referenced
this pull request
Jun 16, 2026
### What changes were proposed in this PR? Pin behavior of `InputManager` — the per-worker input broker that was the only previously-uncovered module in the `messaginglayer` package (every sibling — `WorkerPort`, `OutputManager`, `AmberFIFOChannel`, `CongestionControl`, `FlowControl`, `NetworkInputGateway`, `OrderingEnforcer`, `RangeBasedShuffle` — already has a spec). No production-code changes. | Spec | Source class | Tests | | --- | --- | --- | | `InputManagerSpec` | `InputManager` | 15 | Spec file name follows the `<srcClassName>Spec.scala` one-to-one convention. **Behavior pinned** | Surface | Contract | | --- | --- | | `getAllPorts` (fresh) | empty `Set` | | `addPort(portId, schema, Nil, Nil)` | registers a fresh `WorkerPort` with the supplied schema; no reader threads attached | | second `addPort` for the same `portId` | silently no-ops (first call wins; the prior `WorkerPort` survives, including any mutation to `completed`) | | `addPort` with mismatched URI / partitioning sizes | throws `AssertionError` | | `getPort(portId)` | is a pure lookup — successive calls return the same `WorkerPort` instance | | `getInputPortReaderThreads` | empty `Map` when every port was added with `urisToRead = List.empty` | | `hasUnfinishedInput` (fresh) | `false` (no batch initialized) | | `getCurrentTuple` (fresh) | `null` | | `getCurrentTuple` (empty batch) | `null` | | `hasUnfinishedInput` (empty batch) | `false` | | `initBatch(channelId, batch)` | replaces `inputBatch`, resets the cursor, surfaces the channel id via `currentChannelId` | | `getNextTuple` over a batch | yields each element in order; `getCurrentTuple` tracks the last yielded value; `hasUnfinishedInput` flips to `false` once the last element is consumed | | `initBatch` called a second time | replaces the prior batch entirely and restarts the cursor (proven by yielding the new batch's first element fresh) | | `isPortCompleted` (non-materialized) | reads through to `WorkerPort.completed` — `false` initially, `true` once flipped | | `startInputPortReaderThreads` (no threads) | safe no-op | **Notes** Materialization-reader-thread paths (non-empty `urisToRead`) are deliberately left out of this characterization. Constructing an `InputPortMaterializationReaderThread` eagerly evaluates `toPartitioner(partitioning, workerActorId)` and pulls in document-factory plumbing that is out of scope for a unit spec — those code paths are exercised in higher-level worker / replay tests. ### Any related issues, documentation, discussions? Closes apache#5450. ### How was this PR tested? Pure unit-test addition; verified locally with: - `sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.InputManagerSpec"` — 15 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)
yangzhang75
pushed a commit
to yangzhang75/texera
that referenced
this pull request
Jun 22, 2026
### What changes were proposed in this PR? Pin behavior of `InputManager` — the per-worker input broker that was the only previously-uncovered module in the `messaginglayer` package (every sibling — `WorkerPort`, `OutputManager`, `AmberFIFOChannel`, `CongestionControl`, `FlowControl`, `NetworkInputGateway`, `OrderingEnforcer`, `RangeBasedShuffle` — already has a spec). No production-code changes. | Spec | Source class | Tests | | --- | --- | --- | | `InputManagerSpec` | `InputManager` | 15 | Spec file name follows the `<srcClassName>Spec.scala` one-to-one convention. **Behavior pinned** | Surface | Contract | | --- | --- | | `getAllPorts` (fresh) | empty `Set` | | `addPort(portId, schema, Nil, Nil)` | registers a fresh `WorkerPort` with the supplied schema; no reader threads attached | | second `addPort` for the same `portId` | silently no-ops (first call wins; the prior `WorkerPort` survives, including any mutation to `completed`) | | `addPort` with mismatched URI / partitioning sizes | throws `AssertionError` | | `getPort(portId)` | is a pure lookup — successive calls return the same `WorkerPort` instance | | `getInputPortReaderThreads` | empty `Map` when every port was added with `urisToRead = List.empty` | | `hasUnfinishedInput` (fresh) | `false` (no batch initialized) | | `getCurrentTuple` (fresh) | `null` | | `getCurrentTuple` (empty batch) | `null` | | `hasUnfinishedInput` (empty batch) | `false` | | `initBatch(channelId, batch)` | replaces `inputBatch`, resets the cursor, surfaces the channel id via `currentChannelId` | | `getNextTuple` over a batch | yields each element in order; `getCurrentTuple` tracks the last yielded value; `hasUnfinishedInput` flips to `false` once the last element is consumed | | `initBatch` called a second time | replaces the prior batch entirely and restarts the cursor (proven by yielding the new batch's first element fresh) | | `isPortCompleted` (non-materialized) | reads through to `WorkerPort.completed` — `false` initially, `true` once flipped | | `startInputPortReaderThreads` (no threads) | safe no-op | **Notes** Materialization-reader-thread paths (non-empty `urisToRead`) are deliberately left out of this characterization. Constructing an `InputPortMaterializationReaderThread` eagerly evaluates `toPartitioner(partitioning, workerActorId)` and pulls in document-factory plumbing that is out of scope for a unit spec — those code paths are exercised in higher-level worker / replay tests. ### Any related issues, documentation, discussions? Closes apache#5450. ### How was this PR tested? Pure unit-test addition; verified locally with: - `sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.InputManagerSpec"` — 15 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)
This was referenced Jul 16, 2026
renovate-bot
pushed a commit
to renovate-bot/apache-_-texera
that referenced
this pull request
Aug 4, 2026
### What changes were proposed in this PR? Adds `test_input_manager.py` (new, 20 tests) for the Python worker's `InputManager` (`amber/src/main/python/core/architecture/packaging/input_manager.py`), which had no direct unit tests — the Scala `InputManager` is covered by apache#5451, but the Python counterpart was only exercised indirectly through `MainLoop`. Uses a real `InternalQueue`, in-memory `Schema`/`pyarrow` tables, and stubbed reader runnables, so no engine or storage is needed. The suite covers: - **Registration** — `add_input_port` / `register_input`: `None` `id`/`internal` fields are normalized to `0`/`False`, re-adding an existing port is ignored, and channel-to-port bindings are checked in both directions. - **Completion tracking** — completing a channel marks its port; `all_ports_completed` is vacuously `True` with zero ports; completing one channel completes the whole port even if its other channels are still open (safe today because the `EndChannel` ECM is port-aligned — documented in a test comment). - **Channel filtering** — `get_all_data_channel_ids` excludes control channels. - **Materialization readers** — mismatched `uris`/`partitionings` raise; one reader is created per URI with the right pairing; a second setup replaces the readers instead of appending; finished readers are not restarted, and unfinished ones run on daemon threads. - **`process_data_payload`** — a DataFrame becomes `Tuple`s carrying the port's schema; an empty table yields nothing; a StateFrame passes through unchanged; a DataFrame from an unregistered channel fails only when the generator is consumed; unknown payload types raise `NotImplementedError`. ### Any related issues, documentation, discussions? Closes apache#6486 ### How was this PR tested? ``` cd amber/src/main/python PYTHONPATH=. python -m pytest ../../test/python/core/architecture/packaging/ -v # 28 passed (20 new InputManager tests + 8 existing OutputManager tests) ``` ### Was this PR authored or co-authored using generative AI tooling? Co-authored by: Claude Code (Fable 5) --------- Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
aglinxinyuan
added a commit
that referenced
this pull request
Aug 20, 2026
The cherry-pick of #7804 hit modify/delete on all three of its spec files: each already existed on `main` (added by #7018, #7219 and #5451, none of which were backported) but is absent here, so git could not apply a diff and the automation committed `main`'s whole file. Two of the three compile and pass against this branch unchanged; `PekkoActorRefMappingServiceSpec` does not, because it is written against `main` names this branch predates: - `virtualidentity.util.COORDINATOR` is `CONTROLLER` here, so the import did not resolve at all; - the scaladoc pointed at `PekkoMessageTransferServiceSpec`, a sibling that does not exist on this branch, leaving a dangling `[[link]]`. The assertions are untouched: every method the suite drives is identical on this branch, and the production hunks of #7804 applied cleanly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Pin behavior of
InputManager— the per-worker input broker that was the only previously-uncovered module in themessaginglayerpackage (every sibling —WorkerPort,OutputManager,AmberFIFOChannel,CongestionControl,FlowControl,NetworkInputGateway,OrderingEnforcer,RangeBasedShuffle— already has a spec). No production-code changes.InputManagerSpecInputManagerSpec file name follows the
<srcClassName>Spec.scalaone-to-one convention.Behavior pinned
getAllPorts(fresh)SetaddPort(portId, schema, Nil, Nil)WorkerPortwith the supplied schema; no reader threads attachedaddPortfor the sameportIdWorkerPortsurvives, including any mutation tocompleted)addPortwith mismatched URI / partitioning sizesAssertionErrorgetPort(portId)WorkerPortinstancegetInputPortReaderThreadsMapwhen every port was added withurisToRead = List.emptyhasUnfinishedInput(fresh)false(no batch initialized)getCurrentTuple(fresh)nullgetCurrentTuple(empty batch)nullhasUnfinishedInput(empty batch)falseinitBatch(channelId, batch)inputBatch, resets the cursor, surfaces the channel id viacurrentChannelIdgetNextTupleover a batchgetCurrentTupletracks the last yielded value;hasUnfinishedInputflips tofalseonce the last element is consumedinitBatchcalled a second timeisPortCompleted(non-materialized)WorkerPort.completed—falseinitially,trueonce flippedstartInputPortReaderThreads(no threads)Notes
Materialization-reader-thread paths (non-empty
urisToRead) are deliberately left out of this characterization. Constructing anInputPortMaterializationReaderThreadeagerly evaluatestoPartitioner(partitioning, workerActorId)and pulls in document-factory plumbing that is out of scope for a unit spec — those code paths are exercised in higher-level worker / replay tests.Any related issues, documentation, discussions?
Closes #5450.
How was this PR tested?
Pure unit-test addition; verified locally with:
sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.InputManagerSpec"— 15 tests, all greensbt scalafmtCheckAll— cleanWas this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Sonnet 4.5)