1 start_server
{tags
{"dump"}} {
2 test
{DUMP
/ RESTORE are able to serialize
/ unserialize a simple key
} {
4 set encoded
[r dump foo
]
6 list [r exists foo
] [r restore foo
0 $encoded] [r ttl foo
] [r get foo
]
9 test
{RESTORE can
set an arbitrary expire to the materialized key
} {
11 set encoded
[r dump foo
]
13 r restore foo
5000 $encoded
15 assert
{$ttl >= 3000 && $ttl <= 5000}
19 test
{RESTORE returns an
error of the key already exists
} {
22 catch {r restore foo
0 "..."} e
26 test
{DUMP of non existing key returns nil
} {
27 r dump nonexisting_key
30 test
{MIGRATE is able to migrate a key between two instances
} {
31 set first
[srv
0 client
]
32 r
set key
"Some Value"
33 start_server
{tags
{"repl"}} {
34 set second
[srv
0 client
]
35 set second_host
[srv
0 host
]
36 set second_port
[srv
0 port
]
38 assert
{[$first exists key
] == 1}
39 assert
{[$second exists key
] == 0}
40 set ret
[r
-1 migrate
$second_host $second_port key
9 5000]
42 assert
{[$first exists key
] == 0}
43 assert
{[$second exists key
] == 1}
44 assert
{[$second get key
] eq
{Some Value
}}
48 test
{MIGRATE timeout actually works
} {
49 set first
[srv
0 client
]
50 r
set key
"Some Value"
51 start_server
{tags
{"repl"}} {
52 set second
[srv
0 client
]
53 set second_host
[srv
0 host
]
54 set second_port
[srv
0 port
]
56 assert
{[$first exists key
] == 1}
57 assert
{[$second exists key
] == 0}
59 set rd
[redis_deferring_client
]
60 $rd debug sleep
5.0 ; # Make second server unable to reply.
62 catch {r
-1 migrate
$second_host $second_port key
9 1000} e
63 assert_match
{IOERR
*} $e