From 94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Jan 2018 15:05:18 +0100 Subject: Move job queue to redis We'll use it as cache in the future. /!\ You'll loose your old jobs (pending jobs too) so upgrade only when you don't have pending job anymore. --- server/tests/api/check-params/jobs.ts | 11 ++++++++++- server/tests/api/server/handle-down.ts | 10 +++++----- server/tests/api/server/jobs.ts | 10 +++++----- server/tests/api/videos/multiple-servers.ts | 21 +++++++++++---------- 4 files changed, 31 insertions(+), 21 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index b12818bb1..ce3ac8809 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts @@ -7,7 +7,7 @@ import { checkBadCountPagination, checkBadSortPagination, checkBadStartPaginatio import { makeGetRequest } from '../../utils/requests/requests' describe('Test jobs API validators', function () { - const path = '/api/v1/jobs/' + const path = '/api/v1/jobs/failed' let server: ServerInfo let userAccessToken = '' @@ -31,6 +31,15 @@ describe('Test jobs API validators', function () { }) describe('When listing jobs', function () { + + it('Should fail with a bad state', async function () { + await makeGetRequest({ + url: server.url, + token: server.accessToken, + path: path + 'ade' + }) + }) + it('Should fail with a bad start pagination', async function () { await checkBadStartPagination(server.url, path, server.accessToken) }) diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index de4e77b2f..4cedeb89e 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -2,6 +2,7 @@ import * as chai from 'chai' import 'mocha' +import { JobState } from '../../../../shared/models' import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { completeVideoCheck, getVideo, immutableAssign, reRunServer, viewVideo } from '../../utils' @@ -139,12 +140,11 @@ describe('Test handle downs', function () { }) it('Should not have pending/processing jobs anymore', async function () { - const res = await getJobsListPaginationAndSort(servers[0].url, servers[0].accessToken, 0, 50, '-createdAt') - const jobs = res.body.data + const states: JobState[] = [ 'inactive', 'active' ] - for (const job of jobs) { - expect(job.state).not.to.equal('pending') - expect(job.state).not.to.equal('processing') + for (const state of states) { + const res = await getJobsListPaginationAndSort(servers[ 0 ].url, servers[ 0 ].accessToken, state,0, 50, '-createdAt') + expect(res.body.data).to.have.length(0) } }) diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts index 2e17e71a4..671498769 100644 --- a/server/tests/api/server/jobs.ts +++ b/server/tests/api/server/jobs.ts @@ -35,20 +35,20 @@ describe('Test jobs', function () { }) it('Should list jobs', async function () { - const res = await getJobsList(servers[1].url, servers[1].accessToken) + const res = await getJobsList(servers[1].url, servers[1].accessToken, 'complete') expect(res.body.total).to.be.above(2) expect(res.body.data).to.have.length.above(2) }) it('Should list jobs with sort and pagination', async function () { - const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 4, 1, 'createdAt') + const res = await getJobsListPaginationAndSort(servers[1].url, servers[1].accessToken, 'complete', 1, 1, 'createdAt') expect(res.body.total).to.be.above(2) expect(res.body.data).to.have.lengthOf(1) const job = res.body.data[0] - expect(job.state).to.equal('success') - expect(job.category).to.equal('transcoding') - expect(job.handlerName).to.have.length.above(3) + + expect(job.state).to.equal('complete') + expect(job.type).to.equal('activitypub-http-unicast') expect(dateIsValid(job.createdAt)).to.be.true expect(dateIsValid(job.updatedAt)).to.be.true }) diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 4c4b5123d..0215b3011 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -475,16 +475,17 @@ describe('Test multiple servers', function () { it('Should like and dislikes videos on different services', async function () { this.timeout(20000) - const tasks: Promise[] = [] - tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')) - tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')) - tasks.push(rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')) - tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')) - tasks.push(rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')) - tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')) - tasks.push(rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')) - - await Promise.all(tasks) + await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') + await wait(200) + await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike') + await wait(200) + await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like') + await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like') + await wait(200) + await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike') + await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike') + await wait(200) + await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') await wait(10000) -- cgit v1.2.3