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

make metrics.test.js less flaky #1715

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 8 additions & 8 deletions lib/plugins/multipartBodyParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ function multipartBodyParser(options) {
fs.readFile(files[f].path, function readFile(ex, data) {
barrier.done('fs' + f);
/*
* We want to stop the request here, if there's
* an error trying to read the file from disk.
* Ideally we'd like to stop the other oustanding
* file reads too, but there's no way to cancel
* in flight fs reads. So we just return an
* error, and be grudgingly let the other file
* reads finish.
*/
* We want to stop the request here, if there's
* an error trying to read the file from disk.
* Ideally we'd like to stop the other oustanding
* file reads too, but there's no way to cancel
* in flight fs reads. So we just return an
* error, and be grudgingly let the other file
* reads finish.
*/
if (ex) {
return next(
new errors.InternalError(
Expand Down
9 changes: 7 additions & 2 deletions test/plugins/metrics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@ describe('request metrics plugin', function() {
// However the timeout value is 200,
// it's calculated by the client,
// but setTimeout is happening on the server, tolerate 10ms
assert.isAtLeast(metrics.preLatency, 50);

// Expected pre-latency has been adjusted from 50 to 49
// to work around timer issues in Node.js <11
// https://github.com/nodejs/node/issues/10154
assert.isAtLeast(metrics.preLatency, 49);

assert.isAtLeast(metrics.useLatency, 50);
assert.isAtLeast(metrics.routeLatency, 250);
assert.isAtLeast(metrics.latency, 200 - 10);
// latency should dbe lower as request timeouts
// latency should be lower as request timeouts
assert.isAbove(metrics.routeLatency, metrics.latency);
assert.equal(metrics.path, '/foo');
assert.equal(metrics.method, 'GET');
Expand Down