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

Converting test to use Countdown #17505

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions test/parallel/test-http-should-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
require('../common');
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, I should've been clearer. This is still required but it should not be assigned to a variable. Also, please try to run make test -j4 before committing as it will flag these types of issues in advance and also run the test being modified.

const common = require('../common');
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed but I don't think this const common is actually used? In general, I recommend running make test -j4 — it will run eslint to make sure there are no small issues like this.

const assert = require('assert');
const http = require('http');
const net = require('net');
const common = require('../common');
const Countdown = require('../common/countdown');

const SERVER_RESPONSES = [
Expand All @@ -46,17 +45,18 @@ const SHOULD_KEEP_ALIVE = [
http.globalAgent.maxSockets = 5;

const countdown = new Countdown(SHOULD_KEEP_ALIVE.length , () => server.close());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please remove the space between length and the comma?

let countdownIndexInc = SERVER_RESPONSES.length - countdown.remaining;

const getCountdownIndex = () => SERVER_RESPONSES.length - countdown.remaining
Copy link
Member

Choose a reason for hiding this comment

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

Nit: missing semi-colon.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like there's still no semi-colon at the end of this line btw.

Copy link
Author

Choose a reason for hiding this comment

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

Hi, I`m probably not running the eslint as should. the command
just pass without no issues.
how can I make sure its ok?

Copy link
Member

Choose a reason for hiding this comment

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

You could try running make lint-js from your command line, that should lint the files. The -require might not be caught but the missing semi-colon definitely should.


const server = net.createServer(function(socket) {
socket.write(SERVER_RESPONSES[countdownIndexInc]);
socket.write(SERVER_RESPONSES[getCountdownIndex()]);
}).listen(0, function() {
function makeRequest() {
const req = http.get({ port: server.address().port }, function(res) {
assert.strictEqual(
req.shouldKeepAlive, SHOULD_KEEP_ALIVE[countdownIndexInc],
`${SERVER_RESPONSES[countdownIndexInc]} should ${
SHOULD_KEEP_ALIVE[countdownIndexInc] ? '' : 'not '}Keep-Alive`);
req.shouldKeepAlive, SHOULD_KEEP_ALIVE[getCountdownIndex()],
`${SERVER_RESPONSES[getCountdownIndex()]} should ${
SHOULD_KEEP_ALIVE[getCountdownIndex()] ? '' : 'not '}Keep-Alive`);
countdown.dec();
if (countdown.remaining) {
makeRequest();
Expand All @@ -67,8 +67,3 @@ const server = net.createServer(function(socket) {
makeRequest();
});

process.on('exit', function() {
countdownIndexInc = SERVER_RESPONSES.length - countdown.remaining;
assert.strictEqual(countdownIndexInc, SERVER_RESPONSES.length);
assert.strictEqual(countdownIndexInc, SHOULD_KEEP_ALIVE.length);
});