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: http2 client settings errors #16096

Closed
wants to merge 1 commit into from

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Oct 9, 2017

This code change adds tests for checking errors in client.settings()

Refs: #14985

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, http2

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Oct 9, 2017
@mscdex mscdex added the http2 Issues or PRs related to the http2 subsystem. label Oct 9, 2017

const errorMustCall = common.expectsError(test.error, 2);
const errorMustNotCall = common.mustNotCall(
`${test.error.code} should emit on ${test.type}`
Copy link
Member

@apapirovski apapirovski Oct 9, 2017

Choose a reason for hiding this comment

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

test.type does not appear to be defined in this test. I think it should be replaced with a plain string that says session. (Maybe the message isn't even necessary to be honest since it only emits on session.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch @apapirovski
I'd copied this template from other tests which checks for errors which had types. I've replace ${test.type} with plain string session

runTest(tests.shift());

function runTest(test) {
const server = http2.createServer(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.

I might be missing something but is there a reason the server needs to be started on each test run rather than having a single server for the whole test?

Copy link
Member Author

Choose a reason for hiding this comment

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

The sessionError is thrown on the server.
A single server was used originally, but I was not able to override the error thrown on that server. So a new server was created per test.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to just do server.once('sessionError', fn) inside runTest and have all the code around creating a server and initiating it outside of runTest? If not, no worries.

Copy link
Member Author

Choose a reason for hiding this comment

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

server.once('sessionError', fn) worked!
Thanks for the suggestion. I've updated the commit.

client.settings({
maxHeaderListSize: 1
});
server.on(
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 not sure I'm following what's going on with the changes in this file. Is there a reason everything needs to be scoped within the stream handler? This looks like a lot of churn and I'm having trouble following why.

Copy link
Member Author

Choose a reason for hiding this comment

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

I originally started working on this file and formatted the code using Prettier.
I created test-http2-client-settings-errors.js after coming across the template used by other tests which checked for errors.
I've scoped method assertSettings within stream handler, as it's only used within that block.

Copy link
Member

@apapirovski apapirovski Oct 10, 2017

Choose a reason for hiding this comment

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

My concern is just that it's a bit easier to follow the file history (git blame) when changes aren't made just for the sake of changing code style, unless the clarity is a significant problem. That said, this is a nit so if no one else cares then this is fine. Thanks for the explanation 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that code change shouldn't be made just for changing code style.
I added changed in test-http2-session-settings.js as the formatting was already done. I'll remove it from the commit if more people raise it in the reviews.
Btw, I created an issue at #16115 to check if we can move to Javascript formatter like Prettier.

@refack refack self-assigned this Oct 10, 2017
Copy link
Member

@apapirovski apapirovski left a comment

Choose a reason for hiding this comment

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

LGTM. Just nits above. 👍

@trivikr
Copy link
Member Author

trivikr commented Oct 13, 2017

Can someone create CI link for this pull request?

@joyeecheung
Copy link
Member

@trivikr
Copy link
Member Author

trivikr commented Oct 14, 2017

Fixed linting errors and rebased from upstream/master

@joyeecheung
Copy link
Member

@apapirovski
Copy link
Member

apapirovski commented Oct 14, 2017

Looks like on slower systems this test is failing because sessionError doesn't emit until after the next test started. To be honest, instead of trying to fix (nextTick or setImmediate would likely do it), I would recommend just getting rid of the current sessionError listener because we know those errors are forwarded there and that behaviour is tested elsewhere. Instead I would just add (at the top level scope, not within each test runner):

server.on('sessionError', () => {}); // not being tested

@trivikr
Copy link
Member Author

trivikr commented Oct 14, 2017

Moved sessionError to top level scope as tests are failing on slower systems.

@jasnell
Copy link
Member

jasnell commented Oct 15, 2017

@mcollina
Copy link
Member

Failures are unrelated.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@mcollina mcollina assigned mcollina and unassigned refack Oct 17, 2017
@mcollina
Copy link
Member

Landing this.

@mcollina
Copy link
Member

Landed as c3eeb28.

@mcollina mcollina closed this Oct 17, 2017
mcollina pushed a commit that referenced this pull request Oct 17, 2017
Refs: #14985
PR-URL: #16096
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 18, 2017
Refs: nodejs/node#14985
PR-URL: nodejs/node#16096
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 23, 2017
Refs: #14985
PR-URL: #16096
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@trivikr trivikr deleted the test-http2-session-settings branch February 8, 2018 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants