test: import test-http-server-keep-alive-timeout#13448
test: import test-http-server-keep-alive-timeout#13448realwakka wants to merge 3 commits intonodejs:masterfrom
Conversation
Making same relibility changes that were applied to the https test. Https's relibility changes is in ce5745b.
Trott
left a comment
There was a problem hiding this comment.
LGTM if CI is green and stress tests have expected results
|
I get this message from CI
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 |
|
On a different subject, question to @nodejs/testing if |
|
Sure, I can fix it that simplify http and https. And I'll work it soon. |
|
Nit on the commit message, but it can be handled by whoever lands this: I'd say |
|
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! |
You could put a comment suppressing the linter, but if it's not a trivial change, IMHO you can skip the merge. |
Parameterize and merge two similar test sources. Http's test has function and http's test require it.
|
Despite @refack suggestion I think keeping the tests separate is better. Advantages:
Disadvantages:
|
|
Anyway this needs to be re-reviewed. |
| let createServer; | ||
|
|
||
| const tests = []; | ||
| if (isHttps) { |
There was a problem hiding this comment.
Since this is the only if id do this separately for each file, and pass all the objects as args.
refack
left a comment
There was a problem hiding this comment.
Still 👍
Requesting some changes for readability
| const options = { | ||
| port: server.address().port, | ||
| allowHalfOpen: true | ||
| const fs = require('fs'); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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/13448There was a problem hiding this comment.
This is a test file, not a library file. It shouldn't be exporting. -100 to exporting something to another test file from it.
One more for the pro-merge:
|
| }); | ||
| })); | ||
| }); | ||
| const timeoutTest = require('./test-http-server-keep-alive-timeout'); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
Please do not use require() to load an adjacent test file as a module
👍 |
|
|
||
| createOptions = function(server) { | ||
| return { | ||
| port: server.address().port, |
There was a problem hiding this comment.
FWIW, the indentation is off here.
This reverts commit f0ef3e6.
|
@realwakka I've noticed you reverted the last commit, thanks. |
code reverted, dismissing my request for changes
|
Landed in 1f9b1aa. Congratulations on your first contribution 🎉 |
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]>
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]>
Making same relibility changes that were applied to the https test.
Https's relibility changes is in ce5745b.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)