diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/check-params/runners.ts | 52 | ||||
-rw-r--r-- | server/tests/api/runners/runner-common.ts | 51 |
2 files changed, 99 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 @@ | |||
1 | import { 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 */ |
2 | import { basename } from 'path' | ||
3 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' | 3 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared' |
4 | import { | 4 | import { |
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 | ||
diff --git a/server/tests/api/runners/runner-common.ts b/server/tests/api/runners/runner-common.ts index 34a51abe7..7fed75f40 100644 --- a/server/tests/api/runners/runner-common.ts +++ b/server/tests/api/runners/runner-common.ts | |||
@@ -339,6 +339,30 @@ describe('Test runner common actions', function () { | |||
339 | 339 | ||
340 | expect(data).to.not.have.lengthOf(0) | 340 | expect(data).to.not.have.lengthOf(0) |
341 | expect(total).to.not.equal(0) | 341 | expect(total).to.not.equal(0) |
342 | |||
343 | for (const job of data) { | ||
344 | expect(job.type).to.include('hls') | ||
345 | } | ||
346 | } | ||
347 | }) | ||
348 | |||
349 | it('Should filter jobs', async function () { | ||
350 | { | ||
351 | const { total, data } = await server.runnerJobs.list({ stateOneOf: [ RunnerJobState.WAITING_FOR_PARENT_JOB ] }) | ||
352 | |||
353 | expect(data).to.not.have.lengthOf(0) | ||
354 | expect(total).to.not.equal(0) | ||
355 | |||
356 | for (const job of data) { | ||
357 | expect(job.state.label).to.equal('Waiting for parent job to finish') | ||
358 | } | ||
359 | } | ||
360 | |||
361 | { | ||
362 | const { total, data } = await server.runnerJobs.list({ stateOneOf: [ RunnerJobState.COMPLETED ] }) | ||
363 | |||
364 | expect(data).to.have.lengthOf(0) | ||
365 | expect(total).to.equal(0) | ||
342 | } | 366 | } |
343 | }) | 367 | }) |
344 | }) | 368 | }) |
@@ -598,6 +622,33 @@ describe('Test runner common actions', function () { | |||
598 | }) | 622 | }) |
599 | }) | 623 | }) |
600 | 624 | ||
625 | describe('Remove', function () { | ||
626 | |||
627 | it('Should remove a pending job', async function () { | ||
628 | await server.videos.quickUpload({ name: 'video' }) | ||
629 | await waitJobs([ server ]) | ||
630 | |||
631 | { | ||
632 | const { data } = await server.runnerJobs.list({ count: 10, sort: '-updatedAt' }) | ||
633 | |||
634 | const pendingJob = data.find(j => j.state.id === RunnerJobState.PENDING) | ||
635 | jobUUID = pendingJob.uuid | ||
636 | |||
637 | await server.runnerJobs.deleteByAdmin({ jobUUID }) | ||
638 | } | ||
639 | |||
640 | { | ||
641 | const { data } = await server.runnerJobs.list({ count: 10, sort: '-updatedAt' }) | ||
642 | |||
643 | const parent = data.find(j => j.uuid === jobUUID) | ||
644 | expect(parent).to.not.exist | ||
645 | |||
646 | const children = data.filter(j => j.parent?.uuid === jobUUID) | ||
647 | expect(children).to.have.lengthOf(0) | ||
648 | } | ||
649 | }) | ||
650 | }) | ||
651 | |||
601 | describe('Stalled jobs', function () { | 652 | describe('Stalled jobs', function () { |
602 | 653 | ||
603 | it('Should abort stalled jobs', async function () { | 654 | it('Should abort stalled jobs', async function () { |