#NEWLINE# def test_custom_slowlog( self ) : #NEWLINE# #INDENT# port = NOAUTH_PORT #NEWLINE# test_key = 'testkey' #NEWLINE# instance = { #NEWLINE# #INDENT# 'host' : 'localhost' , #NEWLINE# 'port' : port , #NEWLINE# 'slowlog-max-len' : 1 , #NEWLINE# #UNINDENT# } #NEWLINE# db = redis . Redis ( port = port , db = 14 ) #NEWLINE# old_sl_thresh = db . config_get ( 'slowlog-log-slower-than' ) [ 'slowlog-log-slower-than' ] #NEWLINE# db . config_set ( 'slowlog-log-slower-than' , 0 ) #NEWLINE# db . flushdb ( ) #NEWLINE# for i in range ( 100 ) : #NEWLINE# #INDENT# db . lpush ( test_key , random . random ( ) ) #NEWLINE# #UNINDENT# db . sort ( test_key ) #NEWLINE# db . config_set ( 'slowlog-log-slower-than' , old_sl_thresh ) #NEWLINE# self . assertTrue ( ( db . slowlog_len ( ) > 0 ) ) #NEWLINE# self . run_check ( { #NEWLINE# #INDENT# 'init_config' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'instances' : [ old_sl_thresh ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert self . metrics , 'No metrics returned' #NEWLINE# self . assertMetric ( 'redis.slowlog.micros.count' , tags = [ 'command:SORT' , 'redis_host:localhost' , 'redis_port:{0}' . format ( port ) ] , value = 1.0 )