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

ci: avoid using same port number for different net tests #4147

Merged
merged 24 commits into from
Mar 21, 2020

Conversation

keroxp
Copy link
Contributor

@keroxp keroxp commented Feb 26, 2020

Some net tests (cli,std) are unstable in any platform. I doubt that one of causes is they are using same port numbers during tests. I added port picker that iterates different port number in private port range (49152 - 65535) for cli and std.

And note that when cargo test is running, we are using addresses below by tools/http_server.ts:

PORT = 4545
REDIRECT_PORT = 4546
ANOTHER_REDIRECT_PORT = 4547
DOUBLE_REDIRECTS_PORT = 4548
INF_REDIRECTS_PORT = 4549
HTTPS_PORT = 5545

I also doubt this is the main cause of windows's too flaky CI on net tests. 🤔

@keroxp
Copy link
Contributor Author

keroxp commented Feb 26, 2020

#4107 is related to this.

@bartlomieju bartlomieju requested a review from ry February 29, 2020 15:00
@keroxp
Copy link
Contributor Author

keroxp commented Mar 4, 2020

@ry How do you think?

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

@keroxp LGTM, with a few minor nitpicks

}
const it = portIterator();
/** Obtain (maybe) safe port number for net tests */
export function usePort(): number {
Copy link
Member

Choose a reason for hiding this comment

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

Please rename to randomPort

@@ -0,0 +1,20 @@
import { assert } from "../../testing/asserts.ts";
Copy link
Member

Choose a reason for hiding this comment

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

No need to put it inside internal/ directory, please lift one level up

}
const it = portIterator();
/** Obtain (maybe) safe port number for net tests */
export function usePort(): number {
Copy link
Member

Choose a reason for hiding this comment

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

s/usePort/randomPort/

@nayeemrmn
Copy link
Collaborator

Are you sure this won't hide bugs? If resources are cleaned properly it should be okay to use the same port. Or maybe it can't be helped due to shutdowns not working properly on Windows, or something?

@keroxp
Copy link
Contributor Author

keroxp commented Mar 18, 2020

@nayeemrmn No, thank you for pointing. I know tests around network are very unstable on windows. But what you concern about should be tested by one for that.

The motivation to use random port is that there are no rules to pick port from host and sometimes it conflicts existing local services. Port number between 1000 ~ 10000 are often taken by developer. It's slightly annoying to stop other services before running Deno's test.

Of course, that doesn't mean those ports are safe.
Basically 49152 (+20~30) for js/cli, 55001 (+20 ~ 30) for std will be used.

@keroxp keroxp requested a review from bartlomieju March 18, 2020 13:50
@keroxp
Copy link
Contributor Author

keroxp commented Mar 18, 2020

@bartlomieju Thank you for reviewing. I've applied reviews, please check!

@ry
Copy link
Member

ry commented Mar 18, 2020

This should wait until #4373 is fixed.

I'm hesitant on this patch because it complicates the test setup without a clear benefit.

Sorry for the delayed review @keroxp ...

const { value } = it.next();
assert(value != null);
return value;
}
Copy link
Member

Choose a reason for hiding this comment

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

This could be done more simply without an iterator and a global variable...

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

I'm a little unsure about what consequences this will have, but it seems fine. I misunderstood the issue at first, I thought this was about the ports used for tools/http_server.py which I think must be fixed (since they are shared across process and language boundaries).

LGTM - sorry for the delay @keroxp

@ry ry merged commit 60cee4f into denoland:master Mar 21, 2020
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Mar 24, 2020
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Mar 24, 2020
ry pushed a commit that referenced this pull request Mar 24, 2020
dubiousjim added a commit to dubiousjim/deno that referenced this pull request Mar 29, 2020
* denoland/master: (35 commits)
  Ignore flaky test cafile_info (denoland#4517)
  fix(inspector): proper error message on port collision (denoland#4514)
  feat: Added colors to doc output (denoland#4518)
  v0.38.0
  feat: Add "deno doc" subcommand (denoland#4500)
  Update to Prettier 2 and use ES Private Fields (denoland#4498)
  upgrade: dprint 0.9.6 (denoland#4509)
  upgrade: rusty_v8 to v0.3.9 (denoland#4505)
  feat: Support Inspector / Chrome Devtools (denoland#4484)
  Improve isatty and kill API docs; Deno.kill() - throw on Windows (denoland#4497)
  refactor: rename ConsoleOptions to InspectOptions (denoland#4493)
  upgrade: dprint 0.9.5 (denoland#4491)
  feat: window.close() (denoland#4474)
  errors: replace .lines with explicit .split newline (denoland#4483)
  doc: improve various API docs and include examples (denoland#4486)
  hide source line if error message longer than 150 chars (denoland#4487)
  fix: add fsEvent notify::Error casts (denoland#4488)
  feat: add queueMicrotask to d.ts (denoland#4477)
  Revert "avoid using same port number for test (denoland#4147)"
  docs: update manual about how to run tests for std (denoland#4462)
  ...
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
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.

4 participants