aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server/jobs.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-18 14:44:12 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-19 09:36:50 +0100
commitfae6e4da8f516a9d6c3bad9bf6f35811ccacbad8 (patch)
tree38df5942cb2fa6e5860c8e0e19471eb6b124e291 /shared/extra-utils/server/jobs.ts
parent3f8ae0e4e4da90c964597e4b3e0724da5eaa1668 (diff)
downloadPeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.tar.gz
PeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.tar.zst
PeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.zip
Try to speed up server tests
Diffstat (limited to 'shared/extra-utils/server/jobs.ts')
-rw-r--r--shared/extra-utils/server/jobs.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index a53749589..97971f960 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -1,7 +1,7 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { makeGetRequest } from '../../../shared/extra-utils' 3import { getDebug, makeGetRequest } from '../../../shared/extra-utils'
4import { Job, JobState, JobType } from '../../models' 4import { Job, JobState, JobType, ServerDebug } from '../../models'
5import { wait } from '../miscs/miscs' 5import { wait } from '../miscs/miscs'
6import { ServerInfo } from './servers' 6import { ServerInfo } from './servers'
7 7
@@ -53,7 +53,10 @@ function getJobsListPaginationAndSort (options: {
53} 53}
54 54
55async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { 55async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
56 const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) : 2000 56 const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT
57 ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10)
58 : 500
59
57 let servers: ServerInfo[] 60 let servers: ServerInfo[]
58 61
59 if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ] 62 if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ]
@@ -75,16 +78,26 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
75 start: 0, 78 start: 0,
76 count: 10, 79 count: 10,
77 sort: '-createdAt' 80 sort: '-createdAt'
78 }) 81 }).then(res => res.body.data)
79 .then(res => res.body.data)
80 .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views')) 82 .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views'))
81 .then(jobs => { 83 .then(jobs => {
82 if (jobs.length !== 0) { 84 if (jobs.length !== 0) {
83 pendingRequests = true 85 pendingRequests = true
84 } 86 }
85 }) 87 })
88
86 tasks.push(p) 89 tasks.push(p)
87 } 90 }
91
92 const p = getDebug(server.url, server.accessToken)
93 .then(res => res.body)
94 .then((obj: ServerDebug) => {
95 if (obj.activityPubMessagesWaiting !== 0) {
96 pendingRequests = true
97 }
98 })
99
100 tasks.push(p)
88 } 101 }
89 102
90 return tasks 103 return tasks