stream, test: add tests for _readableStream.awaitDrainΒ #8684
Copy link
Copy link
Closed
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.testIssues and PRs related to Node.js core tests and test infrastructure.Issues and PRs related to Node.js core tests and test infrastructure.
Description
Part of #8644.
The _readableState that needs to be tested is:
stream._readableState.awaitDrainLines 88 to 89 in 774146d
| // the number of writers that are awaiting a drain event in .pipe()s | |
| this.awaitDrain = 0; |
See also #8683
cc @Fishrock123 @nodejs/streams
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.streamIssues and PRs related to Node.js streams.Issues and PRs related to Node.js streams.testIssues and PRs related to Node.js core tests and test infrastructure.Issues and PRs related to Node.js core tests and test infrastructure.
Activity
shmuga commentedon Oct 3, 2016
I have made a proposal how this state variable can be tested in PR #8914 .
As we already have some tests for awaitDrain - I think it's better to add some asserts to them for covering real awairDrain value.
Also tests now cover reseting awaitDrain counter.
But I don't understand what this test is doing and can't rewrite it correctly. Can you someone help me with that?
mcollina commentedon Oct 3, 2016
@shmuga yes, good job!
The test you mentioned is increasing the awaitDrain mechanism manually, by calling resume: https://github.com/nodejs/node/blob/master/test/parallel/test-stream-pipe-await-drain-manual-resume.js#L29-L34.
You need to check that awaitDrain gets increased.
On that test, you should basically check that awaitDrain goes to zero as describe in: https://github.com/nodejs/node/blob/master/test/parallel/test-stream-pipe-await-drain-manual-resume.js#L37-L40
shmuga commentedon Oct 3, 2016
@mcollina great. will add some more tests for manual-resume. But I think this comment
is a bit strange at the place "increase again".
As we have only one writer here - the counter can't be increased more than one time.
So probably I will change that comment.
mcollina commentedon Oct 3, 2016
@shmuga resume interacts with
awaitDrain: https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L741See also https://github.com/nodejs/node/blob/master/lib/_stream_readable.js#L556.
When was that test added? Who did it? It might be worth getting the original PR here, and discussing with the author.
shmuga commentedon Oct 4, 2016
@mcollina I found nice description of this test in commit e2e615e
I will just follow those instructions and add cover tests for
awaitDrainstate variable.mcollina commentedon Jan 18, 2017
Closed by 21a077a
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain
test: tests for _readableStream.awaitDrain