Debian Codegraph @

t/t-progress.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 "progress log: file counts"
6 (
7 set -e
8
9 reponame="progress-log-file-counts"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" "$reponame"
12
13 gitscip-shell system . . git. lfs track "*.dat"
14
15 echoscip-shell system . . echo. "a" > a.dat
16 echoscip-shell system . . echo. "b" > b.dat
17 echoscip-shell system . . echo. "c" > c.dat
18 echoscip-shell system . . echo. "d" > d.dat
19 echoscip-shell system . . echo. "e" > e.dat
20
21 progress_log_dir="$TRASHDIR/${reponame}-logs"
22
23 progress_log="$progress_log_dir/progress-clean.log"
24 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. add .gitattributes *.dat
25 catscip-shell system . . cat. "$progress_log"
26
27 [scip-shell system . . `[`. 5 -eq "$(grepscip-shell system . . grep. -c "clean 1/1" "$progress_log")" ]
28
29 gitscip-shell system . . git. commit -m "add files"
30
31 progress_log="$progress_log_dir/progress-push.log"
32 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log
33 [scip-shell system . . `[`. 0 -eq "${PIPESTATUS[0]}" ]
34 catscip-shell system . . cat. "$progress_log"
35
36 grepscip-shell system . . grep. "Uploading LFS objects: 100% (5/5), 10 B" push.log
37
38 grepscip-shell system . . grep. "upload 1/5" "$progress_log"
39 grepscip-shell system . . grep. "upload 2/5" "$progress_log"
40 grepscip-shell system . . grep. "upload 3/5" "$progress_log"
41 grepscip-shell system . . grep. "upload 4/5" "$progress_log"
42 grepscip-shell system . . grep. "upload 5/5" "$progress_log"
43
44 cd ..
45
46 progress_log="$progress_log_dir/progress-clone.log"
47 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. lfs clone "$GITSERVER/$reponame" "${reponame}-assert"
48 catscip-shell system . . cat. "$progress_log"
49
50 grepscip-shell system . . grep. "download 1/5" "$progress_log"
51 grepscip-shell system . . grep. "download 2/5" "$progress_log"
52 grepscip-shell system . . grep. "download 3/5" "$progress_log"
53 grepscip-shell system . . grep. "download 4/5" "$progress_log"
54 grepscip-shell system . . grep. "download 5/5" "$progress_log"
55
56 rmscip-shell system . . rm. -rf "${reponame}-assert"
57
58 GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert"
59 cd "${reponame}-assert"
60
61 rmscip-shell system . . rm. -rf .git/lfs/objects
62
63 progress_log="$progress_log_dir/progress-fetch.log"
64 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. lfs fetch --all
65 catscip-shell system . . cat. "$progress_log"
66
67 grepscip-shell system . . grep. "download 1/5" "$progress_log"
68 grepscip-shell system . . grep. "download 2/5" "$progress_log"
69 grepscip-shell system . . grep. "download 3/5" "$progress_log"
70 grepscip-shell system . . grep. "download 4/5" "$progress_log"
71 grepscip-shell system . . grep. "download 5/5" "$progress_log"
72
73 progress_log="$progress_log_dir/progress-checkout.log"
74 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. lfs checkout
75 catscip-shell system . . cat. "$progress_log"
76
77 grepscip-shell system . . grep. "checkout 1/5" "$progress_log"
78 grepscip-shell system . . grep. "checkout 2/5" "$progress_log"
79 grepscip-shell system . . grep. "checkout 3/5" "$progress_log"
80 grepscip-shell system . . grep. "checkout 4/5" "$progress_log"
81 grepscip-shell system . . grep. "checkout 5/5" "$progress_log"
82 )
83 end_test
84
85 begin_test "progress log: unknown initial size (clean)"
86 (
87 set -e
88
89 reponame="progress-log-unknown-total-clean"
90 setup_remote_repo "$reponame"
91 clone_repo "$reponame" "$reponame"
92
93 gitscip-shell system . . git. lfs track "*.dat"
94 gitscip-shell system . . git. add .gitattributes
95 gitscip-shell system . . git. commit -m "initial commit"
96
97 # Test with a file size larger than the size of the read buffer used when
98 # decoding pointers. See the secondary issue reported in
99 # https://github.com/git-lfs/git-lfs/issues/4974#issuecomment-2717907543
100 # and https://github.com/git-lfs/git-lfs/pull/6011.
101 max_pointer_size="$(lfstest-getlimit --max-pointer-size)"
102 contents_size=$((max_pointer_size * 2))
103 headscip-shell system . . head. -c "$contents_size" /dev/zeroscip-shell filesystem . . `/dev/zero`. >large.dat
104
105 progress_log="$TRASHDIR/${reponame}-logs/progress.log"
106 GIT_LFS_PROGRESS="$progress_log" gitscip-shell system . . git. add large.dat
107 catscip-shell system . . cat. "$progress_log"
108
109 # Confirm that the callback created by the CopyCallbackFile() method
110 # of lfs.GitFilter reports the final object size in the progress log.
111 #
112 # Note that we will probably not see a preceding entry with a "????"-style
113 # field indicating an unknown total size, even though a callback will
114 # likely be made after the read buffer used to decode pointers is copied
115 # and before the remainder of the data is copied. Specifically, when
116 # io.Copy() reads from io.MultiReader() and reaches the end of the initial
117 # pointer detection buffer, a callback is likely to be made. However,
118 # the callback will not write an entry because insufficient time will
119 # have elapsed, as it only writes if its throttling deadline has passed
120 # or if the byte count has just reached the expected total.
121 grepscip-shell system . . grep. "clean 1/1 $contents_size/$contents_size large.dat" "$progress_log"
122 )
123 end_test
124
125 begin_test "progress log: unknown initial size (smudge)"
126 (
127 set -e
128
129 reponame="progress-log-unknown-total-smudge"
130 setup_remote_repo "$reponame"
131 clone_repo "$reponame" "$reponame"
132
133 gitscip-shell system . . git. lfs track "*.dat"
134
135 # This content announces to the server that it should expect an
136 # "Accept-Encoding: gzip" header and send a gzip-compressed response.
137 contents="storage-download-encoding-gzip"
138 printfscip-shell system . . printf. "%s" "$contents" >a.dat
139
140 gitscip-shell system . . git. add .gitattributes a.dat
141 gitscip-shell system . . git. commit -m "add a.dat"
142
143 gitscip-shell system . . git. push origin main
144
145 # We force the use of "git lfs smudge" rather than "git lfs filter-process"
146 # because the latter downloads object files asynchronously and writes them
147 # to local storage, and then only invokes the progress logging callback
148 # when spooling those files back to Git in response to its second phase
149 # of "smudge" filter commands where it does not specify the "can-delay"
150 # flag. As a result, the total size of each file is known during these
151 # callbacks.
152 #
153 # By contrast, when using "git lfs smudge" the progress logging callback
154 # is called as object file data is downloaded by the transfer adapter,
155 # and the lack of a Content-Length header means the total size is
156 # unknown until EOF is reached.
157 gitscip-shell system . . git. config --global --unset filter.lfs.process
158
159 cd ..
160 progress_log="$TRASHDIR/${reponame}-logs/progress.log"
161 GIT_LFS_PROGRESS="$progress_log" GIT_TRACE=1 \
162 git clone "$GITSERVER/$reponame" "${reponame}-assert" 2>&1 | teescip-shell system . . tee. clone.log
163 [scip-shell system . . `[`. 0 -eq "${PIPESTATUS[0]}" ]
164 catscip-shell system . . cat. "$progress_log"
165
166 # Confirm we saw a gzip-encoded response, which should not include a
167 # Content-Length header, so the size of the download will be initially
168 # unknown. For a more comprehensive test of gzip-encoding, see the
169 # t/t-batch-storage-encoding.sh script.
170 grepscip-shell system . . grep. -c "decompressed gzipped response" clone.log
171
172 # Confirm that the callback created by the CopyCallbackFile() method
173 # of lfs.GitFilter reports the final object size in the progress log.
174 #
175 # Note that we will probably not see a preceding entry with a "????"-style
176 # field indicating an unknown total size because an EOF is usually provided
177 # at the same time the final bytes are read from the HTTP download stream.
178 # Once EOF is reached, the Read() method of tools.CallbackReader should pass
179 # the final byte count to the callback as the total size, so the callback
180 # will likely never be invoked with a negative (i.e., unknown) total size.
181 grepscip-shell system . . grep. "download 1/1 ${#contents}/${#contents} a.dat" "$progress_log"
182 )
183 end_test
184
185 begin_test "progress log: unknown initial size (fetch/pull)"
186 (
187 set -e
188
189 reponame="progress-log-unknown-total-pull"
190 setup_remote_repo "$reponame"
191 clone_repo "$reponame" "$reponame"
192
193 gitscip-shell system . . git. lfs track "*.dat"
194
195 # This content announces to the server that it should expect an
196 # "Accept-Encoding: gzip" header and send a gzip-compressed response.
197 contents="storage-download-encoding-gzip"
198 printfscip-shell system . . printf. "%s" "$contents" >a.dat
199
200 gitscip-shell system . . git. add .gitattributes a.dat
201 gitscip-shell system . . git. commit -m "add a.dat"
202
203 gitscip-shell system . . git. push origin main
204
205 progress_log_dir="$TRASHDIR/${reponame}-logs"
206
207 rmscip-shell system . . rm. -rf .git/lfs/objects a.dat
208
209 progress_log="$progress_log_dir/progress-fetch.log"
210 GIT_LFS_PROGRESS="$progress_log" GIT_TRACE=1 gitscip-shell system . . git. lfs fetch 2>&1 | teescip-shell system . . tee. fetch.log
211 [scip-shell system . . `[`. 0 -eq "${PIPESTATUS[0]}" ]
212 catscip-shell system . . cat. "$progress_log"
213
214 # Confirm we saw a gzip-encoded response, which should not include a
215 # Content-Length header, so the size of the download will be initially
216 # unknown. For a more comprehensive test of gzip-encoding, see the
217 # t/t-batch-storage-encoding.sh script.
218 grepscip-shell system . . grep. -c "decompressed gzipped response" fetch.log
219
220 # Confirm that the callback created by the ensureAdapterBegun() method
221 # of tq.TransferQueue reports the final object size in the progress log.
222 #
223 # Note that we will probably not see a preceding entry with a "????"-style
224 # field indicating an unknown total size because an EOF is usually provided
225 # at the same time the final bytes are read from the HTTP download stream.
226 # Once EOF is reached, the Read() method of tools.CallbackReader should pass
227 # the final byte count to the callback as the total size, so the callback
228 # will likely never be invoked with a negative (i.e., unknown) total size.
229 grepscip-shell system . . grep. "download 1/1 ${#contents}/${#contents} a.dat" "$progress_log"
230
231 rmscip-shell system . . rm. -rf .git/lfs/objects
232
233 progress_log="$progress_log_dir/progress-pull.log"
234 GIT_LFS_PROGRESS="$progress_log" GIT_TRACE=1 gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log
235 [scip-shell system . . `[`. 0 -eq "${PIPESTATUS[0]}" ]
236 catscip-shell system . . cat. "$progress_log"
237
238 # Confirm we saw a gzip-encoded response, which should not include a
239 # Content-Length header, so the size of the download will be initially
240 # unknown.
241 grepscip-shell system . . grep. -c "decompressed gzipped response" pull.log
242
243 # Confirm that the callback created by the ensureAdapterBegun() method
244 # of tq.TransferQueue reports the final object size in the progress log.
245 #
246 # Note that we will probably not see a preceding entry with a "????"-style
247 # field indicating an unknown total size because an EOF is usually provided
248 # at the same time the final bytes are read from the HTTP download stream.
249 # Once EOF is reached, the Read() method of tools.CallbackReader should pass
250 # the final byte count to the callback as the total size, so the callback
251 # will likely never be invoked with a negative (i.e., unknown) total size.
252 grepscip-shell system . . grep. "download 1/1 ${#contents}/${#contents} a.dat" "$progress_log"
253 )
254 end_test