GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: fix flaky test-net-socket-local-address by cjihrig · Pull Request #4650 · nodejs/node

Conversation

@cjihrig

@cjihrig cjihrig commented Jan 12, 2016

Copy link
Copy Markdown
Contributor

Prior to this commit, the test was flaky because it was executing the majority of its logic in a function called from the client and multiple events on the server. This commit simplifies the test by separating the server's connection and listening events, and isolating the client logic.

Refs: #4476 and #4644
R= @Trott

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cjihrig cjihrig mentioned this pull request Jan 12, 2016
test: fix flaky test-net-socket-local-address #4644
Closed
@r-52 r-52 added net Issues and PRs related to the net subsystem. test Issues and PRs related to Node.js core tests and test infrastructure. labels Jan 12, 2016
@jasnell jasnell added the lts-watch-v4.x label Jan 12, 2016
@jasnell

jasnell commented Jan 12, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jan 13, 2016

Copy link
Copy Markdown
Member

These changes mean that the test no longer triggers on the bug it was written for. This test is for a bug that was present in Node.js 3.0.0 and this version of the test (with appropriate modifications to remove fat arrows, etc. which were not supported in Node 3.0.0) does not fire an assertion whereas the current version does.

For the record, here's the way it ended up after removing fat arrows, etc. so that it could run in Node 3.0.0:

'use strict';
// const common = require('../common');
const assert = require('assert');
const net = require('net');

// skip test in FreeBSD jails
// if (common.inFreeBSDJail) {
//   console.log('1..0 # Skipped: In a FreeBSD jail');
//   return;
// }

var conns = 0;
var clientLocalPorts = [];
var serverRemotePorts = [];

const server = net.createServer(function(socket) {
  serverRemotePorts.push(socket.remotePort);
  socket.end();
});

server.on('close', function() {
  assert.deepEqual(clientLocalPorts, serverRemotePorts,
                   'client and server should agree on the ports used');
  assert.strictEqual(2, conns);
});

server.listen(12346, '127.0.0.1', connect);

function connect() {
  if (conns === 2) {
    server.close();
    return;
  }

  const client = new net.Socket();

  conns++;
  client.once('close', connect);
  client.connect(12346, '127.0.0.1', function() {
    clientLocalPorts.push(client.localPort);
  });
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jan 13, 2016

Copy link
Copy Markdown
Contributor Author

Good catch. Simple fix, just have to move the const client = new net.Socket(); up higher so that the same socket is reused. I'll update the PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig
test: fix flaky test-net-socket-local-address
4954d8e
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.
@cjihrig
cjihrig force-pushed the local-addr branch from ba22940 to 4954d8e Compare January 13, 2016 01:50
@cjihrig

cjihrig commented Jan 13, 2016

Copy link
Copy Markdown
Contributor Author

@Trott updated. Verified that moving the client socket triggers the original bug in v3.0.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jbergstroem

jbergstroem commented Jan 13, 2016

Copy link
Copy Markdown
Member

Lets try it in CI: https://ci.nodejs.org/job/node-test-commit/1709/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Jan 13, 2016

Copy link
Copy Markdown
Contributor Author

CI has some red, but none in this test. We should probably run a stress test too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jan 13, 2016

Copy link
Copy Markdown
Member

Stress test: https://ci.nodejs.org/job/node-stress-single-test/341/nodes=win-vs2015/console

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jan 13, 2016

Copy link
Copy Markdown
Member

Confirmed expected test failure in Node.js 3.0.0 and success in Node.js 3.3.0. So that's good.

LGTM if the stress test comes out clean.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig added a commit that referenced this pull request Jan 13, 2016
@cjihrig
test: fix flaky test-net-socket-local-address
6cfd0b5
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: #4476
Refs: #4644
PR-URL: #4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@cjihrig

cjihrig commented Jan 13, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Stress test came through green. Landed in 6cfd0b5.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig cjihrig closed this Jan 13, 2016
@cjihrig
cjihrig deleted the local-addr branch January 13, 2016 16:44
rvagg pushed a commit that referenced this pull request Jan 14, 2016
@cjihrig @rvagg
test: fix flaky test-net-socket-local-address
525afc1
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: #4476
Refs: #4644
PR-URL: #4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@evanlucas evanlucas mentioned this pull request Jan 18, 2016
v5.5.0 Release Proposal (Stable) #4742
Merged
@MylesBorins MylesBorins added land-on-v4.x and removed lts-watch-v4.x labels Jan 28, 2016
MylesBorins pushed a commit that referenced this pull request Jan 28, 2016
@cjihrig Myles Borins
test: fix flaky test-net-socket-local-address
405a8d6
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: #4476
Refs: #4644
PR-URL: #4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit that referenced this pull request Feb 11, 2016
@cjihrig Myles Borins
test: fix flaky test-net-socket-local-address
5f9345a
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: #4476
Refs: #4644
PR-URL: #4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Feb 11, 2016
@cjihrig Myles Borins
test: fix flaky test-net-socket-local-address
0462b78
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: nodejs#4476
Refs: nodejs#4644
PR-URL: nodejs#4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 11, 2016
V4.3.1 proposal #5200
Merged
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Feb 15, 2016
@cjihrig Myles Borins
test: fix flaky test-net-socket-local-address
d615757
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: nodejs#4476
Refs: nodejs#4644
PR-URL: nodejs#4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
@cjihrig Michael Scovetta
test: fix flaky test-net-socket-local-address
f3778e1
Prior to this commit, the test was flaky because it was
executing the majority of its logic in a function called from
the client and multiple events on the server. This commit
simplifies the test by separating the server's connection and
listening events, and isolating the client logic.

Refs: nodejs#4476
Refs: nodejs#4644
PR-URL: nodejs#4650
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

net Issues and PRs related to the net subsystem. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@cjihrig @jasnell @Trott @jbergstroem @MylesBorins @r-52
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.