mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
test infra - reduce disk space usage
this is important when running a test with --loop
This commit is contained in:
parent
9d527d076b
commit
e3e69c25fd
@ -25,7 +25,7 @@ start_server [list overrides [list "dir" $server_path "dbfilename" "encodings.rd
|
||||
|
||||
set server_path [tmpdir "server.rdb-startup-test"]
|
||||
|
||||
start_server [list overrides [list "dir" $server_path]] {
|
||||
start_server [list overrides [list "dir" $server_path] keep_persistence true] {
|
||||
test {Server started empty with non-existing RDB file} {
|
||||
r debug digest
|
||||
} {0000000000000000000000000000000000000000}
|
||||
@ -33,13 +33,13 @@ start_server [list overrides [list "dir" $server_path]] {
|
||||
r save
|
||||
}
|
||||
|
||||
start_server [list overrides [list "dir" $server_path]] {
|
||||
start_server [list overrides [list "dir" $server_path] keep_persistence true] {
|
||||
test {Server started empty with empty RDB file} {
|
||||
r debug digest
|
||||
} {0000000000000000000000000000000000000000}
|
||||
}
|
||||
|
||||
start_server [list overrides [list "dir" $server_path]] {
|
||||
start_server [list overrides [list "dir" $server_path] keep_persistence true] {
|
||||
test {Test RDB stream encoding} {
|
||||
for {set j 0} {$j < 1000} {incr j} {
|
||||
if {rand() < 0.9} {
|
||||
@ -64,7 +64,7 @@ set defaults {}
|
||||
proc start_server_and_kill_it {overrides code} {
|
||||
upvar defaults defaults srv srv server_path server_path
|
||||
set config [concat $defaults $overrides]
|
||||
set srv [start_server [list overrides $config]]
|
||||
set srv [start_server [list overrides $config keep_persistence true]]
|
||||
uplevel 1 $code
|
||||
kill_server $srv
|
||||
}
|
||||
|
@ -31,6 +31,16 @@ proc check_valgrind_errors stderr {
|
||||
}
|
||||
}
|
||||
|
||||
proc clean_persistence config {
|
||||
# we may wanna keep the logs for later, but let's clean the persistence
|
||||
# files right away, since they can accumulate and take up a lot of space
|
||||
set config [dict get $config "config"]
|
||||
set rdb [format "%s/%s" [dict get $config "dir"] "dump.rdb"]
|
||||
set aof [format "%s/%s" [dict get $config "dir"] "appendonly.aof"]
|
||||
catch {exec rm -rf $rdb}
|
||||
catch {exec rm -rf $aof}
|
||||
}
|
||||
|
||||
proc kill_server config {
|
||||
# nothing to kill when running against external server
|
||||
if {$::external} return
|
||||
@ -238,19 +248,27 @@ proc start_server {options {code undefined}} {
|
||||
set baseconfig "default.conf"
|
||||
set overrides {}
|
||||
set tags {}
|
||||
set keep_persistence false
|
||||
|
||||
# parse options
|
||||
foreach {option value} $options {
|
||||
switch $option {
|
||||
"config" {
|
||||
set baseconfig $value }
|
||||
set baseconfig $value
|
||||
}
|
||||
"overrides" {
|
||||
set overrides $value }
|
||||
set overrides $value
|
||||
}
|
||||
"tags" {
|
||||
set tags $value
|
||||
set ::tags [concat $::tags $value] }
|
||||
set ::tags [concat $::tags $value]
|
||||
}
|
||||
"keep_persistence" {
|
||||
set keep_persistence $value
|
||||
}
|
||||
default {
|
||||
error "Unknown option $option" }
|
||||
error "Unknown option $option"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -436,6 +454,10 @@ proc start_server {options {code undefined}} {
|
||||
|
||||
set ::tags [lrange $::tags 0 end-[llength $tags]]
|
||||
kill_server $srv
|
||||
if {!$keep_persistence} {
|
||||
clean_persistence $srv
|
||||
}
|
||||
set _ ""
|
||||
} else {
|
||||
set ::tags [lrange $::tags 0 end-[llength $tags]]
|
||||
set _ $srv
|
||||
|
@ -12,7 +12,7 @@ tags "modules" {
|
||||
|
||||
test {modules global are lost without aux} {
|
||||
set server_path [tmpdir "server.module-testrdb"]
|
||||
start_server [list overrides [list loadmodule "$testmodule" "dir" $server_path]] {
|
||||
start_server [list overrides [list loadmodule "$testmodule" "dir" $server_path] keep_persistence true] {
|
||||
r testrdb.set.before global1
|
||||
assert_equal "global1" [r testrdb.get.before]
|
||||
}
|
||||
@ -23,7 +23,7 @@ tags "modules" {
|
||||
|
||||
test {modules are able to persist globals before and after} {
|
||||
set server_path [tmpdir "server.module-testrdb"]
|
||||
start_server [list overrides [list loadmodule "$testmodule 2" "dir" $server_path]] {
|
||||
start_server [list overrides [list loadmodule "$testmodule 2" "dir" $server_path] keep_persistence true] {
|
||||
r testrdb.set.before global1
|
||||
r testrdb.set.after global2
|
||||
assert_equal "global1" [r testrdb.get.before]
|
||||
@ -38,7 +38,7 @@ tags "modules" {
|
||||
|
||||
test {modules are able to persist globals just after} {
|
||||
set server_path [tmpdir "server.module-testrdb"]
|
||||
start_server [list overrides [list loadmodule "$testmodule 1" "dir" $server_path]] {
|
||||
start_server [list overrides [list loadmodule "$testmodule 1" "dir" $server_path] keep_persistence true] {
|
||||
r testrdb.set.after global2
|
||||
assert_equal "global2" [r testrdb.get.after]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user