提交 620b52b2 作者: Kevin Atkinson

filestore util: refactor and clean up tests

License: MIT
Signed-off-by: 's avatarKevin Atkinson <k@kevina.org>
上级 96269e02
...@@ -8,6 +8,17 @@ test_description="Test out the filestore nocopy functionality" ...@@ -8,6 +8,17 @@ test_description="Test out the filestore nocopy functionality"
. lib/test-lib.sh . lib/test-lib.sh
test_init_filestore() {
test_expect_success "clean up old node" '
rm -rf "$IPFS_PATH" mountdir ipfs ipns
'
test_init_ipfs
test_expect_success "enable filestore config setting" '
ipfs config --json Experimental.FilestoreEnabled true
'
}
test_init_dataset() { test_init_dataset() {
test_expect_success "create a dataset" ' test_expect_success "create a dataset" '
...@@ -19,6 +30,11 @@ test_init_dataset() { ...@@ -19,6 +30,11 @@ test_init_dataset() {
' '
} }
test_init() {
test_init_filestore
test_init_dataset
}
EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V" EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V"
cat <<EOF > ls_expect cat <<EOF > ls_expect
...@@ -68,11 +84,16 @@ test_filestore_adds() { ...@@ -68,11 +84,16 @@ test_filestore_adds() {
' '
} }
test_filestore_verify() { # check that the filestore is in a clean state
test_filestore_state() {
test_expect_success "ipfs filestore verify' output looks good'" ' test_expect_success "ipfs filestore verify' output looks good'" '
ipfs filestore verify | LC_ALL=C sort > verify_actual ipfs filestore verify | LC_ALL=C sort > verify_actual
test_cmp verify_expect verify_actual test_cmp verify_expect verify_actual
' '
}
test_filestore_verify() {
test_filestore_state
test_expect_success "'ipfs filestore verify HASH' works" ' test_expect_success "'ipfs filestore verify HASH' works" '
ipfs filestore verify $FILE1_HASH > verify_actual && ipfs filestore verify $FILE1_HASH > verify_actual &&
...@@ -113,35 +134,28 @@ test_filestore_verify() { ...@@ -113,35 +134,28 @@ test_filestore_verify() {
ipfs filestore verify > verify_actual && ipfs filestore verify > verify_actual &&
grep changed verify_actual | grep -q somedir/file3 grep changed verify_actual | grep -q somedir/file3
' '
}
cat <<EOF > dups_expect # reset the state for the next test
$FILE1_HASH test_init_dataset
EOF }
test_filestore_dups() { test_filestore_dups() {
# make sure the filestore is in a clean state
test_filestore_state
test_expect_success "'ipfs filestore dups'" ' test_expect_success "'ipfs filestore dups'" '
ipfs add --raw-leaves somedir/file1 && ipfs add --raw-leaves somedir/file1 &&
ipfs filestore dups > dups_actual && ipfs filestore dups > dups_actual &&
echo "$FILE1_HASH" > dups_expect
test_cmp dups_expect dups_actual test_cmp dups_expect dups_actual
'
}
init_ipfs_filestore() {
test_expect_success "clean up old node" '
rm -rf "$IPFS_PATH" mountdir ipfs ipns
'
test_init_ipfs
test_expect_success "enable filestore config setting" '
ipfs config --json Experimental.FilestoreEnabled true
' '
} }
test_init_dataset #
# No daemon
#
init_ipfs_filestore test_init
test_filestore_adds test_filestore_adds
...@@ -149,17 +163,14 @@ test_filestore_verify ...@@ -149,17 +163,14 @@ test_filestore_verify
test_filestore_dups test_filestore_dups
echo "WORKING DIR" #
echo "IPFS PATH = " $IPFS_PATH # With daemon
pwd #
test_init_dataset
init_ipfs_filestore test_init
# must be in offline mode so tests of retrieving non-exist blocks # must be in offline mode so tests that retrieve non-existent blocks
# don't hang # doesn't hang
test_launch_ipfs_daemon --offline test_launch_ipfs_daemon --offline
test_filestore_adds test_filestore_adds
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论