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: http test improvements #14315

Closed
wants to merge 1 commit into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jul 17, 2017

Generalized http test suite improvements...

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-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 17, 2017
@jasnell jasnell changed the title Http test improvements test: http test improvements Jul 17, 2017
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Jul 17, 2017
assert.strictEqual('GET', req.method);
assert.strictEqual('/blah', req.url);
assert.deepStrictEqual({
host: 'mapdevel.trolologames.ru:443',
Copy link
Member

Choose a reason for hiding this comment

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

heh

server.listen(0, function() {
name = http.globalAgent.getName({ port: this.address().port });
for (let i = 0; i < max; ++i) {
}, 3));
Copy link
Member

Choose a reason for hiding this comment

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

Why did you add this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just tightening up the tests to be more strict.

assert.throws(() => {
http.request({ method: input, path: '/' }, common.mustNotCall());
http.request({ method: method, path: '/' }, common.mustNotCall());
Copy link
Member

Choose a reason for hiding this comment

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

this can be a shorthand. { method, path: '/'}. Also this test structure is a bit strange - and I'm not sure that in this case the code is clearer after the refactoring. Personally I would prefer a for... of but it's not a big deal.

assert.throws(() => {
http.request({ method: input, path: '/' }, common.mustNotCall());
http.request({ method: method, path: '/' }, common.mustNotCall());
}, /^TypeError: Method must be a string$/);
Copy link
Member

Choose a reason for hiding this comment

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

It might be good to add a Symbol to the list of expectedFails while we're touching these

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

Left a few nits - overall nice work with the countdown.
This is also a pretty big diff.

@refack
Copy link
Contributor

refack commented Jul 17, 2017

/cc @nodejs/testing @nodejs/http

@jasnell
Copy link
Member Author

jasnell commented Jul 17, 2017

@benjamingr ... nits addressed!

@vsemozhetbyt
Copy link
Contributor

It seems this should be added before the code example in README.md to pass linting:

<!-- eslint-disable strict, required-modules -->

@jasnell
Copy link
Member Author

jasnell commented Jul 24, 2017

* Add common/countdown utility
* Numerous improvements to http tests
jasnell added a commit that referenced this pull request Jul 24, 2017
* Add common/countdown utility
* Numerous improvements to http tests

PR-URL: #14315
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@jasnell
Copy link
Member Author

jasnell commented Jul 24, 2017

Landed in b0a8a7c, squashed and a lint issue fixed in the process.

@jasnell jasnell closed this Jul 24, 2017
@jasnell
Copy link
Member Author

jasnell commented Jul 24, 2017

@nodejs/codeandlearn ... As a future exercise for code-n-learn participants, there are a non-trivial number of existing tests that can be modified to use the new common/countdown module... for instance, to shutdown a server after a given number of test requests have completed.

@gibfahn
Copy link
Member

gibfahn commented Jul 25, 2017

Seems like there should be some more people in @nodejs/codeandlearn (I know @Trott and @addaleax have been heavily involved, and I'm sure there are others who are interested).

@addaleax
Copy link
Member

This doesn’t land cleanly on 8.x; if you can, please follow the guide and raise a backport PR.

jasnell added a commit to jasnell/node that referenced this pull request Aug 1, 2017
* Add common/countdown utility
* Numerous improvements to http tests

PR-URL: nodejs#14315
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
addaleax pushed a commit that referenced this pull request Aug 1, 2017
* Add common/countdown utility
* Numerous improvements to http tests

Backport-PR-URL: #14583
Backport-Reviewed-By: Anna Henningsen <anna@addaleax.net>

PR-URL: #14315
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@addaleax addaleax mentioned this pull request Aug 2, 2017
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported

MylesBorins pushed a commit that referenced this pull request Sep 19, 2017
* Add common/countdown utility
* Numerous improvements to http tests

PR-URL: #14315
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
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.

9 participants