@@ -643,14 +643,14 @@ describe('parsers', function () {
643
643
assert . strictEqual ( replyCount , 3 )
644
644
parser . execute ( new Buffer ( '\r\n' ) )
645
645
assert . strictEqual ( replyCount , 4 )
646
- } , 200 )
646
+ } , 25 )
647
647
// Delay done so the bufferPool is cleared and tested
648
648
// If the buffer is not cleared, the coverage is not going to be at 100
649
649
setTimeout ( function ( ) {
650
650
var totalBuffer = Buffer . concat ( chunks ) . toString ( )
651
651
assert . strictEqual ( replies [ 3 ] . toString ( ) , totalBuffer )
652
652
done ( )
653
- } , ( jsParser ? 1800 : 250 ) )
653
+ } , ( jsParser ? 1500 : 50 ) )
654
654
} )
655
655
656
656
it ( 'handle big data' , function ( ) {
@@ -719,20 +719,22 @@ describe('parsers', function () {
719
719
assert . strictEqual ( replyCount , 2 )
720
720
} )
721
721
722
- it ( 'handle big data 2 with buffers' , function ( ) {
722
+ it ( 'handle big data 2 with buffers' , function ( done ) {
723
+ this . timeout ( 4000 )
723
724
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
724
725
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' +
725
726
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
726
727
'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
727
728
var bigStringArray = ( new Array ( Math . pow ( 2 , 16 ) / lorem . length ) . join ( lorem + ' ' ) ) . split ( ' ' ) // Math.pow(2, 16) chars long
728
- var startBigBuffer = new Buffer ( '$' + ( 4 * 1024 * 1024 ) + '\r\n' )
729
- var chunks = new Array ( 64 )
730
- for ( var i = 0 ; i < 64 ; i ++ ) {
729
+ var startBigBuffer = new Buffer ( '$' + ( 200 * 1024 * 1024 ) + '\r\n' )
730
+ var chunks = new Array ( 3200 )
731
+ for ( var i = 0 ; i < 3200 ; i ++ ) {
731
732
chunks [ i ] = new Buffer ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
732
733
}
733
734
var replyCount = 0
735
+ var replyLen = [ 200 * 1024 * 1024 , 11 , 11 ]
734
736
function checkReply ( reply ) {
735
- assert . strictEqual ( reply . length , 4 * 1024 * 1024 )
737
+ assert . strictEqual ( reply . length , replyLen [ replyCount ] )
736
738
replyCount ++
737
739
}
738
740
var parser = new Parser ( {
@@ -742,15 +744,21 @@ describe('parsers', function () {
742
744
returnBuffers : true
743
745
} )
744
746
parser . execute ( startBigBuffer )
745
- for ( i = 0 ; i < 64 ; i ++ ) {
747
+ for ( i = 0 ; i < 3200 ; i ++ ) {
746
748
if ( Parser . name === 'JavascriptRedisParser' ) {
747
749
assert . strictEqual ( parser . bufferCache . length , i + 1 )
748
750
}
749
751
parser . execute ( chunks [ i ] )
750
752
}
751
753
assert . strictEqual ( replyCount , 0 )
752
- parser . execute ( new Buffer ( '\r\n' ) )
754
+ parser . execute ( new Buffer ( '\r\n+hello world ' ) )
753
755
assert . strictEqual ( replyCount , 1 )
756
+ parser . execute ( new Buffer ( '\r\n$11\r\nhuge' ) )
757
+ setTimeout ( function ( ) {
758
+ parser . execute ( new Buffer ( ' buffer\r\n' ) )
759
+ assert . strictEqual ( replyCount , 3 )
760
+ done ( )
761
+ } , 600 )
754
762
} )
755
763
} )
756
764
} )
0 commit comments