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

[tests] Implement serverWithStop in all test interpreters #3306

Merged
merged 17 commits into from
Nov 9, 2023

Conversation

kciesielski
Copy link
Member

@kciesielski kciesielski commented Nov 8, 2023

A follow-up to #3294

Implements serverWithStop for all test interpreters, so that any server test can now be run with graceful shutdown enabled, as well as shutdown hook (called KillSwitch) available as a test parameter using testServerLogicWithStop.

Example:

   testServerLogicWithStop(
      endpoint
        .out(plainBody[String])
        .serverLogic { _ =>
          // do something with input
        },
      "Server name",
      gracefulShutdownTimeout = Some(4.seconds) // enabled
    ) { (release) => (backend, baseUri) =>
        // test body, you can use the `release: IO[Unit]` kill switch in your test 
        // to stop the server arbitrarily, or just let it be stopped by test cleanup automatically
  }

Some servers don't seem to support graceful shutdown out of the box, namely VertX, zio-http 1.x, http4s (Blaze).

@kciesielski kciesielski force-pushed the netty-tests-with-stop branch from 74ac308 to 03d72e5 Compare November 8, 2023 20:27
@kciesielski kciesielski changed the title [WIP] Refactor serverWithStop in test interpreters [WIP] Implement serverWithStop in all test interpreters Nov 8, 2023
@kciesielski kciesielski changed the title [WIP] Implement serverWithStop in all test interpreters Implement serverWithStop in all test interpreters Nov 9, 2023
@kciesielski kciesielski changed the title Implement serverWithStop in all test interpreters [tests] Implement serverWithStop in all test interpreters Nov 9, 2023
@kciesielski kciesielski marked this pull request as ready for review November 9, 2023 05:56
@kciesielski kciesielski requested a review from adamw November 9, 2023 05:56
Copy link
Member

@adamw adamw left a comment

Choose a reason for hiding this comment

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

Nice, thanks! :) one left-over type alias, I think

@kciesielski kciesielski merged commit f6f8bfc into master Nov 9, 2023
15 checks passed
@mergify mergify bot deleted the netty-tests-with-stop branch November 9, 2023 08:47
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