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

test: import test-http-server-keep-alive-timeout #13448

Closed
wants to merge 3 commits into from

Conversation

realwakka
Copy link
Contributor

@realwakka realwakka commented Jun 4, 2017

Making same relibility changes that were applied to the https test.
Https's relibility changes is in ce5745b.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

Making same relibility changes that were applied to the https test.
Https's relibility changes is in ce5745b.
@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jun 4, 2017
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Jun 4, 2017
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

LGTM if CI is green and stress tests have expected results

@Trott
Copy link
Member

Trott commented Jun 4, 2017

@gibfahn
Copy link
Member

gibfahn commented Jun 4, 2017

cc/ @refack @jasnell @lpinca @aqrln (who reviewed #13312)

@realwakka
Copy link
Contributor Author

I get this message from CI

not ok 1418 inspector/test-inspector-port-zero-cluster # TODO : Fix flaky test

and test is marked with UNSTABLE. How can I fix this problem???

@refack
Copy link
Contributor

refack commented Jun 4, 2017

I get this message from CI

not ok 1418 inspector/test-inspector-port-zero-cluster # TODO : Fix flaky test
and test is marked with UNSTABLE. How can I fix this problem???

You can ignore this. Yellow CI means that something that we know is broken (or flaky) has failed again. If you're interested the tracking issue is #13343

@refack
Copy link
Contributor

refack commented Jun 4, 2017

On a different subject, question to @nodejs/testing if test-http-server-keep-alive-timeout.js and test-https-server-keep-alive-timeout.js are similar enough, should we parametrize and merge?

@realwakka
Copy link
Contributor Author

Sure, I can fix it that simplify http and https. And I'll work it soon.

@Trott
Copy link
Member

Trott commented Jun 5, 2017

Nit on the commit message, but it can be handled by whoever lands this: I'd say refactor instead of import. The test isn't being imported, really.

@realwakka
Copy link
Contributor Author

I have some problem with parameterizing and merging. I made some js file for sharing function for http and https. there is dilemma about linter. new js file ( test-server-keep-alive-timeout.js ) requires common and http/https requires new js source. linter says every js file needs to require mandatory common module. because of this, I inserted some source in http/https but it's gonna be unused variable!
is there other way to use new js file for function?

@refack
Copy link
Contributor

refack commented Jun 7, 2017

I have some problem with parameterizing and merging. I made some js file for sharing function for http and https. there is dilemma about linter. new js file ( test-server-keep-alive-timeout.js ) requires common and http/https requires new js source. linter says every js file needs to require mandatory common module. because of this, I inserted some source in http/https but it's gonna be unused variable!
is there other way to use new js file for function?

You could put a comment suppressing the linter, but if it's not a trivial change, IMHO you can skip the merge.

@refack refack self-assigned this Jun 7, 2017
Parameterize and merge two similar test sources.
Http's test has function and http's test require it.
@lpinca
Copy link
Member

lpinca commented Jun 8, 2017

Despite @refack suggestion I think keeping the tests separate is better.

Advantages:

  • easier to read and understand.
  • easier to modify them independently if necessary.
  • no need to use workarounds for our test harness.

Disadvantages:

  • code duplication.

@lpinca
Copy link
Member

lpinca commented Jun 8, 2017

Anyway this needs to be re-reviewed.


const tests = [];
if (isHttps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is the only if id do this separately for each file, and pass all the objects as args.

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Still 👍
Requesting some changes for readability

const options = {
port: server.address().port,
allowHalfOpen: true
const fs = require('fs');
Copy link
Contributor

Choose a reason for hiding this comment

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

then move all the require to the top

const assert = require('assert');
const http = require('http');
const net = require('net');
module.exports.testServerKeepAliveTimeout = function(common, isHttps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As per https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md
put const common = require('../common'); as L2 then a blank line and then a comment

// Testing http[s] server keepalive semantics.
// Reusing tests with test-https-server-keep-alive-timeout.js
// Ref: https://github.com/nodejs/node/pull/13448

Copy link
Member

Choose a reason for hiding this comment

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

This is a test file, not a library file. It shouldn't be exporting. -100 to exporting something to another test file from it.

@refack
Copy link
Contributor

refack commented Jun 8, 2017

Despite @refack suggestion I think keeping the tests separate is better.

Advantages:

  • easier to read and understand.
  • easier to modify them independently if necessary.
  • no need to use workarounds for our test harness.

Disadvantages:

  • code duplication.

One more for the pro-merge:

  • Assert that keepalive semantics are the same for http and https

});
}));
});
const timeoutTest = require('./test-http-server-keep-alive-timeout');
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this could be moved to other file as well, and delete this one.
So other file will be:

const setup http, net, createOptions, serverOptions, createServer;
testServerKeepAliveTimeout(http, net, createOptions, serverOptions, createServer)
const https, tls, createOptions, serverOptions, createServer;
testServerKeepAliveTimeout(https, tls, createOptions, serverOptions, createServer)

This has the benefit of eliminating node startup time (that could be ~2s)

Trott
Trott previously requested changes Jun 8, 2017
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Well, it was OK. This refactoring to remove code duplication is not something I'm excited about for the reasons @lpinca outlines. This PR should have landed when it was getting approvals and it worked and it was a clear improvement over what was there. The additional refactoring to remove code duplication could have been a separate PR. @realwakka if you want to revert it to what you had, that would be great by me. You can open a separate PR for the refactoring to remove code duplication if interested.

});
}));
});
const timeoutTest = require('./test-http-server-keep-alive-timeout');
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use require() to load an adjacent test file as a module

@refack
Copy link
Contributor

refack commented Jun 8, 2017

You can open a separate PR for the refactoring to remove code duplication if interested.

👍

@aqrln
Copy link
Contributor

aqrln commented Jun 8, 2017

+1 to what @lpinca and @Trott said. I don't think that code duplication is a problem for tests. To the contrary, the testing code should be maximally dumb and straightforward, or otherwise you'd need to test your tests ;)


createOptions = function(server) {
return {
port: server.address().port,
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, the indentation is off here.

@aqrln
Copy link
Contributor

aqrln commented Jun 9, 2017

@realwakka I've noticed you reverted the last commit, thanks.
Fresh CI: https://ci.nodejs.org/job/node-test-pull-request/8575/

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Still LGTM.

@Trott Trott dismissed their stale review June 9, 2017 03:19

code reverted, dismissing my request for changes

@aqrln
Copy link
Contributor

aqrln commented Jun 9, 2017

Landed in 1f9b1aa. Congratulations on your first contribution 🎉

@aqrln aqrln closed this Jun 9, 2017
aqrln pushed a commit that referenced this pull request Jun 9, 2017
Make the same reliability changes that were applied to the https test in
ce5745b.

Refs: #13312
PR-URL: #13448
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Alexey Orlenko <[email protected]>
@refack refack removed their assignment Jun 9, 2017
addaleax pushed a commit that referenced this pull request Jun 10, 2017
Make the same reliability changes that were applied to the https test in
ce5745b.

Refs: #13312
PR-URL: #13448
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Alexey Orlenko <[email protected]>
@addaleax addaleax mentioned this pull request Jun 10, 2017
@gibfahn gibfahn mentioned this pull request Jun 15, 2017
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants