Debian Codegraph @

t/t-batch-transfer-size.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . "$(dirname "$0")/testlib.sh"
4
5 begin_test "batch storage upload with small batch size"
6 (
7 set -e
8
9 reponame="batch-storage-upload-small-batch"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" batch-storage-repo-upload
12
13 contents1="storage-upload-batch-1"
14 contents2="storage-upload-batch-2"
15 contents3="storage-upload-batch-3"
16 oid1="$(calc_oid "$contents1")"
17 oid2="$(calc_oid "$contents2")"
18 oid3="$(calc_oid "$contents3")"
19 printf "%s" "$contents1" > a.dat
20 printf "%s" "$contents2" > b.dat
21 printf "%s" "$contents3" > c.dat
22
23 git lfs track "*.dat"
24 git add .gitattributes a.dat b.dat c.dat
25 git commit -m "initial commit"
26
27 git config --local lfs.transfer.batchSize 1
28
29 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
30 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
31 echo >&2 "fatal: expected \`git push origin main\` to succeed ..."
32 exit 1
33 fi
34
35 actual_count="$(grep -c "tq: sending batch of size 1" push.log)"
36 [ "3" = "$actual_count" ]
37
38 assert_server_object "$reponame" "$oid1"
39 assert_server_object "$reponame" "$oid2"
40 assert_server_object "$reponame" "$oid3"
41 )
42 end_test
43
44 begin_test "batch storage download with small batch size"
45 (
46 set -e
47
48 reponame="batch-storage-download-small-batch"
49 setup_remote_repo "$reponame"
50 clone_repo "$reponame" batch-storage-repo-download
51
52 contents1="storage-download-batch-1"
53 contents2="storage-download-batch-2"
54 contents3="storage-download-batch-3"
55 oid1="$(calc_oid "$contents1")"
56 oid2="$(calc_oid "$contents2")"
57 oid3="$(calc_oid "$contents3")"
58 printf "%s" "$contents1" > a.dat
59 printf "%s" "$contents2" > b.dat
60 printf "%s" "$contents3" > c.dat
61
62 git lfs track "*.dat"
63 git add .gitattributes a.dat b.dat c.dat
64 git commit -m "initial commit"
65
66 git push origin main
67 assert_server_object "$reponame" "$oid1"
68 assert_server_object "$reponame" "$oid2"
69 assert_server_object "$reponame" "$oid3"
70
71 cd ..
72 git config --global lfs.transfer.batchSize 1
73
74 GIT_TRACE=1 git clone "$GITSERVER/$reponame" "${reponame}-assert" 2>&1 | tee clone.log
75 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
76 echo >&2 "fatal: expected \`git clone\` to succeed ..."
77 exit 1
78 fi
79
80 actual_count="$(grep -c "tq: sending batch of size 1" clone.log)"
81 [ "3" = "$actual_count" ]
82
83 cd "${reponame}-assert"
84 assert_local_object "$oid1" "${#contents1}"
85 assert_local_object "$oid2" "${#contents2}"
86 assert_local_object "$oid3" "${#contents3}"
87 )
88 end_test