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
5e1d2d30
Commit
5e1d2d30
authored
Jan 09, 2011
by
antirez
Browse files
initial fix of the test suite to run both in in-memory and diskstore mode
parent
67a1810b
Changes
5
Show whitespace changes
Inline
Side-by-side
src/zmalloc.c
View file @
5e1d2d30
...
@@ -186,7 +186,7 @@ size_t zmalloc_used_memory(void) {
...
@@ -186,7 +186,7 @@ size_t zmalloc_used_memory(void) {
}
}
size_t
zmalloc_allocations_for_size
(
size_t
size
)
{
size_t
zmalloc_allocations_for_size
(
size_t
size
)
{
if
(
size
>
ZMALLOC_MAX_ALLOC_STAT
||
size
<
0
)
return
0
;
if
(
size
>
ZMALLOC_MAX_ALLOC_STAT
)
return
0
;
return
zmalloc_allocations
[
size
];
return
zmalloc_allocations
[
size
];
}
}
...
...
tests/assets/default.conf
View file @
5e1d2d30
...
@@ -18,9 +18,9 @@ daemonize no
...
@@ -18,9 +18,9 @@ daemonize no
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
# default. You can specify a custom pid file location here.
pidfile
redis
.
pid
pidfile
/
var
/
run
/
redis
.
pid
# Accept connections on the specified port, default is 6379
# Accept connections on the specified port, default is 6379
.
port
6379
port
6379
# If you want you can bind a single interface, if the bind option is not
# If you want you can bind a single interface, if the bind option is not
...
@@ -28,6 +28,12 @@ port 6379
...
@@ -28,6 +28,12 @@ port 6379
#
#
# bind 127.0.0.1
# bind 127.0.0.1
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# Close the connection after a client is idle for N seconds (0 to disable)
# Close the connection after a client is idle for N seconds (0 to disable)
timeout
300
timeout
300
...
@@ -44,6 +50,16 @@ loglevel verbose
...
@@ -44,6 +50,16 @@ loglevel verbose
# output for logging but daemonize, logs will be sent to /dev/null
# output for logging but daemonize, logs will be sent to /dev/null
logfile
stdout
logfile
stdout
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no
# Specify the syslog identity.
# syslog-ident redis
# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0
# Set the number of databases. The default database is DB 0, you can select
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
# dbid is a number between 0 and 'databases'-1
...
@@ -86,7 +102,7 @@ dbfilename dump.rdb
...
@@ -86,7 +102,7 @@ dbfilename dump.rdb
# Also the Append Only File will be created inside this directory.
# Also the Append Only File will be created inside this directory.
#
#
# Note that you must specify a directory here, not a file name.
# Note that you must specify a directory here, not a file name.
dir
/
tmp
dir
.
/
################################# REPLICATION #################################
################################# REPLICATION #################################
...
@@ -104,6 +120,19 @@ dir /tmp
...
@@ -104,6 +120,19 @@ dir /tmp
#
#
# masterauth <master-password>
# masterauth <master-password>
# When a slave lost the connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
# still reply to client requests, possibly with out of data data, or the
# data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
# an error "SYNC with master in progress" to all the kind of commands
# but to INFO and SLAVEOF.
#
slave
-
serve
-
stale
-
data
yes
################################## SECURITY ###################################
################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
# Require clients to issue AUTH <PASSWORD> before processing any other
...
@@ -119,6 +148,22 @@ dir /tmp
...
@@ -119,6 +148,22 @@ dir /tmp
#
#
# requirepass foobared
# requirepass foobared
# Command renaming.
#
# It is possilbe to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# of hard to guess so that it will be still available for internal-use
# tools but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possilbe to completely kill a command renaming it into
# an empty string:
#
# rename-command CONFIG ""
################################### LIMITS ####################################
################################### LIMITS ####################################
# Set the max number of connected clients at the same time. By default there
# Set the max number of connected clients at the same time. By default there
...
@@ -148,6 +193,37 @@ dir /tmp
...
@@ -148,6 +193,37 @@ dir /tmp
#
#
# maxmemory <bytes>
# maxmemory <bytes>
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached? You can select among five behavior:
#
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys->random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
#
# Note: with all the kind of policies, Redis will return an error on write
# operations, when there are not suitable keys for eviction.
#
# At the date of writing this commands are: set setnx setex append
# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
# getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy volatile-lru
# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can select as well the sample
# size to check. For instance for default Redis will check three keys and
# pick the one that was used less recently, you can change the sample size
# using the following configuration directive.
#
# maxmemory-samples 3
############################## APPEND ONLY MODE ###############################
############################## APPEND ONLY MODE ###############################
# By default Redis asynchronously dumps the dataset on disk. If you can live
# By default Redis asynchronously dumps the dataset on disk. If you can live
...
@@ -195,29 +271,54 @@ appendonly no
...
@@ -195,29 +271,54 @@ appendonly no
appendfsync
everysec
appendfsync
everysec
# appendfsync no
# appendfsync no
################################ VIRTUAL MEMORY ###############################
# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving the durability of Redis is
# the same as "appendfsync none", that in pratical terms means that it is
# possible to lost up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
no
-
appendfsync
-
on
-
rewrite
no
#################################### DISK STORE ###############################
#
Virtual Memory allows
Redis
to
work
with datasets bigger than the actual
#
When disk store is active
Redis work
s as an on-disk database, where memory
#
amount of RAM needed to hold the whole dataset in memory
.
#
is only used as a object cache
.
#
In order to do so very used keys are taken in memory while the other keys
#
#
are swapped into a swap file, similarly to what operating systems do
#
This mode is good for datasets that are bigger than memory, and in general
# w
ith memory pages.
# w
hen you want to trade speed for:
#
#
# To enable VM just set 'vm-enabled' to yes, and set the following three
# - less memory used
# VM parameters accordingly to your needs.
# - immediate server restart
# - per key durability, without need for backgrond savig
#
# On the other hand, with disk store enabled MULTI/EXEC are no longer
# transactional from the point of view of the persistence on disk, that is,
# Redis transactions will still guarantee that commands are either processed
# all or nothing, but there is no guarantee that all the keys are flushed
# on disk in an atomic way.
#
# Of course with disk store enabled Redis is not as fast as it is when
# working with just the memory back end.
diskstore
-
enabled
yes
diskstore
-
enabled
no
diskstore
-
path
redis
.
ds
diskstore
-
path
redis
.
ds
cache
-
max
-
memory
0
cache
-
max
-
memory
0
cache
-
flush
-
delay
0
cache
-
flush
-
delay
0
############################### ADVANCED CONFIG ###############################
############################### ADVANCED CONFIG ###############################
# Glue small output buffers together in order to send small replies in a
# single TCP packet. Uses a bit more CPU but most of the times it is a win
# in terms of number of queries per second. Use 'yes' if unsure.
glueoutputbuf
yes
# Hashes are encoded in a special way (much more memory efficient) when they
# Hashes are encoded in a special way (much more memory efficient) when they
# have at max a given numer of elements, and the biggest element does not
# have at max a given numer of elements, and the biggest element does not
# exceed a given threshold. You can configure this limits with the following
# exceed a given threshold. You can configure this limits with the following
...
@@ -225,6 +326,19 @@ glueoutputbuf yes
...
@@ -225,6 +326,19 @@ glueoutputbuf yes
hash
-
max
-
zipmap
-
entries
64
hash
-
max
-
zipmap
-
entries
64
hash
-
max
-
zipmap
-
value
512
hash
-
max
-
zipmap
-
value
512
# Similarly to hashes, small lists are also encoded in a special way in order
# to save a lot of space. The special representation is only used when
# you are under the following limits:
list
-
max
-
ziplist
-
entries
512
list
-
max
-
ziplist
-
value
64
# Sets have a special encoding in just one case: when a set is composed
# of just strings that happens to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set
-
max
-
intset
-
entries
512
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation redis uses (see dict.c)
# keys to values). The hash table implementation redis uses (see dict.c)
...
...
tests/support/server.tcl
View file @
5e1d2d30
...
@@ -177,9 +177,6 @@ proc start_server {options {code undefined}} {
...
@@ -177,9 +177,6 @@ proc start_server {options {code undefined}} {
if
{
$::valgrind
}
{
if
{
$::valgrind
}
{
exec valgrind --suppressions=src/valgrind.sup src/redis-server $config_file > $stdout 2> $stderr &
exec valgrind --suppressions=src/valgrind.sup src/redis-server $config_file > $stdout 2> $stderr &
}
else
{
}
else
{
if
{
$::verbose
}
{
puts
"Logging on
$stdout
/
$stderr
"
}
exec src/redis-server $config_file > $stdout 2> $stderr &
exec src/redis-server $config_file > $stdout 2> $stderr &
}
}
...
...
tests/support/tmpfile.tcl
View file @
5e1d2d30
...
@@ -4,7 +4,13 @@ file mkdir $::tmproot
...
@@ -4,7 +4,13 @@ file mkdir $::tmproot
# returns a dirname unique to this process to write to
# returns a dirname unique to this process to write to
proc tmpdir
{
basename
}
{
proc tmpdir
{
basename
}
{
if
{
$::diskstore
}
{
# For diskstore we want to use the same dir again and again
# otherwise everything is too slow.
set dir
[
file join $::tmproot $basename.diskstore
]
}
else
{
set dir
[
file join $::tmproot $basename.
[
pid
]
.
[
incr ::tmpcounter
]]
set dir
[
file join $::tmproot $basename.
[
pid
]
.
[
incr ::tmpcounter
]]
}
file mkdir $dir
file mkdir $dir
set _ $dir
set _ $dir
}
}
...
...
tests/test_helper.tcl
View file @
5e1d2d30
...
@@ -13,12 +13,13 @@ set ::host 127.0.0.1
...
@@ -13,12 +13,13 @@ set ::host 127.0.0.1
set ::port 16379
set ::port 16379
set ::traceleaks 0
set ::traceleaks 0
set ::valgrind 0
set ::valgrind 0
set ::verbose
1
set ::verbose
0
set ::denytags
{}
set ::denytags
{}
set ::allowtags
{}
set ::allowtags
{}
set ::external 0
;
# If
"1"
this means, we are running against external instance
set ::external 0
;
# If
"1"
this means, we are running against external instance
set ::file
""
;
# If set, runs only the tests in this comma separated list
set ::file
""
;
# If set, runs only the tests in this comma separated list
set ::curfile
""
;
# Hold the filename of the current suite
set ::curfile
""
;
# Hold the filename of the current suite
set ::diskstore 0
;
# Don't touch this by hand. The test itself will toggle it.
proc execute_tests name
{
proc execute_tests name
{
set path
"tests/
$name.tcl
"
set path
"tests/
$name.tcl
"
...
@@ -103,6 +104,9 @@ proc s {args} {
...
@@ -103,6 +104,9 @@ proc s {args} {
}
}
proc cleanup
{}
{
proc cleanup
{}
{
if
{
$::diskstore
}
{
puts
"Cleanup: warning may take some minute (diskstore enabled)"
}
catch
{
exec rm -rf
{*}
[
glob tests/tmp/redis.conf.*
]}
catch
{
exec rm -rf
{*}
[
glob tests/tmp/redis.conf.*
]}
catch
{
exec rm -rf
{*}
[
glob tests/tmp/server.*
]}
catch
{
exec rm -rf
{*}
[
glob tests/tmp/server.*
]}
}
}
...
@@ -125,8 +129,9 @@ proc execute_everything {} {
...
@@ -125,8 +129,9 @@ proc execute_everything {} {
# execute_tests
"integration/redis-cli"
# execute_tests
"integration/redis-cli"
execute_tests
"unit/pubsub"
execute_tests
"unit/pubsub"
# run tests with VM enabled
# run tests with diskstore enabled
set ::global_overrides
{
vm-enabled yes
}
set ::diskstore 1
set ::global_overrides
{
diskstore-enabled yes
}
execute_tests
"unit/protocol"
execute_tests
"unit/protocol"
execute_tests
"unit/basic"
execute_tests
"unit/basic"
execute_tests
"unit/type/list"
execute_tests
"unit/type/list"
...
...
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