test: attempt to fix the race condition on the "max_dl.account" test
Massimo Melina committed
Mar 23, 2025 at 17:24 UTC
1cec2d1230678e2e20deddbdeed69336731daf59
1 file changed
+2
-2
tests/test.ts
+2
-2
@@ -25,7 +25,7 @@ const UPLOAD_ROOT = '/for-admins/upload/'
25
const UPLOAD_RELATIVE = 'temp/gpl.png'
26
const UPLOAD_DEST = UPLOAD_ROOT + UPLOAD_RELATIVE
27
const BIG_CONTENT = _.repeat(randomId(10), 200_000) // 2MB, big enough to saturate buffers
28
-const throttle = BIG_CONTENT.length /1000 /0.5 // KB, finish in 0.5s, quick but still overlapping downloads
28
+const throttle = BIG_CONTENT.length /1000 /0.8 // KB, finish in 0.8s, quick but still overlapping downloads
29
const SAMPLE_FILE_PATH = resolve(__dirname, 'page/gpl.png')
30
let defaultBaseUrl = BASE_URL
31
@@ -284,7 +284,7 @@ async function testMaxDl(uri: string, good: number, bad: number) {
284
const reqs = []
285
while (good--)
286
reqs.push( req(uri + '?' + (++i), 200, { throttle })() )
287
- await wait(10) // ensure it the slots are taken
287
+ await wait(1) // ensure the requests are worked by hfs before the next ones, and slots are taken. This is subject to race conditions: if the operations take less than this, the test will fail
288
while (bad--)
289
reqs.push( req(uri + '?' + (++i), 429, { throttle })() )
290
await Promise.all(reqs)