Skip to content

[test] Add a test for cancellable #529

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

Merged
merged 17 commits into from
Jul 21, 2025

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Jul 7, 2025

  • Add a test on LambdaRuntime for cancellable.
  • Move the service life cycle test to its own file

@sebsto sebsto requested a review from adam-fowler July 7, 2025 10:11
@sebsto sebsto self-assigned this Jul 7, 2025
@sebsto sebsto added the semver/none No version bump required. label Jul 7, 2025
@sebsto sebsto changed the title Add a test for cancellable [test] Add a test for cancellable Jul 7, 2025
@@ -50,17 +50,24 @@ struct LambdaRuntimeTests {
}

// wait a small amount to ensure runtime1 task is started
try await Task.sleep(for: .seconds(0.5))
Copy link
Member

Choose a reason for hiding this comment

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

When I run all the tests in parallel this test fails quite regularly as the second task gets run before the first. I don't think you can rely on a sleep to ensure the two tasks are run in order. Maybe you should care which order they run in, just that one throws a LambdaRuntimeError. Do the error check before the taskGroup.next()

await #expect(throws: LambdaRuntimeError.self) {
    try await taskGroup.next()
}

I'm pretty sure you can get rid of the test that you can run the second runtime after the failure. Is it really valid to have two separate runtimes, run in the the same lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. Fixed now.

@sebsto sebsto merged commit db7e789 into swift-server:main Jul 21, 2025
@sebsto sebsto deleted the sebsto/test-cancellable branch July 21, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants