Skip to content

test(amber): add unit tests for workflow-core PartitionInfo, WorkflowRuntimeException, WorkflowContext#4806

Merged
aglinxinyuan merged 4 commits into
apache:mainfrom
Yicong-Huang:test-partition-info
May 4, 2026
Merged

test(amber): add unit tests for workflow-core PartitionInfo, WorkflowRuntimeException, WorkflowContext#4806
aglinxinyuan merged 4 commits into
apache:mainfrom
Yicong-Huang:test-partition-info

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds scalatest coverage for three small common/workflow-core modules that had no dedicated specs:

  • PartitionInfoSpecsatisfies reflexivity + UnknownPartition universal-accepter + non-symmetric semantics, merge same/different/RangePartition-override, RangePartition.apply factory's empty-names fallback to UnknownPartition, @JsonSubTypes registration set, case-class equality.
  • WorkflowRuntimeExceptionSpec — all four constructor overloads (message-only, message + cause + workerId, cause + workerId, cause-only, no-arg), null-cause fallback, toString returning the raw message field.
  • WorkflowContextSpec — companion-object pinned defaults (workflow id 1L, execution id 1L), default-constructed instance honours those, var field reassignment, constructor argument override.

Any related issues, documentation, discussions?

Closes #4804.

Bug pinned in the spec with explanatory comment (filed separately as a Bug issue): the @JsonSubTypes annotation on PartitionInfo does not register OneToOnePartition, so Jackson cannot deserialize a polymorphic payload that selects that subclass via the type field. The other five concrete partitions are all registered.

How was this PR tested?

sbt scalafmtCheckAll
sbt "WorkflowCore/testOnly org.apache.texera.amber.core.workflow.PartitionInfoSpec org.apache.texera.amber.core.WorkflowRuntimeExceptionSpec org.apache.texera.amber.core.workflow.WorkflowContextSpec"

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

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

…RuntimeException, WorkflowContext

Closes apache#4804

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

codecov-commenter commented May 3, 2026

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4806      +/-   ##
============================================
+ Coverage     42.04%   42.08%   +0.03%     
- Complexity     2161     2170       +9     
============================================
  Files           980      980              
  Lines         36292    36292              
  Branches       3783     3783              
============================================
+ Hits          15260    15272      +12     
+ Misses        20110    20100      -10     
+ Partials        922      920       -2     
Flag Coverage Δ
access-control-service 39.53% <ø> (ø)
amber 42.95% <ø> (+0.07%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø)
config-service 0.00% <ø> (ø)
file-service 33.24% <ø> (ø)
workflow-compiling-service 47.72% <ø> (ø)

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.

@aglinxinyuan aglinxinyuan requested a review from Copilot May 3, 2026 03:15
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

Adds ScalaTest unit coverage for three previously untested common/workflow-core components, focusing on partition semantics, workflow-context defaults/mutability, and WorkflowRuntimeException constructor/toString behavior.

Changes:

  • Add PartitionInfoSpec covering satisfies, merge, RangePartition.apply fallback behavior, and current @JsonSubTypes registration.
  • Add WorkflowRuntimeExceptionSpec covering constructor overloads, null-cause behavior, and toString.
  • Add WorkflowContextSpec covering companion defaults, default construction, field reassignment, and constructor overrides.

Reviewed changes

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

File Description
common/workflow-core/src/test/scala/org/apache/texera/amber/core/workflow/WorkflowContextSpec.scala Tests pinned defaults and mutability/override behavior for WorkflowContext.
common/workflow-core/src/test/scala/org/apache/texera/amber/core/workflow/PartitionInfoSpec.scala Tests partition compatibility/merge rules and inspects Jackson subtype registration.
common/workflow-core/src/test/scala/org/apache/texera/amber/core/WorkflowRuntimeExceptionSpec.scala Tests WorkflowRuntimeException constructors, cause/worker capture, and toString.

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

…ixed

The original spec said "register all concrete subclasses" but its body
asserted that OneToOnePartition is NOT in the set. Split into two
tests: one that pins the current registration set without claiming
completeness, and one wrapped in pendingUntilFixed that asserts the
intended contract (OneToOnePartition is registered). The latter flips
to a deliberate failure once the bug is fixed, prompting removal of
the marker.
@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 3, 2026 08:07
aglinxinyuan and others added 2 commits May 4, 2026 01:47
# Conflicts:
#	common/workflow-core/src/test/scala/org/apache/texera/amber/core/workflow/PartitionInfoSpec.scala
@aglinxinyuan aglinxinyuan merged commit 8b8a814 into apache:main May 4, 2026
17 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 tests for workflow-core: PartitionInfo, WorkflowRuntimeException, WorkflowContext

4 participants