Skip to content

Conversation

@mithunsasidharan
Copy link
Contributor

@mithunsasidharanmithunsasidharan commented Nov 22, 2017

Refactored the test case test-http-allow-req-after-204-res to use countdown, as per issue #17169

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

test

@nodejs-github-botnodejs-github-bot added the test Issues and PRs related to the tests. label Nov 22, 2017
Copy link
Contributor

Choose a reason for hiding this comment

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

this was basically used as the counter, so i do not think it's necessary anymore (hardcoding the method into the request is enough).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@Bamieh : Thanks. I've updated the PR. Kindly review!

Copy link
Contributor

@aqrlnaqrln left a comment

Choose a reason for hiding this comment

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

Hi and thanks a lot for your contribution! I left a couple of comments.

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 wrap the callback into common.mustCall()?

Something like this:

constcountdown=newCountdown(methods.length,common.mustCall(()=>{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.

Missing new line at the end of file.

@mscdexmscdex added the http Issues or PRs related to the http subsystem. label Nov 22, 2017
@mithunsasidharan
Copy link
ContributorAuthor

mithunsasidharan commented Nov 22, 2017

@aqrln : Thanks for the feedback. I've updated the PR with changes. I accidentally closed the PR...apologies for that. Kindly review!

Copy link
Contributor

@aqrlnaqrlnNov 22, 2017

Choose a reason for hiding this comment

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

Now that you removed the methods array, it should be codes.length, shouldn't it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@aqrln : Thanks. I've fixed it..kindly review.

@aqrln
Copy link
Contributor

@jasnell
Copy link
Member

CI is failing on this.

@thefourtheye
Copy link
Contributor

This patch works

diff --git a/test/common/countdown.js b/test/common/countdown.js index 6a22be0a07..93bdbbfb16 100644 --- a/test/common/countdown.js+++ b/test/common/countdown.js@@ -17,6 +17,7 @@ class Countdown{assert(this[kLimit] > 0, 'Countdown expired'); if (--this[kLimit] === 0) this[kCallback](); + return this[kLimit]; } get remaining(){diff --git a/test/parallel/test-http-allow-req-after-204-res.js b/test/parallel/test-http-allow-req-after-204-res.js index cd55a4f17c..53237f6677 100644 --- a/test/parallel/test-http-allow-req-after-204-res.js+++ b/test/parallel/test-http-allow-req-after-204-res.js@@ -23,12 +23,12 @@ const common = require('../common'); const http = require('http'); const assert = require('assert'); +const Countdown = require('../common/countdown'); // first 204 or 304 works, subsequent anything fails const codes = [204, 200]; -// Methods don't really matter, but we put in something realistic.-const methods = ['DELETE', 'DELETE'];+const countdown = new Countdown(codes.length, () => server.close()); const server = http.createServer(common.mustCall((req, res) =>{const code = codes.shift(); @@ -39,17 +39,13 @@ const server = http.createServer(common.mustCall((req, res) =>{}, codes.length)); function nextRequest(){- const method = methods.shift();-- const request = http.request({+ const request = http.get({ port: server.address().port, - method: method, path: '/' }, common.mustCall((response) =>{response.on('end', common.mustCall(() =>{- if (methods.length === 0){- server.close();- } else{+ if (countdown.dec()){ // throws error: nextRequest(); // works just fine:

@mithunsasidharan
Copy link
ContributorAuthor

@thefourtheye : Thanks for suggesting the correction. I've update the PR. Kindly review!

@mithunsasidharan
Copy link
ContributorAuthor

@maclover7 : Kindly run the CI for this PR too. Thanks !

@aqrln
Copy link
Contributor

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong opinion, but instead of modifying common/countdown.js, you can just use the existing API and do something like

countdown.dec();if(countdown.remaining>0){ ... }

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@aqrln : I feel making the change in countdown.jswill be better as it makes the test case condition more readable and save an extra line! Kindly suggest. Also, could you please run the CI. I've fixed the lint issues. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mithunsasidharan sure, no problem. In the future, please run make -j4 test locally before pushing to the PR branch to save your time and the number of review iterations. Thanks!

@aqrln
Copy link
Contributor

@mithunsasidharan
Copy link
ContributorAuthor

@addaleax@aqrln : Thanks !

@addaleaxaddaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 30, 2017
@addaleax
Copy link
Member

Landed in f6926d5

Thanks for the contribution! ✨ 🎉

@addaleaxaddaleax closed this Dec 1, 2017
@addaleaxaddaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 1, 2017
addaleax pushed a commit that referenced this pull request Dec 1, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 12, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Dec 12, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@gibfahngibfahn mentioned this pull request Dec 20, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #17211 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@gibfahngibfahn mentioned this pull request Dec 20, 2017
@MylesBorinsMylesBorins mentioned this pull request Dec 20, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

httpIssues or PRs related to the http subsystem.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@mithunsasidharan@aqrln@jasnell@thefourtheye@addaleax@Bamieh@mscdex@gibfahn@nodejs-github-bot