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

Unique ports for each test server instance #3276

Closed

Conversation

toBeOfUse
Copy link
Contributor

Description

This implements the test suite port assignment scheme described in #3247.

Currently, each end-to-end test suite in the project calls testConfig to get the configuration for the NestJS server it's supposed to create. The goal is for testConfig to return a unique port number for each test suite that calls it, so that no two test suites attempt to attach a test server to the same port. The current solution is for a ports.json file to keep track of the claimed ports so that a unique one can be chosen, but due to race conditions, this does not always work.

To fix this, a new port assignment method is used. First, glob is used to get a list of all of the *.e2e-spec.ts files in the project. Then, Error.prototype.stack is used to get the filename of the test suite that is the caller of testConfig. The returned configuration will then contain a port number that is the sum of 3010 and the test suite's unique position in the ordered list of e2e test files.

Breaking changes

Does this PR include any breaking changes we should be aware of?

Nope.

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Copy link

vercel bot commented Dec 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Dec 15, 2024 11:09pm

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@toBeOfUse toBeOfUse marked this pull request as draft December 15, 2024 23:26
@michaelbromley
Copy link
Member

This was resolved by 72befaa

@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants