From 21c5e4f9106aaeed8bb7e038921088ef1494922e Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 13 Jul 2015 10:36:28 -0700 Subject: [PATCH] simple stress test --- tests/stress-test.js | 54 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/tests/stress-test.js b/tests/stress-test.js index 2f00837..dad8cb5 100644 --- a/tests/stress-test.js +++ b/tests/stress-test.js @@ -1,20 +1,64 @@ var streamPair = require('stream-pair') -var devNull = require('dev-null') -var bytesStream = require('random-bytes-stream') +// var devNull = require('dev-null') +// var bytesStream = require('random-bytes-stream') module.exports.all = function (test, common) { - test('1 stream with 64Mb file', function (t) { + test('1 stream with 1 msg', function (t) { common.setup(test, function (err, Muxer) { t.ifError(err, 'should not throw') var pair = streamPair.create() - spawnGeneration(t, Muxer, pair, pair.other, 1, [10, 10]) + spawnGeneration(t, Muxer, pair, pair.other, 1, 1) }) }) } -function spawnGeneration (t, Muxer, dialerSocket, listenerSocket, nStreams, sizeWindow) { +function spawnGeneration (t, Muxer, dialerSocket, listenerSocket, nStreams, nMsg, sizeWindow) { + t.plan(6) + + var msg = 'simple msg' + + var listenerMuxer = new Muxer() + var dialerMuxer = new Muxer() + + var listenerConn = listenerMuxer.attach(listenerSocket) + var dialerConn = dialerMuxer.attach(dialerSocket) + + listenerConn.on('stream', function (stream) { + t.pass('Incoming stream') + + stream.on('data', function (chunk) { + + }) + + stream.on('end', function () { + t.pass('Stream ended on Listener') + // stream.end() + }) + + }) + + for (var i = 0; i < nStreams; i++) { + dialerConn.dialStream(function (err, stream) { + t.ifError(err, 'Should not throw') + t.pass('Dialed stream') + + for (var j = 0; j < nMsg; j++) { + stream.write(msg) + } + + stream.on('data', function (chunk) { + t.fail('Should not happen') + }) + + stream.on('end', function () { + t.pass('Stream ended on Dialer') + }) + + stream.end() + }) + } }