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
299f1d02
Commit
299f1d02
authored
Mar 18, 2020
by
WuYunlong
Committed by
antirez
Mar 25, 2020
Browse files
Add 14-consistency-check.tcl to prove there is a data consistency issue.
parent
61b98f32
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/cluster/tests/14-consistency-check.tcl
0 → 100644
View file @
299f1d02
source
"../tests/includes/init-tests.tcl"
test
"Create a 5 nodes cluster"
{
create_cluster 5 5
}
test
"Cluster should start ok"
{
assert_cluster_state ok
}
test
"Cluster is writable"
{
cluster_write_test 0
}
proc find_non_empty_master
{}
{
set master_id_no
{}
foreach_redis_id id
{
if
{[
RI $id role
]
eq
{
master
}
&&
[
R $id dbsize
]
> 0
}
{
set master_id_no $id
}
}
return $master_id_no
}
proc get_one_of_my_replica
{
id
}
{
set replica_port
[
lindex
[
lindex
[
lindex
[
R $id role
]
2
]
0
]
1
]
set replica_id_num
[
get_instance_id_by_port redis $replica_port
]
return $replica_id_num
}
proc cluster_write_keys_with_expire
{
id ttl
}
{
set prefix
[
randstring 20 20 alpha
]
set port
[
get_instance_attrib redis $id port
]
set cluster
[
redis_cluster 127.0.0.1:$port
]
for
{
set j 100
}
{
$j
< 200
}
{
incr j
}
{
$cluster setex key_expire.$j $ttl $prefix.$j
}
$cluster close
}
proc test_slave_load_expired_keys
{
aof
}
{
test
"Slave expired keys is loaded when restarted: appendonly=
$aof
"
{
set master_id
[
find_non_empty_master
]
set replica_id
[
get_one_of_my_replica $master_id
]
set master_dbsize
[
R $master_id dbsize
]
set slave_dbsize
[
R $replica_id dbsize
]
assert_equal $master_dbsize $slave_dbsize
set data_ttl 5
cluster_write_keys_with_expire $master_id $data_ttl
after 100
set replica_dbsize_1
[
R $replica_id dbsize
]
assert
{
$replica
_dbsize_1 > $slave_dbsize
}
R $replica_id config set appendonly $aof
R $replica_id config rewrite
set start_time
[
clock seconds
]
set end_time
[
expr $start_time+$data_ttl+2
]
R $replica_id save
set replica_dbsize_2
[
R $replica_id dbsize
]
assert
{
$replica
_dbsize_2 > $slave_dbsize
}
kill_instance redis $replica_id
set master_port
[
get_instance_attrib redis $master_id port
]
exec ../../../src/redis-cli -h 127.0.0.1 -p $master_port debug sleep
[
expr $data_ttl+3
]
> /dev/null &
while
{[
clock seconds
]
<= $end_time
}
{
#wait for $data_ttl seconds
}
restart_instance redis $replica_id
wait_for_condition 200 50
{
[
R $replica_id ping
]
eq
{
PONG
}
}
else
{
fail
"replica #
$replica
_id not started"
}
set replica_dbsize_3
[
R $replica_id dbsize
]
assert
{
$replica
_dbsize_3 > $slave_dbsize
}
}
}
test_slave_load_expired_keys no
after 5000
test_slave_load_expired_keys yes
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