chore: add hamt directory sharding test
Henrique Dias committed
Mar 14, 2023 at 13:51 UTC
d23702bbf8513094ca445bea52742d952e80a8dc
3 files changed
+44
-3
test/sharness/t0115-gateway-dir-listing.sh
+22
-2
@@ -13,14 +13,34 @@ test_description="Test directory listing (dir-index-html) on the HTTP gateway"
13
14
test_expect_success "ipfs init" '
15
export IPFS_PATH="$(pwd)/.ipfs" &&
16
- ipfs init --profile=test > /dev/null
16
+ ipfs init --empty-repo --profile=test > /dev/null
17
'
18
19
test_launch_ipfs_daemon_without_network
20
21
+# HAMT-sharded directory test. We must execute this test first as we want to
22
+# start from an empty repository and count the exact number of refs we want.
23
+HAMT_CID=bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm
24
+HAMT_REFS_CID=bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a
25
+HAMT_REFS_COUNT=963
26
+
27
+test_expect_success "hamt: import fixture with necessary refs" '
28
+ ipfs dag import ../t0115-gateway-dir-listing/hamt-refs.car &&
29
+ ipfs refs local | wc -l | tr -d " " > refs_count_actual &&
30
+ echo $HAMT_REFS_COUNT > refs_count_expected &&
31
+ test_cmp refs_count_expected refs_count_actual
32
+'
33
+
34
+test_expect_success "hamt: fetch directory from gateway in offline mode" '
35
+ curl --max-time 1 -sD - http://127.0.0.1:$GWAY_PORT/ipfs/$HAMT_CID/ > hamt_list_response &&
36
+ ipfs refs local | wc -l | tr -d " " > refs_count_actual &&
37
+ echo $HAMT_REFS_COUNT > refs_count_expected &&
38
+ test_cmp refs_count_expected refs_count_actual
39
+'
40
+
41
# Import test case
42
# See the static fixtures in ./t0115-gateway-dir-listing/
23
-test_expect_success "Add the test directory" '
43
+test_expect_success "add remaining test fixtures" '
44
ipfs dag import ../t0115-gateway-dir-listing/fixtures.car
45
'
46
DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/
test/sharness/t0115-gateway-dir-listing/README.md
+22
-1
@@ -2,8 +2,12 @@
2
3
- fixtures.car
4
- raw CARv1
5
+- hamt-refs.car
6
+ - raw CARv1 containing all the necessary blocks to present a directory listing
7
+ for `bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm`, which is
8
+ a directory containing over 10k items.
9
6
-generated with:
10
+fixutres.car generated with:
11
12
```sh
13
# using ipfs version 0.18.1
@@ -30,3 +34,20 @@ ipfs dag export ${DIR_CID} > ./fixtures.car
34
# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
35
# FILE_SIZE=34
36
```
37
+
38
+hamt-refs.car generated with:
39
+
40
+```sh
41
+# using ipfs version 0.18.1
42
+export IPFS_PATH=$(mktemp -d)
43
+ipfs init --empty-repo
44
+ipfs daemon &
45
+curl http://127.0.0.1:8080/ipfs/bafybeiggvykl7skb2ndlmacg2k5modvudocffxjesexlod2pfvg5yhwrqm/
46
+killall ipfs
47
+ipfs refs local >> refs
48
+ipfs files mkdir --cid-version 1 /Test
49
+cat refs | xargs -I {} ipfs files cp /ipfs/{} /Test/{}
50
+ipfs files stat /Test
51
+# Grab CID: bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a
52
+ipfs dag export bafybeicv4utmj46mgbpamvw2k6zg4qjs5yvspfnlxz2y6iuey5smjfcn4a > ./refs.car
53
+```
test/sharness/t0115-gateway-dir-listing/hamt-refs.car
Binary files /dev/null and b/test/sharness/t0115-gateway-dir-listing/hamt-refs.car differ