Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ab8232d0
Commit
ab8232d0
authored
Apr 02, 2012
by
antirez
Browse files
DUMP, RESTORE, MIGRATE tests.
parent
70d848e1
Changes
2
Show whitespace changes
Inline
Side-by-side
tests/test_helper.tcl
View file @
ab8232d0
...
@@ -39,6 +39,7 @@ set ::all_tests {
...
@@ -39,6 +39,7 @@ set ::all_tests {
unit/maxmemory
unit/maxmemory
unit/introspection
unit/introspection
unit/obuf-limits
unit/obuf-limits
unit/dump
}
}
# Index to the next test to run in the ::all_tests list.
# Index to the next test to run in the ::all_tests list.
set ::next_test 0
set ::next_test 0
...
...
tests/unit/dump.tcl
0 → 100644
View file @
ab8232d0
start_server
{
tags
{
"dump"
}}
{
test
{
DUMP / RESTORE are able to serialize / unserialize a simple key
}
{
r set foo bar
set encoded
[
r dump foo
]
r del foo
list
[
r exists foo
]
[
r restore foo 0 $encoded
]
[
r ttl foo
]
[
r get foo
]
}
{
0 OK -1 bar
}
test
{
RESTORE can set an arbitrary expire to the materialized key
}
{
r set foo bar
set encoded
[
r dump foo
]
r del foo
r restore foo 5000 $encoded
set ttl
[
r pttl foo
]
assert
{
$ttl
>= 3000 && $ttl <= 5000
}
r get foo
}
{
bar
}
test
{
RESTORE returns an error of the key already exists
}
{
r set foo bar
set e
{}
catch
{
r restore foo 0
"..."
}
e
set e
}
{
*is busy*
}
test
{
DUMP of non existing key returns nil
}
{
r dump nonexisting_key
}
{}
test
{
MIGRATE is able to migrate a key between two instances
}
{
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 ret
[
r -1 migrate $second_host $second_port key 9 5000
]
assert
{
$ret
eq
{
OK
}}
assert
{[
$first
exists key
]
== 0
}
assert
{[
$second
exists key
]
== 1
}
assert
{[
$second
get key
]
eq
{
Some Value
}}
}
}
test
{
MIGRATE timeout actually works
}
{
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.
set e
{}
catch
{
r -1 migrate $second_host $second_port key 9 1000
}
e
assert_match
{
ERR*
}
$e
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment