Add 429 retry batch scenario to lfstest

While the storage endpoint within lfstest-gitserver was already able to simulate
a 429 "retry-after" scenario, the same support for the LFS batch API endpoint was
missing. This commit adds this support in a similar manner to- and re-using the
"checkRateLimit" function from the storage endpoint handler.
This commit is contained in:
Fabio Huser 2021-08-08 19:32:52 +02:00
parent 7266ee06be
commit 7410062329

@ -409,6 +409,17 @@ func lfsBatchHandler(w http.ResponseWriter, r *http.Request, id, repo string) {
}
}
if strings.HasSuffix(repo, "batch-retry-later") {
if timeLeft, isWaiting := checkRateLimit("batch", "", repo, ""); isWaiting {
w.Header().Set("Retry-After", strconv.Itoa(timeLeft))
w.WriteHeader(http.StatusTooManyRequests)
w.Write([]byte("rate limit reached"))
fmt.Println("Setting header to: ", strconv.Itoa(timeLeft))
return
}
}
res := []lfsObject{}
testingChunked := testingChunkedTransferEncoding(r)
testingTus := testingTusUploadInBatchReq(r)