Debian Codegraph @

t/t-batch-transfer-size.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . 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 printfscip-shell system . . printf. "%s" "$contents1" > a.dat
20 printfscip-shell system . . printf. "%s" "$contents2" > b.dat
21 printfscip-shell system . . printf. "%s" "$contents3" > c.dat
22
23 gitscip-shell system . . git. lfs track "*.dat"
24 gitscip-shell system . . git. add .gitattributes a.dat b.dat c.dat
25 gitscip-shell system . . git. commit -m "initial commit"
26
27 gitscip-shell system . . git. config --local lfs.transfer.batchSize 1
28
29 GIT_TRACE=1 gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
30 if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then
31 echoscip-shell system . . echo. >&2 "fatal: expected \`git push origin main\` to succeed ..."
32 exit 1
33 fi
34
35 actual_count="$(grepscip-shell system . . grep. -c "tq: sending batch of size 1" push.log)"
36 [scip-shell system . . `[`. "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 printfscip-shell system . . printf. "%s" "$contents1" > a.dat
59 printfscip-shell system . . printf. "%s" "$contents2" > b.dat
60 printfscip-shell system . . printf. "%s" "$contents3" > c.dat
61
62 gitscip-shell system . . git. lfs track "*.dat"
63 gitscip-shell system . . git. add .gitattributes a.dat b.dat c.dat
64 gitscip-shell system . . git. commit -m "initial commit"
65
66 gitscip-shell system . . 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 gitscip-shell system . . git. config --global lfs.transfer.batchSize 1
73
74 GIT_TRACE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" 2>&1 | teescip-shell system . . tee. clone.log
75 if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then
76 echoscip-shell system . . echo. >&2 "fatal: expected \`git clone\` to succeed ..."
77 exit 1
78 fi
79
80 actual_count="$(grepscip-shell system . . grep. -c "tq: sending batch of size 1" clone.log)"
81 [scip-shell system . . `[`. "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