This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
/
t0260-sharding-flag.sh
executable file
·88 lines (65 loc) · 2.07 KB
/
t0260-sharding-flag.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#
test_description="Test global enable sharding flag"
. lib/test-lib.sh
test_expect_success "set up test data" '
mkdir testdata
for i in `seq 2000`
do
echo $i > testdata/file$i
done
'
test_add_large_dir() {
exphash="$1"
test_expect_success "ipfs add on very large directory succeeds" '
ipfs add -r -q testdata | tail -n1 > sharddir_out &&
echo "$exphash" > sharddir_exp &&
test_cmp sharddir_exp sharddir_out
'
}
test_init_ipfs
UNSHARDED="QmavrTrQG4VhoJmantURAYuw3bowq3E2WcvP36NRQDAC1N"
test_add_large_dir "$UNSHARDED"
test_launch_ipfs_daemon
test_add_large_dir "$UNSHARDED"
test_kill_ipfs_daemon
test_expect_success "enable sharding" '
ipfs config --json Experimental.ShardingEnabled true
'
SHARDED="QmSCJD1KYLhVVHqBK3YyXuoEqHt7vggyJhzoFYbT8v1XYL"
test_add_large_dir "$SHARDED"
test_launch_ipfs_daemon
test_add_large_dir "$SHARDED"
test_kill_ipfs_daemon
test_expect_success "sharded and unsharded output look the same" '
ipfs ls "$SHARDED" | sort > sharded_out &&
ipfs ls "$UNSHARDED" | sort > unsharded_out &&
test_cmp sharded_out unsharded_out
'
test_expect_success "ipfs cat error output the same" '
test_expect_code 1 ipfs cat "$SHARDED" 2> sharded_err &&
test_expect_code 1 ipfs cat "$UNSHARDED" 2> unsharded_err &&
test_cmp sharded_err unsharded_err
'
test_add_large_dir_v1() {
exphash="$1"
test_expect_success "ipfs add (CIDv1) on very large directory succeeds" '
ipfs add -r -q --cid-version=1 testdata | tail -n1 > sharddir_out &&
echo "$exphash" > sharddir_exp &&
test_cmp sharddir_exp sharddir_out
'
test_expect_success "can access a path under the dir" '
ipfs cat "$exphash/file20" > file20_out &&
test_cmp testdata/file20 file20_out
'
}
# this hash implies the directory is CIDv1 and leaf entries are CIDv1 and raw
SHARDEDV1="zdj7WY8aNcxF49q1ZpFXfchNmbswnUxiVDVjmrHb53xRM8W4C"
test_add_large_dir_v1 "$SHARDEDV1"
test_launch_ipfs_daemon
test_add_large_dir_v1 "$SHARDEDV1"
test_kill_ipfs_daemon
test_done