test adapted to run with diskstore, and a few bugs fixed
This commit is contained in:
parent
5e1d2d30f7
commit
69bfffb4a7
@ -529,7 +529,10 @@ int rewriteAppendOnlyFileBackground(void) {
|
||||
pid_t childpid;
|
||||
|
||||
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) {
|
||||
/* Child */
|
||||
char tmpfile[256];
|
||||
|
4
src/db.c
4
src/db.c
@ -201,7 +201,8 @@ int dbDelete(redisDb *db, robj *key) {
|
||||
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() {
|
||||
int j;
|
||||
long long removed = 0;
|
||||
@ -210,6 +211,7 @@ long long emptyDb() {
|
||||
removed += dictSize(server.db[j].dict);
|
||||
dictEmpty(server.db[j].dict);
|
||||
dictEmpty(server.db[j].expires);
|
||||
if (server.ds_enabled) dictEmpty(server.db[j].io_negcache);
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
13
src/debug.c
13
src/debug.c
@ -177,7 +177,20 @@ void computeDatasetDigest(unsigned char *final) {
|
||||
void debugCommand(redisClient *c) {
|
||||
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
||||
*((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")) {
|
||||
if (server.ds_enabled) {
|
||||
addReply(c,shared.ok);
|
||||
return;
|
||||
}
|
||||
if (rdbSave(server.dbfilename) != REDIS_OK) {
|
||||
addReply(c,shared.err);
|
||||
return;
|
||||
|
@ -456,7 +456,7 @@ void *dsRdbSave_thread(void *arg) {
|
||||
/* Use RENAME to make sure the DB file is changed atomically only
|
||||
* if the generate DB file is ok. */
|
||||
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);
|
||||
dsRdbSaveSetState(REDIS_BGSAVE_THREAD_DONE_ERR);
|
||||
return NULL;
|
||||
|
@ -185,8 +185,7 @@ int cacheFreeOneEntry(void) {
|
||||
* are swappable objects */
|
||||
int maxtries = 100;
|
||||
|
||||
if (dictSize(db->dict) == 0) continue;
|
||||
for (i = 0; i < 5; i++) {
|
||||
for (i = 0; i < 5 && dictSize(db->dict); i++) {
|
||||
dictEntry *de;
|
||||
double swappability;
|
||||
robj keyobj;
|
||||
|
@ -13,7 +13,7 @@ set ::host 127.0.0.1
|
||||
set ::port 16379
|
||||
set ::traceleaks 0
|
||||
set ::valgrind 0
|
||||
set ::verbose 0
|
||||
set ::verbose 1
|
||||
set ::denytags {}
|
||||
set ::allowtags {}
|
||||
set ::external 0; # If "1" this means, we are running against external instance
|
||||
@ -104,14 +104,13 @@ proc s {args} {
|
||||
}
|
||||
|
||||
proc cleanup {} {
|
||||
if {$::diskstore} {
|
||||
puts "Cleanup: warning may take some minute (diskstore enabled)"
|
||||
}
|
||||
puts "Cleanup: warning may take some time..."
|
||||
catch {exec rm -rf {*}[glob tests/tmp/redis.conf.*]}
|
||||
catch {exec rm -rf {*}[glob tests/tmp/server.*]}
|
||||
}
|
||||
|
||||
proc execute_everything {} {
|
||||
if 0 {
|
||||
execute_tests "unit/auth"
|
||||
execute_tests "unit/protocol"
|
||||
execute_tests "unit/basic"
|
||||
@ -128,9 +127,11 @@ proc execute_everything {} {
|
||||
execute_tests "integration/aof"
|
||||
# execute_tests "integration/redis-cli"
|
||||
execute_tests "unit/pubsub"
|
||||
}
|
||||
|
||||
# run tests with diskstore enabled
|
||||
set ::diskstore 1
|
||||
lappend ::denytags nodiskstore
|
||||
set ::global_overrides {diskstore-enabled yes}
|
||||
execute_tests "unit/protocol"
|
||||
execute_tests "unit/basic"
|
||||
|
@ -46,7 +46,7 @@ start_server {tags {"other"}} {
|
||||
set _ $err
|
||||
} {*invalid*}
|
||||
|
||||
tags {consistency} {
|
||||
tags {consistency nodiskstore} {
|
||||
if {![catch {package require sha1}]} {
|
||||
test {Check consistency of different data types after a reload} {
|
||||
r flushdb
|
||||
@ -102,12 +102,19 @@ start_server {tags {"other"}} {
|
||||
r flushdb
|
||||
r set x 10
|
||||
r expire x 1000
|
||||
r save
|
||||
r debug reload
|
||||
if {$::diskstore} {
|
||||
r debug flushcache
|
||||
} else {
|
||||
r save
|
||||
r debug reload
|
||||
}
|
||||
set ttl [r ttl x]
|
||||
set e1 [expr {$ttl > 900 && $ttl <= 1000}]
|
||||
r bgrewriteaof
|
||||
waitForBgrewriteaof r
|
||||
if {!$::diskstore} {
|
||||
r bgrewriteaof
|
||||
waitForBgrewriteaof r
|
||||
r debug loadaof
|
||||
}
|
||||
set ttl [r ttl x]
|
||||
set e2 [expr {$ttl > 900 && $ttl <= 1000}]
|
||||
list $e1 $e2
|
||||
|
Loading…
x
Reference in New Issue
Block a user