Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c7091132
提交
c7091132
authored
2月 23, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gc: add sharness test script
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
d7fa05a7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
161 行增加
和
0 行删除
+161
-0
t0087-repo-robust-gc.sh
test/sharness/t0087-repo-robust-gc.sh
+161
-0
没有找到文件。
test/sharness/t0087-repo-robust-gc.sh
0 → 100755
浏览文件 @
c7091132
#!/bin/sh
#
# Copyright (c) 2016 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test robustness of garbage collector"
.
lib/test-lib.sh
set
-e
test_gc_robust_part1
()
{
test_expect_success
"add a 1MB file with --raw-leaves"
'
random 1048576 56 > afile &&
HASH1=`ipfs add --raw-leaves -q afile`
'
HASH1FILE
=
.ipfs/blocks/L3/CIQNIPL4GP62ZMNNSLZ2G33Z3T5VAN3YHCJTGT5FG45XWH5FGZRXL3A.data
LEAF1
=
zb2rhZWKCMcHCfCym41ocwE5BhNQsEVLrwBkLEQaxJzRHHZch
LEAF1FILE
=
.ipfs/blocks/C2/AFKREIBKRCW7HF6NHR6DVWECQXC5RQC7U7PKHKTI53BYYZNQP23DK5FC2Y.data
LEAF2
=
zb2rhdUpCuyoQPRtvBW8JhAEfPaNd9dBb3QQCMMWYS1V8hjBR
LEAF2FILE
=
.ipfs/blocks/Q6/BAFKREIDFSUIR43GJPHNDXXQA45GJVNRZBET3CRPUMYJCBLK3RTN7ZAMQ6Q
LEAF3
=
zb2rhnwyvreekPqEMAbKqs35KYHxkNi7pXED7L2TfJKveTTva
LEAF4
=
zb2rhnvAVvfDDnndcfQkwqNgUm94ba3zBSXyJKCfVXwU4FXx2
test_expect_success
"remove a leaf node from the repo manually"
'
rm "$LEAF1FILE"
'
test_expect_success
"check that the node is removed"
'
test_must_fail ipfs cat $HASH1
'
test_expect_success
"'ipfs repo gc' should still be be fine"
'
ipfs repo gc
'
test_expect_success
"corrupt the root node of 1MB file"
'
test -e "$HASH1FILE" &&
dd if=/dev/zero of="$HASH1FILE" count=1 bs=100 conv=notrunc
'
test_expect_success
"'ipfs repo gc' should abort without removing anything"
'
test_must_fail ipfs repo gc 2>&1 | tee gc_err &&
grep -q "could not retrieve links for $HASH1" gc_err &&
grep -q "aborted" gc_err
'
test_expect_success
"leaf nodes were not removed after gc"
'
ipfs cat $LEAF3 > /dev/null &&
ipfs cat $LEAF4 > /dev/null
'
test_expect_success
"unpin the 1MB file"
'
ipfs pin rm $HASH1
'
# make sure the permission problem is fixed on exit, otherwise cleanup
# will fail
trap
"chmod 700
`
dirname
"
$LEAF2FILE
"
`
2> /dev/null || true"
0
test_expect_success
"create a permission problem"
'
chmod 500 `dirname "$LEAF2FILE"` &&
test_must_fail ipfs block rm $LEAF2 2>&1 | tee block_rm_err &&
grep -q "permission denied" block_rm_err
'
test_expect_success
"'ipfs repo gc' should still run and remove as much as possible"
'
test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
grep -q "removed $HASH1" repo_gc_out &&
grep -q "could not remove $LEAF2" repo_gc_out &&
grep -q "removed $LEAF3" repo_gc_out &&
grep -q "removed $LEAF4" repo_gc_out
'
test_expect_success
"fix the permission problem"
'
chmod 700 `dirname "$LEAF2FILE"`
'
test_expect_success
"'ipfs repo gc' should be ok now"
'
ipfs repo gc | tee repo_gc_out
grep -q "removed $LEAF2" repo_gc_out
'
}
test_gc_robust_part2
()
{
test_expect_success
"add 1MB file normally (i.e., without raw leaves)"
'
random 1048576 56 > afile &&
HASH2=`ipfs add -q afile`
'
LEAF1
=
QmSijovevteoY63Uj1uC5b8pkpDU5Jgyk2dYBqz3sMJUPc
LEAF1FILE
=
.ipfs/blocks/ME/CIQECF2K344QITW5S6E6H6T4DOXDDB2XA2V7BBOCIMN2VVF4Q77SMEY.data
LEAF2
=
QmTbPEyrA1JyGUHFvmtx1FNZVzdBreMv8Hc8jV9sBRWhNA
LEAF2FILE
=
.ipfs/blocks/WM/CIQE4EFIJN2SUTQYSKMKNG7VM75W3SXT6LWJCHJJ73UAWN73WCX3WMY.data
test_expect_success
"add some additional unpinned content"
'
random 1000 3 > junk1 &&
random 1000 4 > junk2 &&
JUNK1=`ipfs add --pin=false -q junk1` &&
JUNK2=`ipfs add --pin=false -q junk2`
'
test_expect_success
"remove a leaf node from the repo manually"
'
rm "$LEAF1FILE"
'
test_expect_success
"'ipfs repo gc' should abort"
'
test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
grep -q "aborted" repo_gc_out
'
test_expect_success
"test that garbage collector really aborted"
'
ipfs cat $JUNK1 > /dev/null &&
ipfs cat $JUNK2 > /dev/null
'
test_expect_success
"corrupt a key"
'
test -e "$LEAF2FILE" &&
dd if=/dev/zero of="$LEAF2FILE" count=1 bs=100 conv=notrunc
'
test_expect_success
"'ipfs repo gc' should abort with two errors"
'
test_must_fail ipfs repo gc 2>&1 | tee repo_gc_out &&
grep -q "could not retrieve links for $LEAF1" repo_gc_out &&
grep -q "could not retrieve links for $LEAF2" repo_gc_out &&
grep -q "aborted" repo_gc_out
'
test_expect_success
"unpin 1MB file"
'
ipfs pin rm $HASH2
'
test_expect_success
"'ipfs repo gc' should be fine now"
'
ipfs repo gc | tee repo_gc_out &&
grep -q "removed $HASH2" repo_gc_out &&
grep -q "removed $LEAF2" repo_gc_out
'
}
test_init_ipfs
test_gc_robust_part1
test_gc_robust_part2
test_launch_ipfs_daemon
--offline
test_gc_robust_part1
test_gc_robust_part2
test_kill_ipfs_daemon
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论