Debian Codegraph @

t/t-batch-storage-retries-ratelimit.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 . "$(dirname "$0")/testlib.sh"
4
5 begin_test "batch storage HTTP upload causes delayed retries"
6 (
7 set -e
8
9 reponame="batch-storage-upload-retry-later"
10 setup_remote_repo "$reponame"
11 clone_repo "$reponame" batch-storage-repo-upload
12
13 contents="storage-upload-retry-later"
14 oid="$(calc_oid "$contents")"
15 printf "%s" "$contents" > a.dat
16
17 git lfs track "*.dat"
18 git add .gitattributes a.dat
19 git commit -m "initial commit"
20
21 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
22 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
23 echo >&2 "fatal: expected \`git push origin main\` to succeed ..."
24 exit 1
25 fi
26
27 [ 1 -eq $(grep -c "tq: retrying object" push.log) ]
28 [ 1 -eq $(grep -c "tq: enqueue retry" push.log) ]
29
30 assert_server_object "$reponame" "$oid"
31 )
32 end_test
33
34 begin_test "batch storage HTTP download causes delayed retries"
35 (
36 set -e
37
38 reponame="batch-storage-download-retry-later"
39 setup_remote_repo "$reponame"
40 clone_repo "$reponame" batch-storage-repo-download
41
42 contents="storage-download-retry-later"
43 oid="$(calc_oid "$contents")"
44 printf "%s" "$contents" > a.dat
45
46 git lfs track "*.dat"
47 git add .gitattributes a.dat
48 git commit -m "initial commit"
49
50 git push origin main
51 assert_server_object "$reponame" "$oid"
52
53 pushd ..
54 git \
55 -c "filter.lfs.process=" \
56 -c "filter.lfs.smudge=cat" \
57 -c "filter.lfs.required=false" \
58 clone "$GITSERVER/$reponame" "$reponame-assert"
59
60 cd "$reponame-assert"
61
62 git config credential.helper lfstest
63
64 GIT_TRACE=1 git lfs pull origin main 2>&1 | tee pull.log
65 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
66 echo >&2 "fatal: expected \`git lfs pull origin main\` to succeed ..."
67 exit 1
68 fi
69
70 [ 1 -eq $(grep -c "tq: retrying object" pull.log) ]
71 [ 1 -eq $(grep -c "tq: enqueue retry" pull.log) ]
72
73 assert_local_object "$oid" "${#contents}"
74 popd
75 )
76 end_test
77
78 begin_test "batch storage HTTP download causes delayed retries during clone"
79 (
80 set -e
81
82 reponame="batch-storage-clone-retry-later"
83 setup_remote_repo "$reponame"
84 clone_repo "$reponame" batch-storage-repo-clone
85
86 contents="storage-download-retry-later"
87 oid="$(calc_oid "$contents")"
88 printf "%s" "$contents" > a.dat
89
90 git lfs track "*.dat"
91 git add .gitattributes a.dat
92 git commit -m "initial commit"
93
94 git push origin main
95 assert_server_object "$reponame" "$oid"
96
97 pushd ..
98 GIT_TRACE=1 git lfs clone "$GITSERVER/$reponame" "$reponame-assert" 2>&1 | tee clone.log
99 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
100 echo >&2 "fatal: expected \`git lfs clone \"$GITSERVER/$reponame\" \"$reponame-assert\"\` to succeed ..."
101 exit 1
102 fi
103
104 [ 1 -eq $(grep -c "tq: retrying object" clone.log) ]
105 [ 1 -eq $(grep -c "tq: enqueue retry" clone.log) ]
106
107 cd "$reponame-assert"
108
109 assert_local_object "$oid" "${#contents}"
110 popd
111 )
112 end_test
113
114 begin_test "batch storage HTTP upload causes retries (missing header)"
115 (
116 set -e
117
118 reponame="batch-storage-upload-retry-later-no-header"
119 setup_remote_repo "$reponame"
120 clone_repo "$reponame" batch-storage-repo-upload-no-header
121
122 contents="storage-upload-retry-later-no-header"
123 oid="$(calc_oid "$contents")"
124 printf "%s" "$contents" > a.dat
125
126 git lfs track "*.dat"
127 git add .gitattributes a.dat
128 git commit -m "initial commit"
129
130 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
131 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
132 echo >&2 "fatal: expected \`git push origin main\` to succeed ..."
133 exit 1
134 fi
135
136 [ 1 -lt $(grep -c "tq: retrying object" push.log) ]
137 [ 1 -lt $(grep -c "tq: enqueue retry" push.log) ]
138 [ 1 -eq $(grep -c "tq: enqueue retry #1" push.log) ]
139 [ 1 -eq $(grep -c "tq: enqueue retry #2" push.log) ]
140
141 assert_server_object "$reponame" "$oid"
142 )
143 end_test
144
145 begin_test "batch storage HTTP download causes retries (missing header)"
146 (
147 set -e
148
149 reponame="batch-storage-download-retry-later-no-header"
150 setup_remote_repo "$reponame"
151 clone_repo "$reponame" batch-storage-repo-download-no-header
152
153 contents="storage-download-retry-later-no-header"
154 oid="$(calc_oid "$contents")"
155 printf "%s" "$contents" > a.dat
156
157 git lfs track "*.dat"
158 git add .gitattributes a.dat
159 git commit -m "initial commit"
160
161 git push origin main
162 assert_server_object "$reponame" "$oid"
163
164 pushd ..
165 git \
166 -c "filter.lfs.process=" \
167 -c "filter.lfs.smudge=cat" \
168 -c "filter.lfs.required=false" \
169 clone "$GITSERVER/$reponame" "$reponame-assert"
170
171 cd "$reponame-assert"
172
173 git config credential.helper lfstest
174
175 GIT_TRACE=1 git lfs pull origin main 2>&1 | tee pull.log
176 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
177 echo >&2 "fatal: expected \`git lfs pull origin main\` to succeed ..."
178 exit 1
179 fi
180
181 [ 1 -lt $(grep -c "tq: retrying object" pull.log) ]
182 [ 1 -lt $(grep -c "tq: enqueue retry" pull.log) ]
183 [ 1 -eq $(grep -c "tq: enqueue retry #1" pull.log) ]
184 [ 1 -eq $(grep -c "tq: enqueue retry #2" pull.log) ]
185
186 assert_local_object "$oid" "${#contents}"
187 popd
188 )
189 end_test
190
191 begin_test "batch storage HTTP upload fails when Retry-After exceeds maxRetryTime"
192 (
193 set -e
194
195 reponame="batch-storage-upload-retry-later-exceeds-max"
196 setup_remote_repo "$reponame"
197 clone_repo "$reponame" "$reponame"
198
199 git config lfs.transfer.maxRetryTime 5
200
201 # This content announces to the server that it should respond to all
202 # object storage PUT requests with a 429 Too Many Requests
203 # status code and a Retry-After header until at least 10 seconds
204 # have passed after the first object storage PUT request.
205 contents="storage-upload-retry-later"
206 oid="$(calc_oid "$contents")"
207 printf "%s" "$contents" > a.dat
208
209 git lfs track "*.dat"
210 git add .gitattributes a.dat
211 git commit -m "initial commit"
212
213 GIT_TRACE=1 git push origin main 2>&1 | tee push.log
214 [ 0 -ne "${PIPESTATUS[0]}" ]
215
216 grep -E "tq: refusing to retry \"$oid\", retry after [0-9]*s exceeds maximum 5s" push.log
217
218 refute_server_object "$reponame" "$oid"
219 )
220 end_test
221
222 begin_test "batch storage HTTP download fails when Retry-After exceeds maxRetryTime"
223 (
224 set -e
225
226 reponame="batch-storage-download-retry-later-exceeds-max"
227 setup_remote_repo "$reponame"
228 clone_repo "$reponame" "$reponame"
229
230 # This content announces to the server that it should respond to all
231 # object storage GET requests with a 429 Too Many Requests
232 # status code and a Retry-After header until at least 10 seconds
233 # have passed after the first object storage GET request.
234 contents="storage-download-retry-later"
235 oid="$(calc_oid "$contents")"
236 printf "%s" "$contents" > a.dat
237
238 git lfs track "*.dat"
239 git add .gitattributes a.dat
240 git commit -m "initial commit"
241
242 git push origin main
243 assert_server_object "$reponame" "$oid"
244
245 pushd ..
246 git \
247 -c "filter.lfs.process=" \
248 -c "filter.lfs.smudge=cat" \
249 -c "filter.lfs.required=false" \
250 clone "$GITSERVER/$reponame" "$reponame-assert"
251
252 cd "$reponame-assert"
253
254 git config credential.helper lfstest
255 git config lfs.transfer.maxRetryTime 5
256
257 GIT_TRACE=1 git lfs pull origin main 2>&1 | tee pull.log
258 [ 0 -ne "${PIPESTATUS[0]}" ]
259
260 grep -E "tq: refusing to retry \"$oid\", retry after [0-9]+s exceeds maximum 5s" pull.log
261
262 refute_local_object "$oid"
263 popd
264 )
265 end_test