Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
a4efbd59
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a4efbd59
编写于
5月 28, 2020
作者:
S
Salvatore Sanfilippo
提交者:
GitHub
5月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7339 from oranagra/revive_mo_tests
Revive and adjust meaningful offset tests
上级
484af8ed
2a8af8e6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
232 addition
and
0 deletion
+232
-0
tests/integration/psync2-pingoff.tcl
tests/integration/psync2-pingoff.tcl
+231
-0
tests/test_helper.tcl
tests/test_helper.tcl
+1
-0
未找到文件。
tests/integration/psync2-pingoff.tcl
0 → 100644
浏览文件 @
a4efbd59
# These tests were added together with the meaningful offset implementation
# in redis 6.0.0, which was later abandoned in 6.0.4, they used to test that
# servers are able to PSYNC with replicas even if the replication stream has
# PINGs at the end which present in one sever and missing on another.
# We keep these tests just because they reproduce edge cases in the replication
# logic in hope they'll be able to spot some problem in the future.
start_server
{
tags
{
"psync2"
}}
{
start_server
{}
{
# Config
set debug_msg 0
;
# Enable additional debug messages
for
{
set j 0
}
{
$j
< 2
}
{
incr j
}
{
set R
(
$j
)
[
srv
[
expr 0-$j
]
client
]
set R_host
(
$j
)
[
srv
[
expr 0-$j
]
host
]
set R_port
(
$j
)
[
srv
[
expr 0-$j
]
port
]
$R
(
$j
)
CONFIG SET repl-ping-replica-period 1
if
{
$debug
_msg
}
{
puts
"Log file:
[
srv
[
expr 0-$j
]
stdout
]
"
}
}
# Setup replication
test
"PSYNC2 pingoff: setup"
{
$R
(
1
)
replicaof $R_host
(
0
)
$R_port
(
0
)
$R
(
0
)
set foo bar
wait_for_condition 50 1000
{
[
status $R
(
1
)
master_link_status
]
==
"up"
&&
[
$R
(
0
)
dbsize
]
== 1 &&
[
$R
(
1
)
dbsize
]
== 1
}
else
{
fail
"Replicas not replicating from master"
}
}
test
"PSYNC2 pingoff: write and wait replication"
{
$R
(
0
)
INCR counter
$R
(
0
)
INCR counter
$R
(
0
)
INCR counter
wait_for_condition 50 1000
{
[
$R
(
0
)
GET counter
]
eq
[
$R
(
1
)
GET counter
]
}
else
{
fail
"Master and replica don't agree about counter"
}
}
# In this test we'll make sure the replica will get stuck, but with
# an active connection: this way the master will continue to send PINGs
# every second
(
we modified the PING period earlier
)
test
"PSYNC2 pingoff: pause replica and promote it"
{
$R
(
1
)
MULTI
$R
(
1
)
DEBUG SLEEP 5
$R
(
1
)
SLAVEOF NO ONE
$R
(
1
)
EXEC
$R
(
1
)
ping
;
# Wait for it to return back available
}
test
"Make the old master a replica of the new one and check conditions"
{
assert_equal
[
status $R
(
1
)
sync_full
]
0
$R
(
0
)
REPLICAOF $R_host
(
1
)
$R_port
(
1
)
wait_for_condition 50 1000
{
[
status $R
(
1
)
sync_full
]
== 1
}
else
{
fail
"The new master was not able to sync"
}
# make sure replication is still alive and kicking
$R
(
1
)
incr x
wait_for_condition 50 1000
{
[
$R
(
0
)
get x
]
== 1
}
else
{
fail
"replica didn't get incr"
}
assert_equal
[
status $R
(
0
)
master_repl_offset
]
[
status $R
(
1
)
master_repl_offset
]
}
}}
start_server
{
tags
{
"psync2"
}}
{
start_server
{}
{
start_server
{}
{
start_server
{}
{
start_server
{}
{
test
{
test various edge cases of repl topology changes with missing pings at the end
}
{
set master
[
srv -4 client
]
set master_host
[
srv -4 host
]
set master_port
[
srv -4 port
]
set replica1
[
srv -3 client
]
set replica2
[
srv -2 client
]
set replica3
[
srv -1 client
]
set replica4
[
srv -0 client
]
$replica1 replicaof $master_host $master_port
$replica2 replicaof $master_host $master_port
$replica3 replicaof $master_host $master_port
$replica4 replicaof $master_host $master_port
wait_for_condition 50 1000
{
[
status $master connected_slaves
]
== 4
}
else
{
fail
"replicas didn't connect"
}
$master incr x
wait_for_condition 50 1000
{
[
$replica1
get x
]
== 1 &&
[
$replica2
get x
]
== 1 &&
[
$replica3
get x
]
== 1 &&
[
$replica4
get x
]
== 1
}
else
{
fail
"replicas didn't get incr"
}
# disconnect replica1 and replica2
# and wait for the master to send a ping to replica3 and replica4
$replica1 replicaof no one
$replica2 replicaof 127.0.0.1 1
;
# we can't promote it to master since that will cycle the replication id
$master config set repl-ping-replica-period 1
after 1500
# make everyone sync from the replica1 that didn't get the last ping from the old master
# replica4 will keep syncing from the old master which now syncs from replica1
# and replica2 will re-connect to the old master
(
which went back in time
)
set new_master_host
[
srv -3 host
]
set new_master_port
[
srv -3 port
]
$replica3 replicaof $new_master_host $new_master_port
$master replicaof $new_master_host $new_master_port
$replica2 replicaof $master_host $master_port
wait_for_condition 50 1000
{
[
status $replica2 master_link_status
]
==
"up"
&&
[
status $replica3 master_link_status
]
==
"up"
&&
[
status $replica4 master_link_status
]
==
"up"
&&
[
status $master master_link_status
]
==
"up"
}
else
{
fail
"replicas didn't connect"
}
# make sure replication is still alive and kicking
$replica1 incr x
wait_for_condition 50 1000
{
[
$replica2
get x
]
== 2 &&
[
$replica3
get x
]
== 2 &&
[
$replica4
get x
]
== 2 &&
[
$master
get x
]
== 2
}
else
{
fail
"replicas didn't get incr"
}
# make sure we have the right amount of full syncs
assert_equal
[
status $master sync_full
]
6
assert_equal
[
status $replica1 sync_full
]
2
assert_equal
[
status $replica2 sync_full
]
0
assert_equal
[
status $replica3 sync_full
]
0
assert_equal
[
status $replica4 sync_full
]
0
# force psync
$master client kill type master
$replica2 client kill type master
$replica3 client kill type master
$replica4 client kill type master
# make sure replication is still alive and kicking
$replica1 incr x
wait_for_condition 50 1000
{
[
$replica2
get x
]
== 3 &&
[
$replica3
get x
]
== 3 &&
[
$replica4
get x
]
== 3 &&
[
$master
get x
]
== 3
}
else
{
fail
"replicas didn't get incr"
}
# make sure we have the right amount of full syncs
assert_equal
[
status $master sync_full
]
6
assert_equal
[
status $replica1 sync_full
]
2
assert_equal
[
status $replica2 sync_full
]
0
assert_equal
[
status $replica3 sync_full
]
0
assert_equal
[
status $replica4 sync_full
]
0
}
}}}}}
start_server
{
tags
{
"psync2"
}}
{
start_server
{}
{
start_server
{}
{
for
{
set j 0
}
{
$j
< 3
}
{
incr j
}
{
set R
(
$j
)
[
srv
[
expr 0-$j
]
client
]
set R_host
(
$j
)
[
srv
[
expr 0-$j
]
host
]
set R_port
(
$j
)
[
srv
[
expr 0-$j
]
port
]
$R
(
$j
)
CONFIG SET repl-ping-replica-period 1
}
test
"Chained replicas disconnect when replica re-connect with the same master"
{
# Add a second replica as a chained replica of the current replica
$R
(
1
)
replicaof $R_host
(
0
)
$R_port
(
0
)
$R
(
2
)
replicaof $R_host
(
1
)
$R_port
(
1
)
wait_for_condition 50 1000
{
[
status $R
(
2
)
master_link_status
]
==
"up"
}
else
{
fail
"Chained replica not replicating from its master"
}
# Do a write on the master, and wait for 3 seconds for the master to
# send some PINGs to its replica
$R
(
0
)
INCR counter2
after 2000
set sync_partial_master
[
status $R
(
0
)
sync_partial_ok
]
set sync_partial_replica
[
status $R
(
1
)
sync_partial_ok
]
$R
(
0
)
CONFIG SET repl-ping-replica-period 100
# Disconnect the master's direct replica
$R
(
0
)
client kill type replica
wait_for_condition 50 1000
{
[
status $R
(
1
)
master_link_status
]
==
"up"
&&
[
status $R
(
2
)
master_link_status
]
==
"up"
&&
[
status $R
(
0
)
sync_partial_ok
]
== $sync_partial_master + 1 &&
[
status $R
(
1
)
sync_partial_ok
]
== $sync_partial_replica
}
else
{
fail
"Disconnected replica failed to PSYNC with master"
}
# Verify that the replica and its replica's meaningful and real
# offsets match with the master
assert_equal
[
status $R
(
0
)
master_repl_offset
]
[
status $R
(
1
)
master_repl_offset
]
assert_equal
[
status $R
(
0
)
master_repl_offset
]
[
status $R
(
2
)
master_repl_offset
]
# make sure replication is still alive and kicking
$R
(
0
)
incr counter2
wait_for_condition 50 1000
{
[
$R
(
1
)
get counter2
]
== 2 &&
[
$R
(
2
)
get counter2
]
== 2
}
else
{
fail
"replicas didn't get incr"
}
assert_equal
[
status $R
(
0
)
master_repl_offset
]
[
status $R
(
1
)
master_repl_offset
]
assert_equal
[
status $R
(
0
)
master_repl_offset
]
[
status $R
(
2
)
master_repl_offset
]
}
}}}
tests/test_helper.tcl
浏览文件 @
a4efbd59
...
...
@@ -47,6 +47,7 @@ set ::all_tests {
integration/logging
integration/psync2
integration/psync2-reg
integration/psync2-pingoff
unit/pubsub
unit/slowlog
unit/scripting
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录