From 989a7820ca0cb1b88493797fdecd2e7168558859 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 14 Nov 2012 12:12:52 +0100 Subject: [PATCH] Test: more MIGRATE tests. --- tests/test_helper.tcl | 2 +- tests/unit/dump.tcl | 44 ++++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/tests/test_helper.tcl b/tests/test_helper.tcl index 853193cc..a376b8bb 100644 --- a/tests/test_helper.tcl +++ b/tests/test_helper.tcl @@ -11,6 +11,7 @@ source tests/support/util.tcl set ::all_tests { unit/printver + unit/dump unit/auth unit/protocol unit/basic @@ -40,7 +41,6 @@ set ::all_tests { unit/introspection unit/limits unit/obuf-limits - unit/dump unit/bitops } # Index to the next test to run in the ::all_tests list. diff --git a/tests/unit/dump.tcl b/tests/unit/dump.tcl index 4ebce0ca..5c729136 100644 --- a/tests/unit/dump.tcl +++ b/tests/unit/dump.tcl @@ -43,6 +43,27 @@ start_server {tags {"dump"}} { r dump nonexisting_key } {} + test {MIGRATE is caching connections} { + # Note, we run this as first test so that the connection cache + # is empty. + set first [srv 0 client] + r set key "Some Value" + start_server {tags {"repl"}} { + set second [srv 0 client] + set second_host [srv 0 host] + set second_port [srv 0 port] + + assert_match {*migrate_cached_sockets:0*} [r -1 info] + r -1 migrate $second_host $second_port key 9 1000 + assert_match {*migrate_cached_sockets:1*} [r -1 info] + } + } + + test {MIGRATE cached connections are released after some time} { + after 15000 + assert_match {*migrate_cached_sockets:0*} [r info] + } + test {MIGRATE is able to migrate a key between two instances} { set first [srv 0 client] r set key "Some Value" @@ -180,28 +201,9 @@ start_server {tags {"dump"}} { assert {[$second exists key] == 0} set rd [redis_deferring_client] - $rd debug sleep 5.0 ; # Make second server unable to reply. - set e {} - catch {r -1 migrate $second_host $second_port key 9 1000} e - assert_match {IOERR*} $e - } - } - - test {MIGRATE is caching connections} { - set first [srv 0 client] - r set key "Some Value" - start_server {tags {"repl"}} { - set second [srv 0 client] - set second_host [srv 0 host] - set second_port [srv 0 port] - - assert {[$first exists key] == 1} - assert {[$second exists key] == 0} - - set rd [redis_deferring_client] - $rd debug sleep 5.0 ; # Make second server unable to reply. + $rd debug sleep 1.0 ; # Make second server unable to reply. set e {} - catch {r -1 migrate $second_host $second_port key 9 1000} e + catch {r -1 migrate $second_host $second_port key 9 500} e assert_match {IOERR*} $e } } -- 2.45.2