Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: fix flaky test-dgram-empty-packet & friends
* Liberal use of common.mustCall()
* Rename test-dgram-empty-packet -> test-dgram-send-empty-packet
* Remove use of timers to avoid CI failures like seen in the Ref below:

```
not ok 237 parallel/test-dgram-empty-packet
  ---
  duration_ms: 0.717
  severity: fail
  stack: |-
        ...
        throw new Error('Timeout');
        ^

    Error: Timeout
        at Timeout._onTimeout
        ...
        at ontimeout (timers.js:365:14)
        at tryOnTimeout (timers.js:237:5)
        at Timer.listOnTimeout (timers.js:207:5)
```

Refs: https://ci.nodejs.org/job/node-test-commit-freebsd/5341/nodes=freebsd11-x64/console:
  • Loading branch information
Trott committed Nov 24, 2016
commit 5b2178a2f5db5e41bd66602ffeace5bb65c97888
40 changes: 0 additions & 40 deletions test/parallel/test-dgram-empty-packet.js

This file was deleted.

9 changes: 5 additions & 4 deletions test/parallel/test-dgram-send-empty-array.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const dgram = require('dgram');

if (common.isOSX) {
common.skip('because of 17894467 Apple bug');
return;
}

const assert = require('assert');
const dgram = require('dgram');

const client = dgram.createSocket('udp4');

client.on('message', common.mustCall(function onMessage(buf, info) {
Expand All @@ -17,8 +18,8 @@ client.on('message', common.mustCall(function onMessage(buf, info) {
client.close();
}));

client.on('listening', function() {
client.on('listening', common.mustCall(function() {
client.send([], this.address().port, common.localhostIPv4);
});
}));

client.bind(0);
14 changes: 5 additions & 9 deletions test/parallel/test-dgram-send-empty-buffer.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
'use strict';
const common = require('../common');
const dgram = require('dgram');

if (common.isOSX) {
common.skip('because of 17894467 Apple bug');
return;
}

const dgram = require('dgram');

const client = dgram.createSocket('udp4');

client.bind(0, function() {
client.bind(0, common.mustCall(function() {
const port = this.address().port;

client.on('message', common.mustCall(function onMessage(buffer, bytes) {
clearTimeout(timer);
client.close();
}));

const buf = Buffer.alloc(0);
client.send(buf, 0, 0, port, '127.0.0.1', function(err, len) { });

const timer = setTimeout(function() {
throw new Error('Timeout');
}, common.platformTimeout(200));
});
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() { }));
}));
27 changes: 27 additions & 0 deletions test/parallel/test-dgram-send-empty-packet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
const common = require('../common');

if (common.isOSX) {
common.skip('because of 17894467 Apple bug');
return;
}

const dgram = require('dgram');

const client = dgram.createSocket('udp4');

client.bind(0, common.mustCall(function() {

function callback(firstArg) {
// First time through, firstArg should be null.
// Second time, it should be the buffer.
if (firstArg instanceof Buffer)
client.close();
}

client.on('message', common.mustCall(callback));

const port = this.address().port;
const buf = Buffer.alloc(1);
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(callback));
}));