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

fix test-readline-interface #14681

Closed
wants to merge 2 commits into from
Closed

fix test-readline-interface #14681

wants to merge 2 commits into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Aug 8, 2017

First commit is from #14677 and I will remove it and rebase if that PR lands before this one (which I imagine it will).

Second First commit (h/t @addaleax):

lib: use Timer.now() in readline module

Using Date.now() introduces problems when operating under load or
otherwise with constrained resources. Use Timer.now() to mitigate.

Refs: https://github.com/nodejs/node/issues/14674

Third Second commit:

test: split out load-sensitive readline tests

Two test cases in `test-readline-interface` are sensitive to resource
constraints (probably due to `\r` and `\n` not arriving within the
appropriate delay to be treated as a single line ending). Move those
tests to `sequential`.

Fixes: https://github.com/nodejs/node/issues/14674
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

test readline

@nodejs-github-bot nodejs-github-bot added the readline Issues and PRs related to the built-in readline module. label Aug 8, 2017
@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

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 pending CI

@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

arm-fanned is green! Ci is effectively green. (Only failure is that vexing C++ test failure on armv7-wheezy.)

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

I starting to RC Collaborators, since our review process is getting watered down.

// Flags: --expose_internals
'use strict';
require('../common');

Copy link
Contributor

Choose a reason for hiding this comment

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

Please comment what this tests, and why is it in /sequential/.

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment added.

Copy link
Member Author

Choose a reason for hiding this comment

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

// These test cases are in `sequential` rather than the analogous test file in
// `parallel` because they become unrelaible under load. The unreliability under
// load was determined empirically when the test cases were in `parallel` by
// running:
//   tools/test.py -j 96 --repeat 192 test/parallel/test-readline-interface.js

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK it should be in the code, not just in GitHub 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

That's puzzling. I must have force-pushed it out at some point...

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh! I overwrote the commit message change I did for @bnoordhuis too. The joys of having two laptops and forgetting to fetch before starting work, I imagine...

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, all fixes have been re-fixed.

@addaleax
Copy link
Member

addaleax commented Aug 8, 2017

@Trott is moving to sequential actually necessary after the first adjustments? I think we might not need that, libuv’s now() should work well with synchronous input

@bnoordhuis
Copy link
Member

Using Date.now() introduces problems when operating under load or otherwise with constrained resources.

Could use more detail. What problems, what load or constrained resources?

@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

@Trott is moving to sequential actually necessary after the first adjustments? I think we might not need that, libuv’s now() should work well with synchronous input

@addaleax Without the third commit, here's the sorts of failures those two test cases get (that were moved to sequential) when resource-constrained:

$ tools/test.py -j 96 --repeat 192 test/parallel/test-readline-interface.js 
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bat'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:262:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bat'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bat'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'baz'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'baz'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'baz'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1032
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:287:10)
    at Interface._line (readline.js:642:8)
    at Interface._ttyWrite (readline.js:929:16)
    at FakeInput.onkeypress (readline.js:165:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
[00:09|% 100|+ 160|-  32]: Done  
$

The changes to lib/readline.js solved a bunch of other issues in the test, but I think the above problems are an artifact of the way those two test cases are written. High load makes them unreliable because subsequent .write() calls do not happen quickly enough. At least, that's what seems to be happening to me.

@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

Could use more detail. What problems, what load or constrained resources?

@bnoordhuis The problem was diagnosed (and the solution prposed) by @addaleax in #14674 (comment):

the delay between processing \r and \n is so long that readline thinks they are actually separate line endings.

I do think it’s problematic that this happens even for synchronously emitted input. Maybe we should be using process.binding('timer_wrap').Timer.now() instead of Date.now()?

As for load, I tend to simulate by running many test processes simultaneously which seems to pretty reliably predict (or retroactively "predict") what tests are unreliable in CI:

$ tools/test.py -j 96 --repeat 192 test/parallel/test-foo-bar.js

@bnoordhuis
Copy link
Member

Right, I mean the commit log could go into more detail. I kind of gleaned what you wrote from the linked issue but it's better for the commit log to document that.

@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

@bnoordhuis Updated commit message.

lib: use Timer.now() in readline module

Using Date.now() introduces problems when operating under load or
otherwise with constrained resources. Use Timer.now() to mitigate.

The problem was identified in `test-readline-interface` where under
heavy load, `\r` and `\n` were received so far apart that they were
treated as separate line endings rather than a single line ending.
Switching to `Timer.now()` prevented this from happening.

Refs: https://github.com/nodejs/node/issues/14674

@Trott Trott force-pushed the fix-readline branch 3 times, most recently from c4a660e to 3fd215c Compare August 8, 2017 14:26
@MylesBorins MylesBorins mentioned this pull request Aug 8, 2017
@refack
Copy link
Contributor

refack commented Aug 8, 2017

@Trott after f11379d is it still falky (I assume yes, but do we have empirical evidance)?

Trott added 2 commits August 8, 2017 12:58
Using Date.now() introduces problems when operating under load or
otherwise with constrained resources. Use Timer.now() to mitigate.

The problem was identified in `test-readline-interface` where under
heavy load, `\r` and `\n` were received so far apart that they were
treated as separate line endings rather than a single line ending.
Switching to `Timer.now()` prevented this from happening.

Refs: nodejs#14674
Two test cases in `test-readline-interface` are sensitive to resource
constraints (probably due to `\r` and `\n` not arriving within the
appropriate delay to be treated as a single line ending). Move those
tests to `sequential`.

Fixes: nodejs#14674
@Trott
Copy link
Member Author

Trott commented Aug 8, 2017

@Trott after f11379d is it still falky (I assume yes, but do we have empirical evidance)?

@refack f11379d seems to fix the flakiness on Raspberry Pi 1 in CI, but there is still unreliability when the test is run under load, which is what this PR addresses.

$ tools/test.py -j 96 --repeat 192 test/parallel/test-readline-interface.js 
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:262:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
assert.js:42
  throw new errors.AssertionError({
  ^

AssertionError [ERR_ASSERTION]: 2 === 1
    at Timeout.common.mustCall (/Users/trott/io.js/test/parallel/test-readline-interface.js:349:14)
    at Timeout._onTimeout (/Users/trott/io.js/test/common/index.js:509:15)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                    
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:262:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:262:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
=== release test-readline-interface ===                   
Path: parallel/test-readline-interface
readline.js:1030
            throw err;
            ^

AssertionError [ERR_ASSERTION]: '' === 'bar'
    at Interface.<anonymous> (/Users/trott/io.js/test/parallel/test-readline-interface.js:245:14)
    at emitOne (events.js:115:13)
    at Interface.emit (events.js:210:7)
    at Interface._onLine (readline.js:285:10)
    at Interface._line (readline.js:640:8)
    at Interface._ttyWrite (readline.js:927:16)
    at FakeInput.onkeypress (readline.js:163:10)
    at emitTwo (events.js:125:13)
    at FakeInput.emit (events.js:213:7)
    at emitKeys (internal/readline.js:420:14)
Command: out/Release/node --expose_internals /Users/trott/io.js/test/parallel/test-readline-interface.js
[00:08|% 100|+ 176|-  16]: Done  
$

(With the changes in this PR, the test passes with the above command line.)

@Trott
Copy link
Member Author

Trott commented Aug 10, 2017

@Trott
Copy link
Member Author

Trott commented Aug 10, 2017

AIX failure is almost certainly unrelated, but just in case...

CI: https://ci.nodejs.org/job/node-test-pull-request/9585/

Trott added a commit to Trott/io.js that referenced this pull request Aug 10, 2017
Using Date.now() introduces problems when operating under load or
otherwise with constrained resources. Use Timer.now() to mitigate.

The problem was identified in `test-readline-interface` where under
heavy load, `\r` and `\n` were received so far apart that they were
treated as separate line endings rather than a single line ending.
Switching to `Timer.now()` prevented this from happening.

PR-URL: nodejs#14681
Refs: nodejs#14674
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Trott added a commit to Trott/io.js that referenced this pull request Aug 10, 2017
Two test cases in `test-readline-interface` are sensitive to resource
constraints (probably due to `\r` and `\n` not arriving within the
appropriate delay to be treated as a single line ending). Move those
tests to `sequential`.

PR-URL: nodejs#14681
Fixes: nodejs#14674
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
@Trott
Copy link
Member Author

Trott commented Aug 10, 2017

Landed in fe54bc7 and c7a9a2e

@Trott Trott closed this Aug 10, 2017
addaleax pushed a commit that referenced this pull request Aug 10, 2017
Using Date.now() introduces problems when operating under load or
otherwise with constrained resources. Use Timer.now() to mitigate.

The problem was identified in `test-readline-interface` where under
heavy load, `\r` and `\n` were received so far apart that they were
treated as separate line endings rather than a single line ending.
Switching to `Timer.now()` prevented this from happening.

PR-URL: #14681
Refs: #14674
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
addaleax pushed a commit that referenced this pull request Aug 10, 2017
Two test cases in `test-readline-interface` are sensitive to resource
constraints (probably due to `\r` and `\n` not arriving within the
appropriate delay to be treated as a single line ending). Move those
tests to `sequential`.

PR-URL: #14681
Fixes: #14674
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
@addaleax addaleax mentioned this pull request Aug 13, 2017
@MylesBorins
Copy link
Contributor

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants