X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Freal-world%2Freal-world.ts;h=b7375f77826a84fef48fa2cedfa643ebbda42295;hb=bbe0f0645ca958d33a3f409b15166609733b663f;hp=ac83d64a6b3cb964958f0c748be8200247d78ce5;hpb=9a27cdc27c900feaae5f6db4315c4ccdfc0c4493;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts index ac83d64a6..b7375f778 100644 --- a/server/tests/real-world/real-world.ts +++ b/server/tests/real-world/real-world.ts @@ -3,22 +3,21 @@ process.env.NODE_ENV = 'test' import * as program from 'commander' import { Video, VideoFile, VideoRateType } from '../../../shared' +import { JobState } from '../../../shared/models' import { flushAndRunMultipleServers, - flushTests, - getAllVideosListBy, - getRequestsStats, + flushTests, follow, getVideo, - getVideosList, + getVideosList, getVideosListPagination, killallServers, removeVideo, ServerInfo as DefaultServerInfo, setAccessTokensToServers, updateVideo, - uploadVideo, + uploadVideo, viewVideo, wait } from '../utils' -import { follow } from '../utils/follows' +import { getJobsListPaginationAndSort } from '../utils/server/jobs' interface ServerInfo extends DefaultServerInfo { requestsNumber: number @@ -34,7 +33,7 @@ program .option('-p, --servers [n]', 'Number of servers to run (3 or 6)', /^3|6$/, 3) .option('-i, --interval-action [interval]', 'Interval in ms for an action') .option('-I, --interval-integrity [interval]', 'Interval in ms for an integrity check') - .option('-f, --flush', 'Flush datas on exit') + .option('-f, --flush', 'Flush data on exit') .option('-d, --difference', 'Display difference if integrity is not okay') .parse(process.argv) @@ -183,7 +182,7 @@ function upload (servers: ServerInfo[], numServer: number) { category: 4, nsfw: false, licence: 2, - language: 1, + language: 'en', description: Date.now() + ' description', tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ], fixture: 'video_short1.webm' @@ -229,7 +228,7 @@ async function view (servers: ServerInfo[], numServer: number) { const toView = videos[getRandomInt(0, videos.length)].id console.log('Viewing video from server ' + numServer) - return getVideo(servers[numServer].url, toView) + return viewVideo(servers[numServer].url, toView) } function like (servers: ServerInfo[], numServer: number) { @@ -258,7 +257,8 @@ async function checkIntegrity (servers: ServerInfo[]) { // Fetch all videos and remove some fields that can differ between servers for (const server of servers) { - const p = getAllVideosListBy(server.url).then(res => videos.push(res.body.data)) + const p = getVideosListPagination(server.url, 0, 1000000, '-createdAt') + .then(res => videos.push(res.body.data)) tasks.push(p) } @@ -327,7 +327,7 @@ function areDifferences (videos1: Video[], videos2: Video[]) { return `Video ${video1.uuid} has missing video file ${videoFile1.magnetUri}.` } - if (videoFile1.size !== videoFile2.size || videoFile1.resolutionLabel !== videoFile2.resolutionLabel) { + if (videoFile1.size !== videoFile2.size || videoFile1.resolution.label !== videoFile2.resolution.label) { return `Video ${video1.uuid} has different video file ${videoFile1.magnetUri}.` } }) @@ -347,24 +347,19 @@ function goodbye () { } async function isTherePendingRequests (servers: ServerInfo[]) { + const states: JobState[] = [ 'inactive', 'active', 'delayed' ] const tasks: Promise[] = [] let pendingRequests = false // Check if each server has pending request for (const server of servers) { - const p = getRequestsStats(server).then(res => { - const stats = res.body - - if ( - stats.requestScheduler.totalRequests !== 0 || - stats.requestVideoEventScheduler.totalRequests !== 0 || - stats.requestVideoQaduScheduler.totalRequests !== 0 - ) { - pendingRequests = true - } - }) - - tasks.push(p) + for (const state of states) { + const p = getJobsListPaginationAndSort(server.url, server.accessToken, state, 0, 10, '-createdAt') + .then(res => { + if (res.body.total > 0) pendingRequests = true + }) + tasks.push(p) + } } await Promise.all(tasks)