Skip to content

Commit

Permalink
test: replace callback with arrow functions
Browse files Browse the repository at this point in the history
PR-URL: nodejs#24490
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
sreepurnajasti authored and refack committed Jan 10, 2019
1 parent 949dfd7 commit 37297c9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions test/pummel/test-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const http = require('http');
const url = require('url');

const body = 'hello world\n';
const server = http.createServer(function(req, res) {
const server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Length': body.length,
'Content-Type': 'text/plain'
Expand All @@ -45,7 +45,7 @@ let keepAliveReqSec = 0;
let normalReqSec = 0;


function runAb(opts, callback) {
const runAb = (opts, callback) => {
const args = [
'-c', opts.concurrent || 100,
'-t', opts.threads || 2,
Expand All @@ -66,11 +66,9 @@ function runAb(opts, callback) {

let stdout;

child.stdout.on('data', function(data) {
stdout += data;
});
child.stdout.on('data', (data) => stdout += data);

child.on('close', function(code, signal) {
child.on('close', (code, signal) => {
if (code) {
console.error(code, signal);
process.exit(code);
Expand All @@ -90,20 +88,20 @@ function runAb(opts, callback) {

callback(reqSec, keepAliveRequests);
});
}
};

server.listen(common.PORT, () => {
runAb({ keepalive: true }, (reqSec) => {
keepAliveReqSec = reqSec;

runAb({ keepalive: false }, function(reqSec) {
runAb({ keepalive: false }, (reqSec) => {
normalReqSec = reqSec;
server.close();
});
});
});

process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(
normalReqSec > 50,
true,
Expand Down

0 comments on commit 37297c9

Please sign in to comment.