From 9fb768636d37c6ad949e26d76652a7980ff7b66a Mon Sep 17 00:00:00 2001 From: dafnarosenblum Date: Sun, 17 Sep 2017 14:01:17 +0300 Subject: [PATCH 1/2] Add support in primus non default pathname --- README.md | 1 + index.js | 4 +++- lib/benchmark.js | 3 ++- lib/workers/primusworker.js | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 index.js diff --git a/README.md b/README.md index 782cbd8..8240658 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ command help -o, --output Output file -t, --type Type of websocket server to bench(socket.io, engine.io, faye, primus, wamp). Default to socket.io -p, --transport Type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). Default to websockets (Just for Primus) + -n, --pathname Pathname for primus configuration, default is '/primus' -k, --keep-alive Keep alive connection -v, --verbose Verbose Logging diff --git a/index.js b/index.js old mode 100644 new mode 100755 index 341884e..852bc6d --- a/index.js +++ b/index.js @@ -17,6 +17,7 @@ program .option('-o, --output ', 'Output file') .option('-t, --type ', 'type of websocket server to bench(socket.io, engine.io, faye, primus, wamp). Default to io') .option('-p, --transport ', 'type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). Default to websockets') + .option('-n, --pathname ', 'pathname for primus configuration, default is "/primus" ') .option('-k, --keep-alive', 'Keep alive connection') .option('-v, --verbose', 'Verbose Logging') .parse(process.argv); @@ -74,7 +75,8 @@ var options = { type : program.type, transport : program.transport, keepAlive : program.keepAlive, - verbose : program.verbose + verbose : program.verbose, + pathname : program.pathname }; if (program.verbose) { diff --git a/lib/benchmark.js b/lib/benchmark.js index d114f99..f376731 100644 --- a/lib/benchmark.js +++ b/lib/benchmark.js @@ -36,7 +36,8 @@ Benchmark.prototype.launch = function (connectNumber, concurency, workerNumber, for (var i = 0; i < workerNumber; i++) { this.workers[i] = cp.fork(__dirname + '/worker.js', [ - this.server, this.options.generatorFile, this.options.type, this.options.transport, this.options.verbose + this.server, this.options.generatorFile, this.options.type, this.options.transport, this.options.verbose, + this.options.pathname ]); this.workers[i].on('message', this._onMessage.bind(this)); diff --git a/lib/workers/primusworker.js b/lib/workers/primusworker.js index 34791e8..35f884d 100644 --- a/lib/workers/primusworker.js +++ b/lib/workers/primusworker.js @@ -7,7 +7,7 @@ var BaseWorker = require('./baseworker.js'), logger = require('../logger.js'); // Create a primus instance in order to obtain the client constructor. -var PrimusClient = new Primus(http.createServer(), {'transformer' : process.argv[5]}).Socket; +var PrimusClient = new Primus(http.createServer(), {'transformer' : process.argv[5] , pathname: process.argv[7]}).Socket; var PrimusWorker = function (server, generator) { PrimusWorker.super_.apply(this, arguments); From 19c0abfc9432556cbfb2553ea7be67297e916a24 Mon Sep 17 00:00:00 2001 From: dafnarosenblum Date: Tue, 19 Sep 2017 16:20:51 +0300 Subject: [PATCH 2/2] Fix sinon API use - according to new version --- test/functional/faye.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/faye.js b/test/functional/faye.js index 4f0a344..957ecdb 100644 --- a/test/functional/faye.js +++ b/test/functional/faye.js @@ -49,7 +49,7 @@ describe('Test Faye Benchmarking', function () { }); it('should connect call reporter with 5 connection done', function (done) { - var stubReport = sinon.stub(testReporter, 'report', function (steps, monitor) { + var stubReport = sinon.stub(testReporter, 'report').callsFake(function (steps, monitor) { assert.equal(monitor.results.connection, 5); assert.equal(monitor.results.errors, 0); testReporter.report.restore(); @@ -62,7 +62,7 @@ describe('Test Faye Benchmarking', function () { }); describe('Test without faye server', function () { it('should connect call reporter with 10 errors', function (done) { - var stubReport = sinon.stub(testReporter, 'report', function (steps, monitor) { + var stubReport = sinon.stub(testReporter, 'report').callsFake(function (steps, monitor) { assert.equal(monitor.results.connection, 0); assert.equal(monitor.results.errors, 10); testReporter.report.restore();