Skip to content

test: make mapWithResource abrupt cleanup tests deterministic#3319

Merged
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/3310-flow-map-with-resource-cleanup
Jul 10, 2026
Merged

test: make mapWithResource abrupt cleanup tests deterministic#3319
He-Pin merged 1 commit into
apache:mainfrom
He-Pin:fix/3310-flow-map-with-resource-cleanup

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 10, 2026

Copy link
Copy Markdown
Member

Motivation

The abrupt materializer termination tests used Source.single. Since mapWithResource runs on the blocking I/O dispatcher, its async boundary can let Source.single complete and close the resource before materializer shutdown. The test can therefore observe normal upstream completion instead of the abrupt termination path.

Modification

Use Source.maybe in both abrupt termination variants so the upstream remains open. After resource creation, assert that cleanup has not run before shutting down the materializer.

Result

The tests now isolate abrupt termination from normal upstream completion and retain directional assertions that cleanup runs after shutdown, including exactly-once closure for AutoCloseable resources.

Verification

  • FlowMapWithResourceSpec passed on Scala 2.13 and Scala 3.
  • validatePullRequest passed with 3,392 tests and no failures or errors.
  • Header and code-style checks passed.

References

Fixes #3310

Motivation:
The abrupt materializer termination tests used Source.single, which can complete across mapWithResource's async boundary and close the resource before shutdown.

Modification:
Keep the upstream open with Source.maybe and assert that the resource has not been closed before shutting down the materializer.

Result:
The tests now distinguish abrupt termination cleanup from normal upstream completion.

Tests:
- FlowMapWithResourceSpec on Scala 2.13 and Scala 3
- sbt +headerCheckAll
- sbt checkCodeStyle
- sbt validatePullRequest (3392 passed, 0 failed)

References:
Refs apache#3310
@He-Pin He-Pin added the flaky Related to flaky tests label Jul 10, 2026
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 10, 2026

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@He-Pin He-Pin merged commit 0059cce into apache:main Jul 10, 2026
10 checks passed
@He-Pin He-Pin deleted the fix/3310-flow-map-with-resource-cleanup branch July 10, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flaky Related to flaky tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

failed: FlowMapWithResourceSpec

2 participants