Skip to content

test(workflow-core): add unit test coverage for core executor traits + factory - #5400

Merged
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:test-core-executor-spec
Jun 6, 2026
Merged

aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:test-core-executor-spec

Conversation

@aglinxinyuan

@aglinxinyuan aglinxinyuan commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

CoreExecutorReflectionSpec (same package) already covered the basic defaults of OperatorExecutor / SourceOperatorExecutor and the ExecFactory.newExecFromJavaClassName happy paths + JavaRuntimeCompilation failure path. This PR extends the existing spec with five additional regression pins, without duplicating any existing assertion.

Surface Pinned (new in this PR)
OperatorExecutor.open / close A subclass override is reachable from every call site that invokes open / close on the trait (counter-based pin; a direct no-op-stub regression that bypassed dispatch wouldn't fail the existing default-stays-no-op tests).
OperatorExecutor.processTupleMultiPort The default wrapper hands the input port verbatim to the subclass override (a regression that hard-coded port = 0 would be invisible to the basic delegation test). Zero-emission and many-emission fan-out from the underlying processTuple both pass through with Option.empty port.
SourceOperatorExecutor.processTupleMultiPort The input-side path never invokes produceTuple (counter-based pin; an accidental drain that discarded results wouldn't fail an empty-iterator check).
ExecFactory.newExecFromJavaClassName NoSuchMethodException propagates when neither factory branch matches a fixture with only a (Long) constructor (the existing tests pin the success paths and ClassNotFoundException, not the "no constructor matches" branch).

The PR body's earlier claim that "this package has no unit tests today" was inaccurate; the existing spec was missed during my initial coverage check because its Reflection suffix doesn't match any source-class name pattern. Consolidated per Copilot review.

No production code changed; this is test-only.

Any related issues, documentation, discussions?

Closes #5396

How was this PR tested?

sbt "WorkflowCore/Test/testOnly org.apache.texera.amber.core.executor.CoreExecutorReflectionSpec"
# → 23 tests (18 pre-existing + 5 new), all pass

sbt "WorkflowCore/Test/scalafmtCheck"
# → clean

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

Generated-by: Claude Code (Claude Opus 4.7)

…+ factory

Pin the abstract executor contract every operator implementation honors
plus the reflection-based factory that compiles / instantiates them.

OperatorExecutor defaults: no-op open / close (idempotent across the
lifecycle); produceStateOnStart / produceStateOnFinish default to None;
processState defaults to Some(state); onFinish defaults to
Iterator.empty. Multi-port wrappers default to pairing each underlying
emission with Option.empty port and forwarding the input port id
verbatim to the subclass override; zero-/many-emission fan-out covered.

SourceOperatorExecutor overrides: open / close no-op; processTuple
returns Iterator.empty (sources do not consume input); the input-side
processTupleMultiPort returns Iterator.empty without ever calling
produceTuple; onFinishMultiPort delegates to produceTuple and wraps
each emitted tuple with Option.empty port.

ExecFactory.newExecFromJavaClassName: no-arg constructor when descString
is empty; (String) constructor when non-empty; falls back to (Int, Int)
or (String, Int, Int) when the first branch raises NoSuchMethodException;
ClassNotFoundException propagates when the name doesn't resolve;
NoSuchMethodException propagates when neither branch matches (a
fixture with only a (Long) constructor exercises this).

ExecFactory.newExecFromJavaCode: the diagnostic-collection branch is
covered with a syntactically-broken source. A happy-path compile-and-
construct test is intentionally omitted — JavaRuntimeCompilation's
in-memory compiler doesn't inherit sbt's test classpath, so a source
that implements OperatorExecutor can't resolve the trait at javac time.

Closes apache#5396
Copilot AI review requested due to automatic review settings June 6, 2026 07:37
@github-actions github-actions Bot added the common label Jun 6, 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

Adds a new ScalaTest suite intended to pin the default behaviors of the core executor traits (OperatorExecutor, SourceOperatorExecutor) and the reflection-based executor factory (ExecFactory) in workflow-core.

Changes:

  • Adds CoreExecutorSpec covering default lifecycle/state methods and multi-port wrappers for OperatorExecutor.
  • Adds coverage for SourceOperatorExecutor input-side no-op behavior and finish-time tuple production wrapping.
  • Adds reflection/compilation failure-path tests for ExecFactory (class-name instantiation branches; Java compilation diagnostics).

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

@codecov-commenter

codecov-commenter commented Jun 6, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5400      +/-   ##
============================================
- Coverage     51.62%   51.60%   -0.02%     
+ Complexity     2419     2418       -1     
============================================
  Files          1056     1056              
  Lines         41049    41049              
  Branches       4410     4410              
============================================
- Hits          21190    21182       -8     
- Misses        18619    18627       +8     
  Partials       1240     1240              
Flag Coverage Δ *Carryforward flag
access-control-service 41.89% <ø> (ø)
agent-service 33.76% <ø> (ø) Carriedforward from df55fe4
amber 52.22% <ø> (-0.06%) ⬇️
computing-unit-managing-service 1.38% <ø> (ø)
config-service 54.68% <ø> (ø)
file-service 38.42% <ø> (ø)
frontend 46.30% <ø> (ø) Carriedforward from df55fe4
pyamber 90.69% <ø> (ø) Carriedforward from df55fe4
python 90.84% <ø> (ø) Carriedforward from df55fe4
workflow-compiling-service 58.39% <ø> (ø)

*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 6, 2026 08:12
…Spec

Address Copilot review on apache#5400: CoreExecutorReflectionSpec already
covered OperatorExecutor / SourceOperatorExecutor defaults and
ExecFactory.newExecFromJavaClassName / JavaRuntimeCompilation. I
missed the existing spec during my initial coverage check (its name
doesn't match any source-class name pattern). Drop the duplicate
CoreExecutorSpec.scala and instead add five genuinely-new tests to
the existing spec:

- OperatorExecutor.open / close honor a subclass override across the
  lifecycle (counter-based pin so direct no-op stubs would not pass).
- processTupleMultiPort forwards the input port id verbatim to the
  subclass override (regression that hard-codes port = 0 would be
  invisible to the basic delegation test).
- processTupleMultiPort produces as many output pairs as
  processTuple emits (zero / many fan-out).
- SourceOperatorExecutor.processTupleMultiPort never invokes
  produceTuple on the input-side path (counter-based pin — an
  accidental drain that discards results wouldn't fail an
  empty-iterator check).
- ExecFactory.newExecFromJavaClassName propagates
  NoSuchMethodException when neither factory branch matches a
  fixture with only a (Long) constructor.

The PR diff is now additive on top of the existing spec rather than
a parallel duplicate.

@Yicong-Huang Yicong-Huang 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.

LGTM

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jun 6, 2026
Merged via the queue into apache:main with commit 57640a7 Jun 6, 2026
20 checks passed
@aglinxinyuan
aglinxinyuan deleted the test-core-executor-spec branch June 6, 2026 22:52
aglinxinyuan added a commit to aglinxinyuan/texera that referenced this pull request Jun 7, 2026
… files

Address Yicong-Huang's review on apache#5439: the single
WorkerManagersAdditionalSpec.scala combining tests for two source
classes makes future contributors miss this file when they search
StatisticsManagerSpec.scala / SerializationManagerSpec.scala — exactly
the duplicate-spec failure mode that surfaced on apache#5400 with
CoreExecutorReflectionSpec vs my parallel CoreExecutorSpec.

Split into two files following the <srcClassName>Spec.scala convention:
- StatisticsManagerSpec.scala (12 tests for StatisticsManager)
- SerializationManagerSpec.scala (8 tests for SerializationManager)

No assertion changes; tests + companion fixtures simply move to the
file that matches their source class.
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
…+ factory (apache#5400)

### What changes were proposed in this PR?

`CoreExecutorReflectionSpec` (same package) already covered the basic
defaults of `OperatorExecutor` / `SourceOperatorExecutor` and the
`ExecFactory.newExecFromJavaClassName` happy paths +
`JavaRuntimeCompilation` failure path. This PR extends the existing spec
with five additional regression pins, without duplicating any existing
assertion.

| Surface | Pinned (new in this PR) |
| --- | --- |
| `OperatorExecutor.open` / `close` | A subclass override is reachable
from every call site that invokes `open` / `close` on the trait
(counter-based pin; a direct no-op-stub regression that bypassed
dispatch wouldn't fail the existing default-stays-no-op tests). |
| `OperatorExecutor.processTupleMultiPort` | The default wrapper hands
the input `port` verbatim to the subclass override (a regression that
hard-coded `port = 0` would be invisible to the basic delegation test).
Zero-emission and many-emission fan-out from the underlying
`processTuple` both pass through with `Option.empty` port. |
| `SourceOperatorExecutor.processTupleMultiPort` | The input-side path
never invokes `produceTuple` (counter-based pin; an accidental drain
that discarded results wouldn't fail an empty-iterator check). |
| `ExecFactory.newExecFromJavaClassName` | `NoSuchMethodException`
propagates when neither factory branch matches a fixture with only a
`(Long)` constructor (the existing tests pin the success paths and
`ClassNotFoundException`, not the "no constructor matches" branch). |

The PR body's earlier claim that "this package has no unit tests today"
was inaccurate; the existing spec was missed during my initial coverage
check because its `Reflection` suffix doesn't match any source-class
name pattern. Consolidated per Copilot review.

No production code changed; this is test-only.

### Any related issues, documentation, discussions?

Closes apache#5396

### How was this PR tested?

```
sbt "WorkflowCore/Test/testOnly org.apache.texera.amber.core.executor.CoreExecutorReflectionSpec"
# → 23 tests (18 pre-existing + 5 new), all pass

sbt "WorkflowCore/Test/scalafmtCheck"
# → clean
```

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

Generated-by: Claude Code (Claude Opus 4.7)
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 core executor traits + factory

4 participants