Skip to content

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

Closed
realwakka wants to merge 3 commits into
nodejs:masterfrom
realwakka:master
Closed

test: import test-http-server-keep-alive-timeout#13448
realwakka wants to merge 3 commits into
nodejs:masterfrom
realwakka:master

Conversation

@realwakka

@realwakka realwakka commented Jun 4, 2017

Copy link
Copy Markdown
Contributor

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

@Trott Trott left a comment

Copy link
Copy Markdown
Member

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

Trott commented Jun 4, 2017

Copy link
Copy Markdown
Member

@gibfahn

gibfahn commented Jun 4, 2017

Copy link
Copy Markdown
Member

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

@realwakka

Copy link
Copy Markdown
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

refack commented Jun 4, 2017

Copy link
Copy Markdown
Contributor

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

refack commented Jun 4, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@Trott

Trott commented Jun 5, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
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

refack commented Jun 7, 2017

Copy link
Copy Markdown
Contributor

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

lpinca commented Jun 8, 2017

Copy link
Copy Markdown
Member

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

lpinca commented Jun 8, 2017

Copy link
Copy Markdown
Member

Anyway this needs to be re-reviewed.

let createServer;

const tests = [];
if (isHttps) {

Copy link
Copy Markdown
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.

@refack refack left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

refack commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@Trott Trott left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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

refack commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

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

👍

@aqrln

aqrln commented Jun 8, 2017

Copy link
Copy Markdown
Contributor

+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
Copy Markdown
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

aqrln commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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

@refack refack left a comment

Copy link
Copy Markdown
Contributor

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

aqrln commented Jun 9, 2017

Copy link
Copy Markdown
Contributor

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 <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
@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 <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
@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