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

stream, test: Increase the coverage of _readableState and _writableState properties #8644

Closed
mcollina opened this issue Sep 18, 2016 · 9 comments
Labels
good first issue Issues that are suitable for first-time contributors. stream Issues and PRs related to the stream subsystem. test Issues and PRs related to the tests.

Comments

@mcollina
Copy link
Member

mcollina commented Sep 18, 2016

  • Version: all
  • Platform: all
  • Subsystem: stream

_readableStream and _writableStream in streams are widely used in userland, but the coverage for the state machine is insufficient, as only few properties of those are checked by unit tests.

I propose we add some more tests for the internal properties and state. This is probably a meta-issue, in the sense that we might send multiple PRs to increase the coverage.

Edit: The tests should possibly use only the stream module, rather than fs or net.

$ grep _readableState *
test-https-truncate.js:    assert.equal(res._readableState.length, 0);
test-stream-duplex.js:assert(stream._readableState.objectMode);
test-stream-push-order.js:  assert.deepStrictEqual(s._readableState.buffer.join(','), '1,2,3,4,5,6');
test-stream-readable-event.js:    assert(!r._readableState.reading);
test-stream-readable-event.js:    assert(r._readableState.reading);
test-stream-readable-event.js:    assert(!r._readableState.reading);
test-stream-readable-flow-recursion.js:  assert.equal(stream._readableState.highWaterMark, 8192);
test-stream-readable-flow-recursion.js:  assert.equal(stream._readableState.length, 0);
test-stream-transform-split-objectmode.js:assert(parser._readableState.objectMode);
test-stream-transform-split-objectmode.js:assert(parser._readableState.highWaterMark === 16);
test-stream-transform-split-objectmode.js:assert(!serializer._readableState.objectMode);
test-stream-transform-split-objectmode.js:assert(serializer._readableState.highWaterMark === (16 * 1024));
test-stream2-large-read-stall.js:var rs = r._readableState;
test-stream2-push.js:  console.error('data', stream._readableState.length);
test-stream2-read-sync-stack.js:  if (!(r._readableState.length % 256))
test-stream2-read-sync-stack.js:    console.error('readable', r._readableState.length);
test-stream2-transform.js:  t.equal(tx._readableState.length, 10);
test-stream2-unpipe-leak.js:console.error(src._readableState);
test-stream2-unpipe-leak.js:  src._readableState.buffer.length = 0;
test-stream2-unpipe-leak.js:  console.error(src._readableState);
test-stream2-unpipe-leak.js:  assert(src._readableState.length >= src._readableState.highWaterMark);
test-stream3-pause-then-read.js:      assert(!r._readableState.flowing);
$ grep _writableState *
test-http-pipeline-regr-3508.js:  if (size <= req.socket._writableState.highWaterMark) {
test-net-reconnect.js:    console.error('CLIENT connected', client._writableState);
test-net-reconnect.js:    console.error('CLIENT: calling end', client._writableState);
test-stream-big-packet.js:var big = Buffer.alloc(s1._writableState.highWaterMark + 1, 'x');
test-stream-duplex.js:assert(stream._writableState.objectMode);
test-stream-transform-split-objectmode.js:assert(!parser._writableState.objectMode);
test-stream-transform-split-objectmode.js:assert(parser._writableState.highWaterMark === (16 * 1024));
test-stream-transform-split-objectmode.js:assert(serializer._writableState.objectMode);
test-stream-transform-split-objectmode.js:assert(serializer._writableState.highWaterMark === 16);
test-stream2-transform.js:  t.same(tx._writableState.getBuffer().map(function(c) {
test-stream2-writable.js:      assert(tw._writableState.length >= 50);
test-zlib-flush-drain.js:const ws = deflater._writableState;

cc @nodejs/streams

@mcollina mcollina added stream Issues and PRs related to the stream subsystem. test Issues and PRs related to the tests. good first issue Issues that are suitable for first-time contributors. labels Sep 18, 2016
@Fishrock123
Copy link
Contributor

Maybe we should make a GitHub Project for "Streams: _readableState and _writableState"?

@mcollina
Copy link
Member Author

@Fishrock123 if we want to try that, I'm happy to. I do not have much time to do the tests, but I am happy to divide this into single issues.

@sstern6
Copy link
Contributor

sstern6 commented Sep 20, 2016

hey @mcollina and @Fishrock123!!

I am fairly new to the code base but would like to help out on this if you guys would like.

@mcollina have you separated out the issues as you mentioned?

@Fishrock123
Copy link
Contributor

Fishrock123 commented Sep 20, 2016

I've made a meta-project at https://github.com/nodejs/node/projects/2

@mcollina if you could make issues and then add them to the "issues" section, that could be a good start!

Edit: I still think we should do some groupings though, or should this issue be good enough to sum them up as an issue description?

@mcollina
Copy link
Member Author

@Fishrock123 I added some. Probably it needs some more. I tried to split them up in manageable chunks of work that could be achieved independently.

Let me know if I should clarify the text of the issues, or if they are easy to pick up.

@ALJCepeda
Copy link
Contributor

Could this issue be in conflict with #445? It seemed like _writableState and _readableState should not be used and instead new API should be introduced where these properties were deemed necessary

@mcollina
Copy link
Member Author

mcollina commented Sep 21, 2016

Currently there are very little tests on streams internal state machine. Currently we just test the public API.

Anything that changes the behavior of the linked properties is likely to be semver-major, so a decent test suite is in order to catch that situation.

IMHO unit tests are a basic step forward for any refactoring of the streams code.

@sstern6
Copy link
Contributor

sstern6 commented Sep 21, 2016

Thanks for setting up the issues @mcollina. Will try and tackle one of them and let you know if I have any questions.

@mcollina
Copy link
Member Author

Closing this, as we have good coverage of that now, thanks to everyone involved in this effort!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. stream Issues and PRs related to the stream subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

No branches or pull requests

4 participants