@cryptotaxi247 / kubo / commits / 5a61bedef

test: add sharness test for reading ADLs with FUSE

guseggert committed Sep 28, 2021 at 09:05 UTC 5a61bedef5bc83ced329f437ab7be5b414675700
2 files changed +69 -1
test/sharness/lib/test-lib.sh
+1 -1
@@ -287,7 +287,7 @@ test_launch_ipfs_daemon_without_network() {
287
288 do_umount() {
289 if [ "$(uname -s)" = "Linux" ]; then
290 - fusermount -u "$1"
290 + fusermount -z -u "$1"
291 else
292 umount "$1"
293 fi
test/sharness/t0032-mount-sharded.sh new
+68
@@ -0,0 +1,68 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Copyright (c) 2021 Protocol Labs
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test mount command with sharding enabled"
8 +
9 +. lib/test-lib.sh
10 +
11 +if ! test_have_prereq FUSE; then
12 + skip_all='skipping mount sharded tests, fuse not available'
13 + test_done
14 +fi
15 +
16 +test_init_ipfs
17 +
18 +test_expect_success 'enable sharding' '
19 + ipfs config --json Experimental.ShardingEnabled true
20 +'
21 +
22 +test_launch_ipfs_daemon
23 +test_mount_ipfs
24 +
25 +# we're testing nested subdirs which ensures that IPLD ADLs work
26 +test_expect_success 'setup test data' '
27 + mkdir testdata &&
28 + echo a > testdata/a &&
29 + mkdir testdata/subdir &&
30 + echo b > testdata/subdir/b
31 +'
32 +
33 +HASH=QmY59Ufw8zA2BxGPMTcfXg86JVed81Qbxeq5rDkHWSLN1m
34 +
35 +test_expect_success 'can add the data' '
36 + echo $HASH > expected_hash &&
37 + ipfs add -r -Q testdata > actual_hash &&
38 + test_cmp expected_hash actual_hash
39 +'
40 +
41 +test_expect_success 'can read the data' '
42 + echo a > expected_a &&
43 + cat "ipfs/$HASH/a" > actual_a &&
44 + test_cmp expected_a actual_a &&
45 + echo b > expected_b &&
46 + cat "ipfs/$HASH/subdir/b" > actual_b &&
47 + test_cmp expected_b actual_b
48 +'
49 +
50 +test_expect_success 'can list directories' '
51 + printf "a\nsubdir\n" > expected_ls &&
52 + ls -1 "ipfs/$HASH" > actual_ls &&
53 + test_cmp expected_ls actual_ls &&
54 + printf "b\n" > expected_ls_subdir &&
55 + ls -1 "ipfs/$HASH/subdir" > actual_ls_subdir &&
56 + test_cmp expected_ls_subdir actual_ls_subdir
57 +'
58 +
59 +test_expect_success "unmount" '
60 + do_umount "$(pwd)/ipfs" &&
61 + do_umount "$(pwd)/ipns"
62 +'
63 +
64 +test_expect_success 'cleanup' 'rmdir ipfs ipns'
65 +
66 +test_kill_ipfs_daemon
67 +
68 +test_done