aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-27 11:44:31 +0200
committerChocobozzz <me@florianbigard.com>2023-07-27 14:17:12 +0200
commitf18003d0ac5c3fc6ec8de2a89102d1e1e89182df (patch)
tree0b3baa5658478607f3417fe7c747cc3a782f15b3 /server/tests/api/check-params
parentf5af5feb5a41eb6e2796e480402106b55bd10f04 (diff)
downloadPeerTube-f18003d0ac5c3fc6ec8de2a89102d1e1e89182df.tar.gz
PeerTube-f18003d0ac5c3fc6ec8de2a89102d1e1e89182df.tar.zst
PeerTube-f18003d0ac5c3fc6ec8de2a89102d1e1e89182df.zip
Improve runner management
* Add ability to remove runner jobs * Add runner job state quick filter * Merge registration tokens and runners tables in the same page * Add copy button to copy registration token
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/runners.ts52
1 files changed, 48 insertions, 4 deletions
diff --git a/server/tests/api/check-params/runners.ts b/server/tests/api/check-params/runners.ts
index 9112ff716..7f9a0cd32 100644
--- a/server/tests/api/check-params/runners.ts
+++ b/server/tests/api/check-params/runners.ts
@@ -1,14 +1,14 @@
1import { basename } from 'path'
2/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2import { basename } from 'path'
3import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' 3import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
4import { 4import {
5 HttpStatusCode, 5 HttpStatusCode,
6 isVideoStudioTaskIntro, 6 isVideoStudioTaskIntro,
7 RunnerJob, 7 RunnerJob,
8 RunnerJobState, 8 RunnerJobState,
9 RunnerJobStudioTranscodingPayload,
9 RunnerJobSuccessPayload, 10 RunnerJobSuccessPayload,
10 RunnerJobUpdatePayload, 11 RunnerJobUpdatePayload,
11 RunnerJobStudioTranscodingPayload,
12 VideoPrivacy, 12 VideoPrivacy,
13 VideoStudioTaskIntro 13 VideoStudioTaskIntro
14} from '@shared/models' 14} from '@shared/models'
@@ -236,6 +236,10 @@ describe('Test managing runners', function () {
236 await checkBadSortPagination(server.url, path, server.accessToken) 236 await checkBadSortPagination(server.url, path, server.accessToken)
237 }) 237 })
238 238
239 it('Should fail with an invalid state', async function () {
240 await server.runners.list({ start: 0, count: 5, sort: '-createdAt' })
241 })
242
239 it('Should succeed to list with the correct params', async function () { 243 it('Should succeed to list with the correct params', async function () {
240 await server.runners.list({ start: 0, count: 5, sort: '-createdAt' }) 244 await server.runners.list({ start: 0, count: 5, sort: '-createdAt' })
241 }) 245 })
@@ -307,8 +311,48 @@ describe('Test managing runners', function () {
307 await checkBadSortPagination(server.url, path, server.accessToken) 311 await checkBadSortPagination(server.url, path, server.accessToken)
308 }) 312 })
309 313
310 it('Should succeed to list with the correct params', async function () { 314 it('Should fail with an invalid state', async function () {
311 await server.runnerJobs.list({ start: 0, count: 5, sort: '-createdAt' }) 315 await server.runnerJobs.list({ start: 0, count: 5, sort: '-createdAt', stateOneOf: 42 as any })
316 await server.runnerJobs.list({ start: 0, count: 5, sort: '-createdAt', stateOneOf: [ 42 ] as any })
317 })
318
319 it('Should succeed with the correct params', async function () {
320 await server.runnerJobs.list({ start: 0, count: 5, sort: '-createdAt', stateOneOf: [ RunnerJobState.COMPLETED ] })
321 })
322 })
323
324 describe('Delete', function () {
325 let jobUUID: string
326
327 before(async function () {
328 this.timeout(60000)
329
330 await server.videos.quickUpload({ name: 'video' })
331 await waitJobs([ server ])
332
333 const { availableJobs } = await server.runnerJobs.request({ runnerToken })
334 jobUUID = availableJobs[0].uuid
335 })
336
337 it('Should fail without oauth token', async function () {
338 await server.runnerJobs.deleteByAdmin({ token: null, jobUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
339 })
340
341 it('Should fail without admin rights', async function () {
342 await server.runnerJobs.deleteByAdmin({ token: userToken, jobUUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
343 })
344
345 it('Should fail with a bad job uuid', async function () {
346 await server.runnerJobs.deleteByAdmin({ jobUUID: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
347 })
348
349 it('Should fail with an unknown job uuid', async function () {
350 const jobUUID = badUUID
351 await server.runnerJobs.deleteByAdmin({ jobUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
352 })
353
354 it('Should succeed with the correct params', async function () {
355 await server.runnerJobs.deleteByAdmin({ jobUUID })
312 }) 356 })
313 }) 357 })
314 358