Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
69bfffb4
Commit
69bfffb4
authored
Jan 09, 2011
by
antirez
Browse files
test adapted to run with diskstore, and a few bugs fixed
parent
5e1d2d30
Changes
7
Show whitespace changes
Inline
Side-by-side
src/aof.c
View file @
69bfffb4
...
@@ -529,7 +529,10 @@ int rewriteAppendOnlyFileBackground(void) {
...
@@ -529,7 +529,10 @@ int rewriteAppendOnlyFileBackground(void) {
pid_t
childpid
;
pid_t
childpid
;
if
(
server
.
bgrewritechildpid
!=
-
1
)
return
REDIS_ERR
;
if
(
server
.
bgrewritechildpid
!=
-
1
)
return
REDIS_ERR
;
redisAssert
(
server
.
ds_enabled
==
0
);
if
(
server
.
ds_enabled
!=
0
)
{
redisLog
(
REDIS_WARNING
,
"BGREWRITEAOF called with diskstore enabled: AOF is not supported when diskstore is enabled. Operation not performed."
);
return
REDIS_ERR
;
}
if
((
childpid
=
fork
())
==
0
)
{
if
((
childpid
=
fork
())
==
0
)
{
/* Child */
/* Child */
char
tmpfile
[
256
];
char
tmpfile
[
256
];
...
...
src/db.c
View file @
69bfffb4
...
@@ -201,7 +201,8 @@ int dbDelete(redisDb *db, robj *key) {
...
@@ -201,7 +201,8 @@ int dbDelete(redisDb *db, robj *key) {
return
dictDelete
(
db
->
dict
,
key
->
ptr
)
==
DICT_OK
;
return
dictDelete
(
db
->
dict
,
key
->
ptr
)
==
DICT_OK
;
}
}
/* Empty the whole database */
/* Empty the whole database.
* If diskstore is enabled this function will just flush the in-memory cache. */
long
long
emptyDb
()
{
long
long
emptyDb
()
{
int
j
;
int
j
;
long
long
removed
=
0
;
long
long
removed
=
0
;
...
@@ -210,6 +211,7 @@ long long emptyDb() {
...
@@ -210,6 +211,7 @@ long long emptyDb() {
removed
+=
dictSize
(
server
.
db
[
j
].
dict
);
removed
+=
dictSize
(
server
.
db
[
j
].
dict
);
dictEmpty
(
server
.
db
[
j
].
dict
);
dictEmpty
(
server
.
db
[
j
].
dict
);
dictEmpty
(
server
.
db
[
j
].
expires
);
dictEmpty
(
server
.
db
[
j
].
expires
);
if
(
server
.
ds_enabled
)
dictEmpty
(
server
.
db
[
j
].
io_negcache
);
}
}
return
removed
;
return
removed
;
}
}
...
...
src/debug.c
View file @
69bfffb4
...
@@ -177,7 +177,20 @@ void computeDatasetDigest(unsigned char *final) {
...
@@ -177,7 +177,20 @@ void computeDatasetDigest(unsigned char *final) {
void
debugCommand
(
redisClient
*
c
)
{
void
debugCommand
(
redisClient
*
c
)
{
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"segfault"
))
{
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"segfault"
))
{
*
((
char
*
)
-
1
)
=
'x'
;
*
((
char
*
)
-
1
)
=
'x'
;
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"flushcache"
))
{
if
(
!
server
.
ds_enabled
)
{
addReplyError
(
c
,
"DEBUG FLUSHCACHE called with diskstore off."
);
return
;
}
else
{
emptyDb
();
addReply
(
c
,
shared
.
ok
);
return
;
}
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"reload"
))
{
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"reload"
))
{
if
(
server
.
ds_enabled
)
{
addReply
(
c
,
shared
.
ok
);
return
;
}
if
(
rdbSave
(
server
.
dbfilename
)
!=
REDIS_OK
)
{
if
(
rdbSave
(
server
.
dbfilename
)
!=
REDIS_OK
)
{
addReply
(
c
,
shared
.
err
);
addReply
(
c
,
shared
.
err
);
return
;
return
;
...
...
src/diskstore.c
View file @
69bfffb4
...
@@ -456,7 +456,7 @@ void *dsRdbSave_thread(void *arg) {
...
@@ -456,7 +456,7 @@ void *dsRdbSave_thread(void *arg) {
/* Use RENAME to make sure the DB file is changed atomically only
/* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */
* if the generate DB file is ok. */
if
(
rename
(
tmpfile
,
filename
)
==
-
1
)
{
if
(
rename
(
tmpfile
,
filename
)
==
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Error moving temp DB file on the final destination: %s"
,
strerror
(
errno
));
redisLog
(
REDIS_WARNING
,
"Error moving temp DB file on the final destination: %s
(diskstore)
"
,
strerror
(
errno
));
unlink
(
tmpfile
);
unlink
(
tmpfile
);
dsRdbSaveSetState
(
REDIS_BGSAVE_THREAD_DONE_ERR
);
dsRdbSaveSetState
(
REDIS_BGSAVE_THREAD_DONE_ERR
);
return
NULL
;
return
NULL
;
...
...
src/dscache.c
View file @
69bfffb4
...
@@ -185,8 +185,7 @@ int cacheFreeOneEntry(void) {
...
@@ -185,8 +185,7 @@ int cacheFreeOneEntry(void) {
* are swappable objects */
* are swappable objects */
int
maxtries
=
100
;
int
maxtries
=
100
;
if
(
dictSize
(
db
->
dict
)
==
0
)
continue
;
for
(
i
=
0
;
i
<
5
&&
dictSize
(
db
->
dict
);
i
++
)
{
for
(
i
=
0
;
i
<
5
;
i
++
)
{
dictEntry
*
de
;
dictEntry
*
de
;
double
swappability
;
double
swappability
;
robj
keyobj
;
robj
keyobj
;
...
...
tests/test_helper.tcl
View file @
69bfffb4
...
@@ -13,7 +13,7 @@ set ::host 127.0.0.1
...
@@ -13,7 +13,7 @@ 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
0
set ::verbose
1
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
...
@@ -104,14 +104,13 @@ proc s {args} {
...
@@ -104,14 +104,13 @@ proc s {args} {
}
}
proc cleanup
{}
{
proc cleanup
{}
{
if
{
$::diskstore
}
{
puts
"Cleanup: warning may take some time..."
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.*
]}
}
}
proc execute_everything
{}
{
proc execute_everything
{}
{
if 0
{
execute_tests
"unit/auth"
execute_tests
"unit/auth"
execute_tests
"unit/protocol"
execute_tests
"unit/protocol"
execute_tests
"unit/basic"
execute_tests
"unit/basic"
...
@@ -128,9 +127,11 @@ proc execute_everything {} {
...
@@ -128,9 +127,11 @@ proc execute_everything {} {
execute_tests
"integration/aof"
execute_tests
"integration/aof"
# execute_tests
"integration/redis-cli"
# execute_tests
"integration/redis-cli"
execute_tests
"unit/pubsub"
execute_tests
"unit/pubsub"
}
# run tests with diskstore enabled
# run tests with diskstore enabled
set ::diskstore 1
set ::diskstore 1
lappend ::denytags nodiskstore
set ::global_overrides
{
diskstore-enabled yes
}
set ::global_overrides
{
diskstore-enabled yes
}
execute_tests
"unit/protocol"
execute_tests
"unit/protocol"
execute_tests
"unit/basic"
execute_tests
"unit/basic"
...
...
tests/unit/other.tcl
View file @
69bfffb4
...
@@ -46,7 +46,7 @@ start_server {tags {"other"}} {
...
@@ -46,7 +46,7 @@ start_server {tags {"other"}} {
set _ $err
set _ $err
}
{
*invalid*
}
}
{
*invalid*
}
tags
{
consistency
}
{
tags
{
consistency
nodiskstore
}
{
if
{
!
[
catch
{
package require sha1
}]}
{
if
{
!
[
catch
{
package require sha1
}]}
{
test
{
Check consistency of different data types after a reload
}
{
test
{
Check consistency of different data types after a reload
}
{
r flushdb
r flushdb
...
@@ -102,12 +102,19 @@ start_server {tags {"other"}} {
...
@@ -102,12 +102,19 @@ start_server {tags {"other"}} {
r flushdb
r flushdb
r set x 10
r set x 10
r expire x 1000
r expire x 1000
if
{
$::diskstore
}
{
r debug flushcache
}
else
{
r save
r save
r debug reload
r debug reload
}
set ttl
[
r ttl x
]
set ttl
[
r ttl x
]
set e1
[
expr
{
$ttl
> 900 && $ttl <= 1000
}]
set e1
[
expr
{
$ttl
> 900 && $ttl <= 1000
}]
if
{
!$::diskstore
}
{
r bgrewriteaof
r bgrewriteaof
waitForBgrewriteaof r
waitForBgrewriteaof r
r debug loadaof
}
set ttl
[
r ttl x
]
set ttl
[
r ttl x
]
set e2
[
expr
{
$ttl
> 900 && $ttl <= 1000
}]
set e2
[
expr
{
$ttl
> 900 && $ttl <= 1000
}]
list $e1 $e2
list $e1 $e2
...
...
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