Skip to content

test(amber): DB-backed unit tests for ExecutionsMetadataPersistService and updateWorkflowState#5213

Merged
kunwp1 merged 1 commit into
apache:mainfrom
Yicong-Huang:test/executions-metadata-persist-service
May 26, 2026
Merged

test(amber): DB-backed unit tests for ExecutionsMetadataPersistService and updateWorkflowState#5213
kunwp1 merged 1 commit into
apache:mainfrom
Yicong-Huang:test/executions-metadata-persist-service

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds ExecutionsMetadataPersistServiceSpec, a MockTexeraDB-backed unit spec covering the three methods on ExecutionsMetadataPersistService plus the ExecutionStateStore.updateWorkflowState wrapper that sits on top of tryUpdateExistingExecution. The MockTexeraDB trait (already used by WorkflowExecutionsResourceSpec and peers) spins up an EmbeddedPostgres in beforeAll, loads sql/texera_ddl.sql, and tears down in afterAll.

Two latent silent-failure patterns are pinned with explanatory comments and filed as follow-up bugs: tryGetExistingExecution returns Some(null) instead of None for unknown eids, and insertNewExecution propagates a NOT NULL violation when uid=None despite the Option[Integer] signature. The pinned Some(null) test is paired with an intercept[TestFailedException]-based xfail-strict test asserting the intended None contract — it flips red the day the bug is fixed.

Any related issues, documentation, discussions?

Closes #5210. Surfaces #5211 and #5212.

How was this PR tested?

Added unit tests under amber/src/test/scala/org/apache/texera/web/service/.

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

Generated-by: Claude Opus 4.7

…e and updateWorkflowState

Adds a MockTexeraDB-backed spec that exercises insertNewExecution,
tryGetExistingExecution, tryUpdateExistingExecution, and the
ExecutionStateStore.updateWorkflowState wrapper. Two latent silent-
failure patterns are pinned with explanatory comments (filed as
follow-up bugs): tryGetExistingExecution returns Some(null) for
missing eids instead of None, and insertNewExecution propagates a
NOT NULL violation when called with uid=None despite the
Option[Integer] signature. The pinned None case is paired with an
intercept-based xfail-strict test that flips red the day the bug is
fixed.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.42%. Comparing base (9b850e2) to head (9bec8c1).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5213      +/-   ##
============================================
+ Coverage     48.05%   48.42%   +0.36%     
+ Complexity     2348     2345       -3     
============================================
  Files          1042     1042              
  Lines         39973    39973              
  Branches       4251     4251              
============================================
+ Hits          19211    19355     +144     
+ Misses        19624    19473     -151     
- Partials       1138     1145       +7     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 9b850e2
agent-service 33.76% <ø> (ø) Carriedforward from 9b850e2
amber 51.31% <ø> (+0.94%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 9b850e2
config-service 0.00% <ø> (ø) Carriedforward from 9b850e2
file-service 32.18% <ø> (ø) Carriedforward from 9b850e2
frontend 40.02% <ø> (ø) Carriedforward from 9b850e2
python 90.50% <ø> (ø) Carriedforward from 9b850e2
workflow-compiling-service 56.81% <ø> (ø) Carriedforward from 9b850e2

*This pull request uses carry forward flags. 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:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@kunwp1 kunwp1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kunwp1 kunwp1 added this pull request to the merge queue May 26, 2026
Merged via the queue into apache:main with commit 69bee15 May 26, 2026
15 checks passed
Ma77Ball added a commit to Ma77Ball/texera that referenced this pull request May 26, 2026
### What changes were proposed in this PR?
- Change `tryGetExistingExecution` in `ExecutionsMetadataPersistService`
to wrap the DAO call with `Option(...)` instead of `Some(...)`, so a
missing row (jOOQ returns `null`) collapses to `None` rather than
`Some(null)`.
- Keep the existing `catch Throwable` block, which still earns its keep
for hard DB errors (e.g. closed connection); the `Option` wrap only
addresses the no-row miss path.
- Update `ExecutionsMetadataPersistServiceSpec` (added in apache#5213):
replace the two paired pin tests (the `Some(null)` pin and the inverted
`intercept[TestFailedException]` xfail-strict) with a single positive
`shouldBe None` test.
  ### Any related issues, documentation, or discussions?
Closes: apache#5211. Depends on apache#5213 (test scaffolding); rebase after it
lands.
  ### How was this PR tested?
  - Ran `sbt scalafmtAll` (no rewrites needed).
- `ExecutionsMetadataPersistServiceSpec.tryGetExistingExecution` now has
positive tests for both the hit (`Some(row)`) and the miss (`None`)
cases.
  ### Was this PR authored or co-authored using generative AI tooling?
  Co-authored with Claude Opus 4.7 in compliance with ASF
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 DB-backed unit tests for ExecutionsMetadataPersistService and ExecutionStateStore.updateWorkflowState

3 participants