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: refactor test-http-response-splitting #11429

Closed
wants to merge 1 commit into from

Conversation

notarseniy
Copy link
Contributor

@notarseniy notarseniy commented Feb 16, 2017

  • move repeated code to function
  • remove unneeded common.mustCall() usage with function arguments that
    are not callbacks
  • add error message checking

like #11274.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test http

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Feb 16, 2017
Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

Almost there

function test(res, code, header) {
assert.throws(() => {
res.writeHead(code, header);
});
Copy link
Member

Choose a reason for hiding this comment

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

This should actually be updated to test the actual error message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you! implemented.

@notarseniy notarseniy force-pushed the http-response-splitting branch 2 times, most recently from e84501e to 42dbf60 Compare February 16, 2017 21:05
@notarseniy
Copy link
Contributor Author

Thanks for review :-) Recommited with error message checking and with new commit message.

@@ -19,23 +19,26 @@ const y = 'foo⠊Set-Cookie: foo=bar';

let count = 0;

function test(res, code, header) {
const errRegExp = new RegExp(
'TypeError: The header content contains invalid characters'
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 add ^ and $ to the regular expression. You can also use a regex literal instead of the RegExp() constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, seems better. Thank you for pointing this out! Fixed.

@notarseniy notarseniy force-pushed the http-response-splitting branch 4 times, most recently from 308738e to a84c506 Compare February 16, 2017 21:25
@notarseniy
Copy link
Contributor Author

notarseniy commented Feb 16, 2017

Re-forcepushed again with fixes. Feel free to commenting anything more :)

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM. Only comment is that it might look a little cleaner to drop errRegExp, and just put the regex inline.

* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Feb 16, 2017
@targos
Copy link
Member

targos commented Feb 18, 2017

@notarseniy
Copy link
Contributor Author

notarseniy commented Feb 18, 2017

Why test on armv8-ubuntu1404 is break down? This test is passed, but there's hudson-related issue (unrelated to this PR):

ok 1397 sequential/test-vm-timeout-rethrow
  ---
  duration_ms: 0.510
  ...
make[1]: Leaving directory `/home/iojs/build/workspace/node-test-commit-arm/nodes/armv8-ubuntu1404'
[armv8-ubuntu1404] $ /bin/sh -xe /tmp/hudson5359784332414623123.sh
+ set +x
Sat Feb 18 07:00:53 PST 2017
+ pgrep node
+ true
FATAL: command execution failed
hudson.remoting.ChannelClosedException: channel is already closed
	at hudson.remoting.Channel.send(Channel.java:604)
	at hudson.remoting.Request.call(Request.java:130)
	at hudson.remoting.Channel.call(Channel.java:821)
	at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:256)
	at com.sun.proxy.$Proxy106.isAlive(Unknown Source)
	at hudson.Launcher$RemoteLauncher$ProcImpl.isAlive(Launcher.java:1043)
	at hudson.Launcher$RemoteLauncher$ProcImpl.join(Launcher.java:1035)
	at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:154)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:108)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:65)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
	at hudson.model.Build$BuildExecution.build(Build.java:205)
	at hudson.model.Build$BuildExecution.doRun(Build.java:162)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
	at hudson.model.Run.execute(Run.java:1728)
	at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: Connection aborted: org.jenkinsci.remoting.nio.NioChannelHub$MonoNioTransport@ffbeda2[name=Channel to /121.212.45.83]
	at org.jenkinsci.remoting.nio.NioChannelHub$NioTransport.abort(NioChannelHub.java:210)
	at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:635)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Connection timed out
	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
	at sun.nio.ch.IOUtil.read(IOUtil.java:197)
	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
	at org.jenkinsci.remoting.nio.FifoBuffer$Pointer.receive(FifoBuffer.java:142)
	at org.jenkinsci.remoting.nio.FifoBuffer.receive(FifoBuffer.java:359)
	at org.jenkinsci.remoting.nio.NioChannelHub.run(NioChannelHub.java:564)
	... 6 more
Build step 'Execute shell' marked build as failure
[Current build status] check if current [FAILURE] is worse or equals then [UNSTABLE] and better or equals then [SUCCESS]
Run condition [Current build status] preventing perform for step [[Execute a set of scripts]]
[Current build status] check if current [FAILURE] is worse or equals then [ABORTED] and better or equals then [FAILURE]
Run condition [Current build status] enabling perform for step [[Execute a set of scripts]]
ERROR: Step ?Publish TAP Results? failed: no workspace for node-test-commit-arm/nodes=armv8-ubuntu1404 #7848
Checking ^not ok
ERROR: Build step failed with exception
java.lang.NullPointerException
Build step 'Jenkins Text Finder' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE

@gibfahn
Copy link
Member

gibfahn commented Feb 19, 2017

Why test on armv8-ubuntu1404 is break down? This test is passed, but there's hudson-related issue (unrelated to this PR):

Probably related to nodejs/build#611

jasnell pushed a commit that referenced this pull request Feb 19, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@jasnell
Copy link
Member

jasnell commented Feb 19, 2017

Landed in 6647688

@jasnell jasnell closed this Feb 19, 2017
addaleax pushed a commit that referenced this pull request Feb 22, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@italoacasas italoacasas mentioned this pull request Feb 25, 2017
jasnell pushed a commit that referenced this pull request Mar 7, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
jasnell pushed a commit that referenced this pull request Mar 7, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 2017
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
* move repeated code to function
* remove unneeded `common.mustCall()` usage with function arguments that
  are not callbacks
* add error message checking

PR-URL: #11429
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Mar 9, 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