X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=scripts%2Fbenchmark.ts;h=4a414a2fa1e734af0dc686e064235edc09db1896;hb=2cca5f5f22b1b519b600854134b954f90ccfb9a9;hp=91e8b865afef8a870283759edb897fa09ef3c687;hpb=6afc0d374cbb7c87c095eaa3235e1e83134c0337;p=github%2FChocobozzz%2FPeerTube.git diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 91e8b865a..4a414a2fa 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts @@ -55,7 +55,7 @@ async function run () { path: '/accounts/peertube', headers: buildAPHeader(), expecter: (body, status) => { - return status === 200 && body.startsWith('{"type":') + return status === 200 && body.startsWith('{"@context":') } }, { @@ -63,7 +63,7 @@ async function run () { path: '/videos/watch/' + video.uuid, headers: buildAPHeader(), expecter: (body, status) => { - return status === 200 && body.startsWith('{"type":"Video"') + return status === 200 && body.startsWith('{"@context":') } }, { @@ -153,21 +153,23 @@ async function run () { } }, { - title: 'API - watching', + title: 'API - views with token', method: 'PUT', headers: { ...buildAuthorizationHeader(), ...buildJSONHeader() }, body: JSON.stringify({ currentTime: 2 }), - path: '/api/v1/videos/' + video.uuid + '/watching', + path: '/api/v1/videos/' + video.uuid + '/views', expecter: (body, status) => { return status === 204 } }, { - title: 'API - views', + title: 'API - views without token', method: 'POST', + headers: buildJSONHeader(), + body: JSON.stringify({ currentTime: 2 }), path: '/api/v1/videos/' + video.uuid + '/views', expecter: (body, status) => { return status === 204 @@ -201,12 +203,12 @@ function runBenchmark (options: { headers?: { [ id: string ]: string } expecter: Function }) { - const { method, path, body, expecter, headers } = options + const { method = 'GET', path, body, expecter, headers } = options return new Promise((res, rej) => { autocannon({ url: server.url + path, - method, + method: method, body, connections: 20, headers,