Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-7682 Fix TestApplication.stop() doesn't stop the application anymore #4534

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

osipxd
Copy link
Member

@osipxd osipxd commented Dec 6, 2024

Subsystem
Test Infrastructure

Motivation
KTOR-7682 TestApplication.stop() doesn't stop the application anymore

Solution
The problem occurs because TestApplication.client uses an instance of an application different from the returned by TestApplication constructor-like function and calls start() on it. TestApplication.start() calls TestApplicationEngine.start() under the hood which rewrites cancellationJob, so coroutine waiting for cancellation never ends.

To fix this problem:

  • make TestApplication return application from builder – the same as used in a client
  • remove builder from TestApplication constructor to make builder the only way to get TestApplication and break circular dependency: TestApplication -> ApplicationTestBuilder -> TestApplication

It is better to review commit-by-commit

@osipxd osipxd self-assigned this Dec 6, 2024
@osipxd osipxd requested a review from bjhham December 9, 2024 12:03
@osipxd osipxd force-pushed the osipxd/server-close-suspended branch 2 times, most recently from 77affbf to 3bda051 Compare December 9, 2024 16:05
Copy link
Contributor

@bjhham bjhham left a comment

Choose a reason for hiding this comment

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

Nice!

@osipxd osipxd force-pushed the osipxd/server-close-suspended branch from 3bda051 to 053dd0b Compare December 10, 2024 10:27
@osipxd osipxd enabled auto-merge (squash) December 10, 2024 10:30
@osipxd osipxd force-pushed the osipxd/server-close-suspended branch from 053dd0b to 4920eaa Compare December 10, 2024 14:18
@osipxd osipxd merged commit d90ef06 into main Dec 10, 2024
14 of 16 checks passed
@osipxd osipxd deleted the osipxd/server-close-suspended branch December 10, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants