2
2
3
3
var assert = require ( 'assert' ) ;
4
4
var Parser = require ( "../../lib/parser/javascript" ) . Parser ;
5
+ var config = require ( "../lib/config" ) ;
6
+ var redis = config . redis ;
5
7
6
8
describe ( 'javascript parser' , function ( ) {
7
9
it ( 'handles multi-bulk reply' , function ( done ) {
@@ -24,4 +26,36 @@ describe('javascript parser', function () {
24
26
assert . equal ( reply_count , 3 , "check reply should have been called three times" ) ;
25
27
return done ( ) ;
26
28
} ) ;
29
+
30
+ // Activate this if you want to fry your cpu / memory
31
+ describe . skip ( "test out of memory" , function ( ) {
32
+ var args = config . configureClient ( 'javascript' , '127.0.0.1' ) ;
33
+ var clients = new Array ( 300 ) . join ( " " ) . split ( " " ) ;
34
+ var client ;
35
+ beforeEach ( function ( done ) {
36
+ client = redis . createClient . apply ( redis . createClient , args ) ;
37
+ client . once ( "connect" , function ( ) {
38
+ client . flushdb ( done ) ;
39
+ } ) ;
40
+ } ) ;
41
+
42
+ it ( 'reach limit and wait for further data' , function ( done ) {
43
+ setTimeout ( done , 5000 ) ;
44
+ clients . forEach ( function ( entry , a ) {
45
+ var max = 0 ;
46
+ var client = redis . createClient . apply ( redis . createClient , args ) ;
47
+ client . on ( 'ready' , function ( ) {
48
+ while ( ++ max < 50 ) {
49
+ var item = [ ] ;
50
+ for ( var i = 0 ; i < 100 ; ++ i ) {
51
+ item . push ( 'aaa' + ( Math . random ( ) * 1000000 | 0 ) ) ;
52
+ }
53
+ client . del ( 'foo' + a ) ;
54
+ client . lpush ( 'foo' + a , item ) ;
55
+ client . lrange ( 'foo' + a , 0 , 99 ) ;
56
+ }
57
+ } ) ;
58
+ } ) ;
59
+ } ) ;
60
+ } ) ;
27
61
} ) ;
0 commit comments