aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/helpers/request.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-16 11:17:52 +0100
committerChocobozzz <me@florianbigard.com>2021-11-16 11:34:24 +0100
commit3455c2656e257ae3d9b4169af58b6889d9904148 (patch)
tree72ef7035ffd9030cffe8e73d7c1265241c120173 /server/tests/helpers/request.ts
parentac03618098e430acb21c075bdba57ce6d377b12d (diff)
downloadPeerTube-3455c2656e257ae3d9b4169af58b6889d9904148.tar.gz
PeerTube-3455c2656e257ae3d9b4169af58b6889d9904148.tar.zst
PeerTube-3455c2656e257ae3d9b4169af58b6889d9904148.zip
Test and log request retries
Diffstat (limited to 'server/tests/helpers/request.ts')
-rw-r--r--server/tests/helpers/request.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts
index c9a2eb831..6edbf2a76 100644
--- a/server/tests/helpers/request.ts
+++ b/server/tests/helpers/request.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { pathExists, remove } from 'fs-extra' 5import { pathExists, remove } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { Mock429 } from '@shared/extra-utils/mock-servers/mock-429'
7import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' 8import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils'
8import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' 9import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
9 10
@@ -34,6 +35,20 @@ describe('Request helpers', function () {
34 throw new Error('No error thrown by do request and save to file') 35 throw new Error('No error thrown by do request and save to file')
35 }) 36 })
36 37
38 it('Should correctly retry on 429 error', async function () {
39 this.timeout(25000)
40
41 const mock = new Mock429()
42 const port = await mock.initialize()
43
44 const before = new Date().getTime()
45 await doRequest('http://localhost:' + port)
46
47 expect(new Date().getTime() - before).to.be.greaterThan(2000)
48
49 await mock.terminate()
50 })
51
37 it('Should succeed if the file is below the limit', async function () { 52 it('Should succeed if the file is below the limit', async function () {
38 await doRequest(FIXTURE_URLS.file4K, { bodyKBLimit: 5 }) 53 await doRequest(FIXTURE_URLS.file4K, { bodyKBLimit: 5 })
39 await doRequestAndSaveToFile(FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }) 54 await doRequestAndSaveToFile(FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 })