Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
440ee603
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
440ee603
编写于
5月 19, 2014
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cluster test: better failure detection test and framework improvements.
上级
a7fd2eb5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
9 deletion
+43
-9
tests/cluster/cluster.tcl
tests/cluster/cluster.tcl
+33
-0
tests/cluster/tests/01-faildet.tcl
tests/cluster/tests/01-faildet.tcl
+10
-9
未找到文件。
tests/cluster/cluster.tcl
浏览文件 @
440ee603
...
...
@@ -73,3 +73,36 @@ proc assert_cluster_state {state} {
}
}
}
# Search the first node starting from ID $first that is not
# already configured as a slave.
proc cluster_find_available_slave
{
first
}
{
foreach_redis_id id
{
if
{
$id
< $first
}
continue
if
{[
instance_is_killed redis $id
]}
continue
set me
[
get_myself $id
]
if
{[
dict get $me slaveof
]
eq
{
-
}}
{
return $id
}
}
fail
"No available slaves"
}
# Add 'slaves' slaves to a cluster composed of 'masters' masters.
# It assumes that masters are allocated sequentially from instance ID 0
# to N-1.
proc cluster_allocate_slaves
{
masters slaves
}
{
for
{
set j 0
}
{
$j
< $slaves
}
{
incr j
}
{
set master_id
[
expr
{
$j
% $masters
}]
set slave_id
[
cluster_find_available_slave $masters
]
set master_myself
[
get_myself $master_id
]
R $slave_id cluster replicate
[
dict get $master_myself id
]
}
}
# Create a cluster composed of the specified number of masters and slaves.
proc create_cluster
{
masters slaves
}
{
cluster_allocate_slots $masters
if
{
$slaves
}
{
cluster_allocate_slaves $masters $slaves
}
assert_cluster_state ok
}
tests/cluster/tests/01-faildet.tcl
浏览文件 @
440ee603
...
...
@@ -2,16 +2,8 @@
source
"../tests/includes/init-tests.tcl"
proc create_cluster
{
masters slaves
}
{
cluster_allocate_slots $masters
if
{
$slaves
}
{
cluster_allocate_slaves $masters $slaves
}
assert_cluster_state ok
}
test
"Create a 5 nodes cluster"
{
create_cluster 5
0
create_cluster 5
5
}
test
"Killing one master node"
{
...
...
@@ -29,3 +21,12 @@ test "Restarting master node" {
test
"Cluster should be up again"
{
assert_cluster_state ok
}
test
"Killing two slave nodes"
{
kill_instance redis 5
kill_instance redis 6
}
test
"Cluster should be still up"
{
assert_cluster_state ok
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录