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
6ddcba6e
Commit
6ddcba6e
authored
Oct 09, 2015
by
antirez
Browse files
Test: basic lazyfree unit test.
parent
363c0f67
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/test_helper.tcl
View file @
6ddcba6e
...
@@ -51,6 +51,7 @@ set ::all_tests {
...
@@ -51,6 +51,7 @@ set ::all_tests {
unit/bitops
unit/bitops
unit/memefficiency
unit/memefficiency
unit/hyperloglog
unit/hyperloglog
unit/lazyfree
}
}
# 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/lazyfree.tcl
0 → 100644
View file @
6ddcba6e
start_server
{
tags
{
"lazyfree"
}}
{
test
"UNLINK can reclaim memory in background"
{
set orig_mem
[
s used_memory
]
set args
{}
for
{
set i 0
}
{
$i
< 100000
}
{
incr i
}
{
lappend args $i
}
r sadd myset
{*}
$args
assert
{[
r scard myset
]
== 100000
}
set peak_mem
[
s used_memory
]
assert
{[
r unlink myset
]
== 1
}
assert
{
$peak
_mem > $orig_mem+1000000
}
wait_for_condition 50 100
{
[
s used_memory
]
< $peak_mem &&
[
s used_memory
]
< $orig_mem*2
}
else
{
fail
"Memory is not reclaimed by UNLINK"
}
}
test
"FLUSHDB ASYNC can reclaim memory in background"
{
set orig_mem
[
s used_memory
]
set args
{}
for
{
set i 0
}
{
$i
< 100000
}
{
incr i
}
{
lappend args $i
}
r sadd myset
{*}
$args
assert
{[
r scard myset
]
== 100000
}
set peak_mem
[
s used_memory
]
r flushdb async
assert
{
$peak
_mem > $orig_mem+1000000
}
wait_for_condition 50 100
{
[
s used_memory
]
< $peak_mem &&
[
s used_memory
]
< $orig_mem*2
}
else
{
fail
"Memory is not reclaimed by FLUSHDB ASYNC"
}
}
}
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