p5-RedisDB / RedisDB

Perl extension to access Redis
22 stars 11 forks source link

t/auth.t pass randomly #19

Closed scripter-v closed 10 years ago

scripter-v commented 10 years ago

I have run the test multiple times on same node and it doesn't work always. On some nodes i can't get this test pass. On some nodes it pass almost always. Seems like passing this test depend on some tcp-timings or something like that. I put 'sleep 30' into test and get connected to the test redis server. List of command doesn't depend on the test pass result and is always the same:

redis 127.0.0.1:50874> MONITOR
OK
1398426188.012124 "MONITOR"
1398426208.314498 "AUTH" "wrong pass"
1398426208.315114 "AUTH" "test"
1398426208.315804 "PING"
1398426208.316426 (db 1) "SELECT" "1"
1398426208.316553 (db 1) "SET" "Database" "1"
1398426208.316825 (db 1) "INFO"
1398426208.317591 "AUTH" "test"
1398426208.317705 (db 1) "SELECT" "1"
1398426208.317799 (db 1) "PING"
1398426208.318433 (db 1) "GET" "Database"
1398426208.319574 "AUTH" "wrong"
[scripter@router-1:~]$ 

I saved tcp dump when test passed and then failed. I can send dump to you if you need it. Here is two test runs one by one:

[scripter@router-1:~/work/git/RedisDB-2.30]$ perl -I lib t/auth.t
ok 1 - Couldn't ping before auth
ok 2 - Didn't accept wrong password
ok 3 - Authenticated
ok 4 - Can ping now
ok 5 - Still can ping server after reconnecting
ok 6 - Selected database 1
ok 7 - dies on reconnect if password is wrong
1..7
[scripter@router-1:~/work/git/RedisDB-2.30]$ perl -I lib t/auth.t
ok 1 - Couldn't ping before auth
ok 2 - Didn't accept wrong password
ok 3 - Authenticated
ok 4 - Can ping now
ok 5 - Still can ping server after reconnecting
ok 6 - Selected database 1
not ok 7 - dies on reconnect if password is wrong
#   Failed test 'dies on reconnect if password is wrong'
#   at t/auth.t line 23.
# expecting: Regexp ((?^i:invalid password))
# found: RedisDB::Error::DISCONNECTED (Connection error: Connection reset by peer)
1..7
# Looks like you failed 1 test of 7.

Test still pass randomly with 2.3103.

trinitum commented 10 years ago

Thank you for the report. I couldn't reproduce the problem myself, but I see what may be the reason. Can you please check if 0365318 fixes this random failure for you?

scripter-v commented 10 years ago

Yes, it fixes. After replacing "$redis->quit;" with "delete $redis->{_socket};" the test passes always.