mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Test: fix RDB test checking file permissions.
When the test is executed using the root account, setting the permission to 222 does not work as expected, as root can read files with 222 permission. Now we skip the test if root is detected. This fixes issue #1034 and the duplicated #1040 issue. Thanks to Jan-Erik Rediger (@badboy on Github) for finding a way to reproduce the issue.
This commit is contained in:
parent
4ed2581a92
commit
c4656119b6
@ -53,8 +53,17 @@ proc start_server_and_kill_it {overrides code} {
|
|||||||
# Make the RDB file unreadable
|
# Make the RDB file unreadable
|
||||||
file attributes [file join $server_path dump.rdb] -permissions 0222
|
file attributes [file join $server_path dump.rdb] -permissions 0222
|
||||||
|
|
||||||
|
# Detect root account (it is able to read the file even with 002 perm)
|
||||||
|
set isroot 0
|
||||||
|
catch {
|
||||||
|
open [file join $server_path dump.rdb]
|
||||||
|
set isroot 1
|
||||||
|
}
|
||||||
|
|
||||||
# Now make sure the server aborted with an error
|
# Now make sure the server aborted with an error
|
||||||
|
if {!$isroot} {
|
||||||
start_server_and_kill_it [list "dir" $server_path] {
|
start_server_and_kill_it [list "dir" $server_path] {
|
||||||
|
test {Server should not start if RDB file can't be open} {
|
||||||
wait_for_condition 50 100 {
|
wait_for_condition 50 100 {
|
||||||
[string match {*Fatal error loading*} \
|
[string match {*Fatal error loading*} \
|
||||||
[exec tail -n1 < [dict get $srv stdout]]]
|
[exec tail -n1 < [dict get $srv stdout]]]
|
||||||
@ -62,6 +71,8 @@ start_server_and_kill_it [list "dir" $server_path] {
|
|||||||
fail "Server started even if RDB was unreadable!"
|
fail "Server started even if RDB was unreadable!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Fix permissions of the RDB file.
|
# Fix permissions of the RDB file.
|
||||||
file attributes [file join $server_path dump.rdb] -permissions 0666
|
file attributes [file join $server_path dump.rdb] -permissions 0666
|
||||||
@ -76,6 +87,7 @@ close $fd
|
|||||||
|
|
||||||
# Now make sure the server aborted with an error
|
# Now make sure the server aborted with an error
|
||||||
start_server_and_kill_it [list "dir" $server_path] {
|
start_server_and_kill_it [list "dir" $server_path] {
|
||||||
|
test {Server should not start if RDB is corrupted} {
|
||||||
wait_for_condition 50 100 {
|
wait_for_condition 50 100 {
|
||||||
[string match {*RDB checksum*} \
|
[string match {*RDB checksum*} \
|
||||||
[exec tail -n1 < [dict get $srv stdout]]]
|
[exec tail -n1 < [dict get $srv stdout]]]
|
||||||
@ -83,3 +95,4 @@ start_server_and_kill_it [list "dir" $server_path] {
|
|||||||
fail "Server started even if RDB was corrupted!"
|
fail "Server started even if RDB was corrupted!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user