-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Simplify test files #89
Conversation
@jaydenseric - just to confirm, only the "Aborted request" test failure is intermittent, correct? (I see the others consistently failing on my machine.) |
@mike-marcacci pretty sure. |
In |
I saw that – I think either strategy should be fine, since we don't ever send the Working off of this branch, though, I'm not seeing the failure you describe above (I've probably run it 20 times). What OS / node version are you running? Just want to make sure I'm seeing the same things. |
Interesting, as Travis failed on Node.js v10.6 (what I also run locally) and v8.5. I'm on macOS v10.13.6. |
So, I see the same thing as Travis (I'm also running node v10.6 on macOS): Errors 2 and 3 from your screenshot appear every time; error 1 never appears though. I'll look into 2 and 3, and see if that leads somewhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes can account for both errors in travis, and error number 2 and number 3 in your screenshot... but I haven't been able to reproduce the first error in your screenshot.
@@ -851,8 +822,8 @@ t.test('Exceed max file size.', async t => { | |||
}) | |||
) | |||
|
|||
body.append(1, fs.createReadStream(TEST_FILE_PATH_JPG)) | |||
body.append(2, fs.createReadStream(TEST_FILE_PATH_JSON)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test tests:
- That an upload that exceeds the max file size triggers an error
- That a subsequent upload does not error
Because both uploads now exceed the max file size, they both error, which is the correct behavior. We could either introduce another smaller test file, or remove the second half of the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a second smaller test file.
I added a commit to fix these When these requests are aborted, the socket experiences a parse error which gets emitted as a In node 8, the default behavior results in a message being written to |
I'm actually looking at getting rid of having actual test files altogether. It's better tests create exactly the sort of file and assertions they need independently. Using this alternative - body.append(1, fs.createReadStream(TEST_FILE_PATH))
+ body.append(1, 'Text file content.', { filename: 'test-file.txt' }) |
Ooh! That's a fantastic idea. I did just push the "small file" commit here and was about to hit you up on slack. I'll defer to your changes here so we don't step on each others' toes. Let me know if you see that first error again, or have an idea how it might be reproduced! |
Reduced 88 tests to 60, with the same coverage. Also, if upload promises resolve unexpected extra fields it will now be noticed.
@mike-marcacci there are now only 3 usages of With
But when using the inline created files, the upload promises are resolved (with a file stream error?) before they can be accessed in the next middleware:
|
BTW I'm aware that the change to use |
OK! It looks like one of these errors was a problem with the test expecting an The other one, however, was actually a bug in that the extraneous stream was unhandled. When the previous file was larger, a stream wasn't created, and so no error needed to be handled. With the smaller file, though, this bug was exposed. |
@mike-marcacci Thanks for the bugfix! It had me tearing hair out. I don't know why the tests are currently passing on one of Travis Node.js versions, as they hang for me at the |
It seems this is a little too aggressive, and sometimes the tests run pretty slow. There are a lot of ways errors in these tests can cause the process to hang, perhaps a higher level Travis or tap timeout would be better.
This reveals an issue where certain tests were not even running.
I just checked in on this, and see why the abort test is hanging: using a single character (especially a number) as the abort signal probably isn't a great idea, since the actual multipart request is going to contain a randomly generated boundary to construct the delimiter between parts:
|
Some sort of memory leak though, as the test script no longer closes.
Yep, I'm a few steps ahead than that. Made the discovery that it is possible for a request to not be sent at all when aborting, if Node.js has not yet sent any packets. The trick is to use a timeout of 50 or so ms to be sure some of the first packets have been sent out. Fixed the tests (except some todos), but now there is some sort of memory leak I can't easily work out; the test script doesn't exit. |
Sounds like a socket handle hasn't been released. Instead of using a timeout (which is definitely a bit of a race) or a signal in the data, you could just keep track of the byte count and abort somewhere in the middle of that large payload. |
But, of course, I'm arguing against a straw man of your implementation that I just imagined... so you can probably ignore me :) I'm off to bed (have to drive my wife to the airport in like 4 hours) but let me know if you want me to look over anything as I'll have some time tomorrow! |
I celebrated too soon, for some reason the process doesn't exit again. @mike-marcacci I have to go out to an event now; maybe you can work it out. While debugging, I suggest having task manager open listing all |
Instead of using three seperate JSON, JPG and SVG test files, use one multipurpose test file.
Because the multipurpose test file is larger than the previous JSON and SVG files (at 100kb) it may reveal more bugs as it will be received in at least 2 chunks.
@mike-marcacci I don't know why, but these changes cause some tests to fail. Maybe you can tell why? Hopefully it's something silly I've done and not a bug with the new approach 😅