Improve tests when waiting pending jobs

This commit is contained in:
Chocobozzz 2018-06-13 10:06:50 +02:00
parent 2186386cca
commit 3cd0734fd9
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
32 changed files with 225 additions and 252 deletions

View File

@ -449,14 +449,21 @@ const FEEDS = {
// Special constants for a test instance // Special constants for a test instance
if (isTestInstance() === true) { if (isTestInstance() === true) {
ACTOR_FOLLOW_SCORE.BASE = 20 ACTOR_FOLLOW_SCORE.BASE = 20
REMOTE_SCHEME.HTTP = 'http' REMOTE_SCHEME.HTTP = 'http'
REMOTE_SCHEME.WS = 'ws' REMOTE_SCHEME.WS = 'ws'
STATIC_MAX_AGE = '0' STATIC_MAX_AGE = '0'
ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB
SCHEDULER_INTERVAL = 10000 SCHEDULER_INTERVAL = 10000
VIDEO_VIEW_LIFETIME = 1000 // 1 second VIDEO_VIEW_LIFETIME = 1000 // 1 second
JOB_ATTEMPTS['email'] = 1
} }
updateWebserverConfig() updateWebserverConfig()

View File

@ -1,5 +1,5 @@
import * as Bluebird from 'bluebird' import * as Bluebird from 'bluebird'
import { ActivityUpdate } from '../../../../shared/models/activitypub' import { ActivityUpdate, VideoTorrentObject } from '../../../../shared/models/activitypub'
import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor' import { ActivityPubActor } from '../../../../shared/models/activitypub/activitypub-actor'
import { retryTransactionWrapper } from '../../../helpers/database-utils' import { retryTransactionWrapper } from '../../../helpers/database-utils'
import { logger } from '../../../helpers/logger' import { logger } from '../../../helpers/logger'
@ -12,13 +12,13 @@ import { VideoChannelModel } from '../../../models/video/video-channel'
import { VideoFileModel } from '../../../models/video/video-file' import { VideoFileModel } from '../../../models/video/video-file'
import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor' import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor'
import { import {
fetchRemoteVideo,
generateThumbnailFromUrl, generateThumbnailFromUrl,
getOrCreateAccountAndVideoAndChannel, getOrCreateAccountAndVideoAndChannel,
getOrCreateVideoChannel, getOrCreateVideoChannel,
videoActivityObjectToDBAttributes, videoActivityObjectToDBAttributes,
videoFileActivityUrlToDBAttributes videoFileActivityUrlToDBAttributes
} from '../videos' } from '../videos'
import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
async function processUpdateActivity (activity: ActivityUpdate) { async function processUpdateActivity (activity: ActivityUpdate) {
const actor = await getOrCreateActorAndServerAndModel(activity.actor) const actor = await getOrCreateActorAndServerAndModel(activity.actor)
@ -30,7 +30,7 @@ async function processUpdateActivity (activity: ActivityUpdate) {
return processUpdateActor(actor, activity) return processUpdateActor(actor, activity)
} }
return return undefined
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -51,10 +51,12 @@ function processUpdateVideo (actor: ActorModel, activity: ActivityUpdate) {
} }
async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
const videoUrl = activity.object.id const videoObject = activity.object as VideoTorrentObject
const videoObject = await fetchRemoteVideo(videoUrl) if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) {
if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl) logger.debug('Video sent by update is not valid.', { videoObject })
return undefined
}
const res = await getOrCreateAccountAndVideoAndChannel(videoObject.id) const res = await getOrCreateAccountAndVideoAndChannel(videoObject.id)

View File

@ -31,10 +31,5 @@ describe('Test activitypub', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -234,11 +234,6 @@ describe('Test config', function () {
}) })
after(async function () { after(async function () {
process.kill(-server.app.pid) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,6 +5,7 @@ import 'mocha'
import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils' import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils'
import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index'
import { mockSmtpServer } from '../../utils/miscs/email' import { mockSmtpServer } from '../../utils/miscs/email'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -32,8 +33,6 @@ describe('Test emails', function () {
} }
} }
server = await runServer(1, overrideConfig) server = await runServer(1, overrideConfig)
await wait(5000)
await setAccessTokensToServers([ server ]) await setAccessTokensToServers([ server ])
{ {
@ -57,7 +56,7 @@ describe('Test emails', function () {
await askResetPassword(server.url, 'user_1@example.com') await askResetPassword(server.url, 'user_1@example.com')
await wait(3000) await waitJobs(server)
expect(emails).to.have.lengthOf(1) expect(emails).to.have.lengthOf(1)
const email = emails[0] const email = emails[0]
@ -101,7 +100,7 @@ describe('Test emails', function () {
const reason = 'my super bad reason' const reason = 'my super bad reason'
await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason) await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason)
await wait(3000) await waitJobs(server)
expect(emails).to.have.lengthOf(2) expect(emails).to.have.lengthOf(2)
const email = emails[1] const email = emails[1]
@ -115,10 +114,5 @@ describe('Test emails', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,10 +5,13 @@ import 'mocha'
import { Video, VideoPrivacy } from '../../../../shared/models/videos' import { Video, VideoPrivacy } from '../../../../shared/models/videos'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { completeVideoCheck } from '../../utils' import { completeVideoCheck } from '../../utils'
import { import {
flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, flushAndRunMultipleServers,
wait getVideosList,
killallServers,
ServerInfo,
setAccessTokensToServers,
uploadVideo
} from '../../utils/index' } from '../../utils/index'
import { dateIsValid } from '../../utils/miscs/miscs' import { dateIsValid } from '../../utils/miscs/miscs'
import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows'
@ -16,10 +19,13 @@ import { expectAccountFollows } from '../../utils/users/accounts'
import { userLogin } from '../../utils/users/login' import { userLogin } from '../../utils/users/login'
import { createUser } from '../../utils/users/users' import { createUser } from '../../utils/users/users'
import { import {
addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, addVideoCommentReply,
addVideoCommentThread,
getVideoCommentThreads,
getVideoThreadComments getVideoThreadComments
} from '../../utils/videos/video-comments' } from '../../utils/videos/video-comments'
import { rateVideo } from '../../utils/videos/videos' import { rateVideo } from '../../utils/videos/videos'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -62,7 +68,7 @@ describe('Test follows', function () {
await follow(servers[0].url, [ servers[1].url, servers[2].url ], servers[0].accessToken) await follow(servers[0].url, [ servers[1].url, servers[2].url ], servers[0].accessToken)
await wait(7000) await waitJobs(servers)
}) })
it('Should have 2 followings on server 1', async function () { it('Should have 2 followings on server 1', async function () {
@ -135,7 +141,7 @@ describe('Test follows', function () {
await unfollow(servers[0].url, servers[0].accessToken, servers[2]) await unfollow(servers[0].url, servers[0].accessToken, servers[2])
await wait(3000) await waitJobs(servers)
}) })
it('Should not follow server 3 on server 1 anymore', async function () { it('Should not follow server 3 on server 1 anymore', async function () {
@ -175,7 +181,7 @@ describe('Test follows', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' })
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' }) await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' })
await wait(5000) await waitJobs(servers)
let res = await getVideosList(servers[0].url) let res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(1) expect(res.body.total).to.equal(1)
@ -240,12 +246,12 @@ describe('Test follows', function () {
} }
} }
await wait(5000) await waitJobs(servers)
// Server 1 follows server 3 // Server 1 follows server 3
await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken) await follow(servers[ 0 ].url, [ servers[ 2 ].url ], servers[ 0 ].accessToken)
await wait(7000) await waitJobs(servers)
}) })
it('Should have the correct follows counts 3', async function () { it('Should have the correct follows counts 3', async function () {
@ -352,7 +358,7 @@ describe('Test follows', function () {
await unfollow(servers[0].url, servers[0].accessToken, servers[2]) await unfollow(servers[0].url, servers[0].accessToken, servers[2])
await wait(3000) await waitJobs(servers)
let res = await getVideosList(servers[ 0 ].url) let res = await getVideosList(servers[ 0 ].url)
expect(res.body.total).to.equal(1) expect(res.body.total).to.equal(1)
@ -362,10 +368,5 @@ describe('Test follows', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -12,7 +12,7 @@ import {
wait wait
} from '../../utils/index' } from '../../utils/index'
import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows' import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows'
import { getJobsListPaginationAndSort } from '../../utils/server/jobs' import { getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs'
import { import {
addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
getVideoThreadComments getVideoThreadComments
@ -94,11 +94,11 @@ describe('Test handle downs', function () {
await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken) await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
await wait(5000) await waitJobs(servers)
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
await wait(5000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
@ -118,7 +118,7 @@ describe('Test handle downs', function () {
videos.push(resVideo.body.video) videos.push(resVideo.body.video)
} }
await wait(2000) await waitJobs(servers[0])
await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes) await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
@ -136,7 +136,9 @@ describe('Test handle downs', function () {
commentIdServer1 = resComment.body.comment.id commentIdServer1 = resComment.body.comment.id
} }
await wait(10000) await waitJobs(servers[0])
// Wait scheduler
await wait(3000)
const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt') const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt')
expect(res.body.data).to.be.an('array') expect(res.body.data).to.be.an('array')
@ -159,7 +161,7 @@ describe('Test handle downs', function () {
await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken) await follow(servers[1].url, [ servers[0].url ], servers[1].accessToken)
await wait(5000) await waitJobs(servers)
const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt') const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 1, 'createdAt')
expect(res.body.data).to.be.an('array') expect(res.body.data).to.be.an('array')
@ -171,7 +173,7 @@ describe('Test handle downs', function () {
await viewVideo(servers[0].url, videos[0].uuid) await viewVideo(servers[0].url, videos[0].uuid)
await wait(5000) await waitJobs(servers)
const res = await getVideosList(servers[1].url) const res = await getVideosList(servers[1].url)
expect(res.body.data).to.be.an('array') expect(res.body.data).to.be.an('array')
@ -189,7 +191,7 @@ describe('Test handle downs', function () {
await addVideoCommentReply(servers[0].url, servers[0].accessToken, videos[1].uuid, commentIdServer1, 'comment 1-3') await addVideoCommentReply(servers[0].url, servers[0].accessToken, videos[1].uuid, commentIdServer1, 'comment 1-3')
await wait(5000) await waitJobs(servers)
const resVideo = await getVideo(servers[1].url, videos[0].uuid) const resVideo = await getVideo(servers[1].url, videos[0].uuid)
expect(resVideo.body).not.to.be.undefined expect(resVideo.body).not.to.be.undefined
@ -230,7 +232,7 @@ describe('Test handle downs', function () {
await addVideoCommentReply(servers[1].url, servers[1].accessToken, videos[1].uuid, commentIdServer2, 'comment 1-4') await addVideoCommentReply(servers[1].url, servers[1].accessToken, videos[1].uuid, commentIdServer2, 'comment 1-4')
await wait(5000) await waitJobs(servers)
{ {
const resComment = await getVideoThreadComments(servers[0].url, videos[1].uuid, threadIdServer1) const resComment = await getVideoThreadComments(servers[0].url, videos[1].uuid, threadIdServer1)
@ -259,10 +261,5 @@ describe('Test handle downs', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -4,7 +4,7 @@ import * as chai from 'chai'
import 'mocha' import 'mocha'
import { flushTests, killallServers, ServerInfo, setAccessTokensToServers, wait } from '../../utils/index' import { flushTests, killallServers, ServerInfo, setAccessTokensToServers, wait } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { getJobsList, getJobsListPaginationAndSort } from '../../utils/server/jobs' import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs'
import { flushAndRunMultipleServers } from '../../utils/server/servers' import { flushAndRunMultipleServers } from '../../utils/server/servers'
import { uploadVideo } from '../../utils/videos/videos' import { uploadVideo } from '../../utils/videos/videos'
import { dateIsValid } from '../../utils/miscs/miscs' import { dateIsValid } from '../../utils/miscs/miscs'
@ -31,7 +31,7 @@ describe('Test jobs', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' }) await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
await wait(15000) await waitJobs(servers)
}) })
it('Should list jobs', async function () { it('Should list jobs', async function () {
@ -55,10 +55,5 @@ describe('Test jobs', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -72,11 +72,6 @@ describe('Test application behind a reverse proxy', function () {
}) })
after(async function () { after(async function () {
process.kill(-server.app.pid) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -17,6 +17,7 @@ import {
import { flushTests, setAccessTokensToServers } from '../../utils/index' import { flushTests, setAccessTokensToServers } from '../../utils/index'
import { getStats } from '../../utils/server/stats' import { getStats } from '../../utils/server/stats'
import { addVideoCommentThread } from '../../utils/videos/video-comments' import { addVideoCommentThread } from '../../utils/videos/video-comments'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -46,7 +47,7 @@ describe('Test stats', function () {
await viewVideo(servers[0].url, videoUUID) await viewVideo(servers[0].url, videoUUID)
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
await wait(5000) await waitJobs(servers)
}) })
it('Should have the correct stats on instance 1', async function () { it('Should have the correct stats on instance 1', async function () {
@ -93,10 +94,5 @@ describe('Test stats', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -20,6 +20,7 @@ import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../u
import { setAccessTokensToServers } from '../../utils/users/login' import { setAccessTokensToServers } from '../../utils/users/login'
import { User } from '../../../../shared/models/users' import { User } from '../../../../shared/models/users'
import { VideoChannel } from '../../../../shared/models/videos' import { VideoChannel } from '../../../../shared/models/videos'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -76,7 +77,7 @@ describe('Test users with multiple servers', function () {
videoUUID = resVideo.body.video.uuid videoUUID = resVideo.body.video.uuid
} }
await wait(5000) await waitJobs(servers)
}) })
it('Should be able to update my display name', async function () { it('Should be able to update my display name', async function () {
@ -92,7 +93,7 @@ describe('Test users with multiple servers', function () {
user = res.body user = res.body
expect(user.account.displayName).to.equal('my super display name') expect(user.account.displayName).to.equal('my super display name')
await wait(5000) await waitJobs(servers)
}) })
it('Should be able to update my description', async function () { it('Should be able to update my description', async function () {
@ -109,7 +110,7 @@ describe('Test users with multiple servers', function () {
expect(user.account.displayName).to.equal('my super display name') expect(user.account.displayName).to.equal('my super display name')
expect(user.account.description).to.equal('my super description updated') expect(user.account.description).to.equal('my super description updated')
await wait(5000) await waitJobs(servers)
}) })
it('Should be able to update my avatar', async function () { it('Should be able to update my avatar', async function () {
@ -128,7 +129,7 @@ describe('Test users with multiple servers', function () {
await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png') await testImage(servers[0].url, 'avatar2-resized', user.account.avatar.path, '.png')
await wait(5000) await waitJobs(servers)
}) })
it('Should have updated my profile on other servers too', async function () { it('Should have updated my profile on other servers too', async function () {
@ -178,7 +179,7 @@ describe('Test users with multiple servers', function () {
await removeUser(servers[0].url, userId, servers[0].accessToken) await removeUser(servers[0].url, userId, servers[0].accessToken)
await wait(5000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt') const resAccounts = await getAccountsList(server.url, '-createdAt')
@ -209,10 +210,5 @@ describe('Test users with multiple servers', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this[ 'ok' ]) {
await flushTests()
}
}) })
}) })

View File

@ -15,7 +15,8 @@ import {
dateIsValid, dateIsValid,
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests, getLocalVideos, flushTests,
getLocalVideos,
getVideo, getVideo,
getVideoChannelsList, getVideoChannelsList,
getVideosList, getVideosList,
@ -39,7 +40,7 @@ import {
getVideoCommentThreads, getVideoCommentThreads,
getVideoThreadComments getVideoThreadComments
} from '../../utils/videos/video-comments' } from '../../utils/videos/video-comments'
import { getAccountsList } from '../../utils/users/accounts' import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -102,7 +103,7 @@ describe('Test multiple servers', function () {
} }
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
await wait(10000) await waitJobs(servers)
// All servers should have this video // All servers should have this video
let publishedAt: string = null let publishedAt: string = null
@ -177,7 +178,7 @@ describe('Test multiple servers', function () {
await uploadVideo(servers[1].url, userAccessToken, videoAttributes) await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
// Transcoding // Transcoding
await wait(30000) await waitJobs(servers)
// All servers should have this video // All servers should have this video
for (const server of servers) { for (const server of servers) {
@ -266,7 +267,7 @@ describe('Test multiple servers', function () {
} }
await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2) await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
await wait(10000) await waitJobs(servers)
// All servers should have this video // All servers should have this video
for (const server of servers) { for (const server of servers) {
@ -496,15 +497,15 @@ describe('Test multiple servers', function () {
await viewVideo(servers[2].url, localVideosServer3[1]) await viewVideo(servers[2].url, localVideosServer3[1])
await Promise.all(tasks) await Promise.all(tasks)
await wait(1500) await waitJobs(servers)
await viewVideo(servers[2].url, localVideosServer3[0]) await viewVideo(servers[2].url, localVideosServer3[0])
await wait(1500) await waitJobs(servers)
await viewVideo(servers[2].url, localVideosServer3[0]) await viewVideo(servers[2].url, localVideosServer3[0])
await wait(5000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
@ -535,7 +536,7 @@ describe('Test multiple servers', function () {
await Promise.all(tasks) await Promise.all(tasks)
await wait(10000) await waitJobs(servers)
let baseVideos = null let baseVideos = null
@ -572,7 +573,7 @@ describe('Test multiple servers', function () {
await wait(200) await wait(200)
await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like') await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
await wait(10000) await waitJobs(servers)
let baseVideos = null let baseVideos = null
for (const server of servers) { for (const server of servers) {
@ -614,7 +615,7 @@ describe('Test multiple servers', function () {
await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes) await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
await wait(5000) await waitJobs(servers)
}) })
it('Should have the video 3 updated on each server', async function () { it('Should have the video 3 updated on each server', async function () {
@ -670,7 +671,7 @@ describe('Test multiple servers', function () {
await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id) await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id) await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
await wait(5000) await waitJobs(servers)
}) })
it('Should not have files of videos 3 and 3-2 on each server', async function () { it('Should not have files of videos 3 and 3-2 on each server', async function () {
@ -749,7 +750,7 @@ describe('Test multiple servers', function () {
await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text) await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
} }
await wait(5000) await waitJobs(servers)
{ {
const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5) const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
@ -759,7 +760,7 @@ describe('Test multiple servers', function () {
await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text) await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
} }
await wait(5000) await waitJobs(servers)
{ {
const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5) const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
@ -775,7 +776,7 @@ describe('Test multiple servers', function () {
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2) await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
} }
await wait(5000) await waitJobs(servers)
}) })
it('Should have these threads', async function () { it('Should have these threads', async function () {
@ -848,7 +849,7 @@ describe('Test multiple servers', function () {
await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id) await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
await wait(5000) await waitJobs(servers)
}) })
it('Should not have this comment anymore', async function () { it('Should not have this comment anymore', async function () {
@ -877,7 +878,7 @@ describe('Test multiple servers', function () {
const threadId = res1.body.data.find(c => c.text === 'my super first comment').id const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId) await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
await wait(5000) await waitJobs(servers)
}) })
it('Should have the thread comments deleted on other servers too', async function () { it('Should have the thread comments deleted on other servers too', async function () {
@ -910,7 +911,7 @@ describe('Test multiple servers', function () {
await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes) await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
await wait(5000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideo(server.url, videoUUID) const res = await getVideo(server.url, videoUUID)
@ -941,7 +942,7 @@ describe('Test multiple servers', function () {
await req.attach('videofile', filePath) await req.attach('videofile', filePath)
.expect(200) .expect(200)
await wait(40000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)

View File

@ -54,7 +54,8 @@ describe('Test services', function () {
const maxWidth = 50 const maxWidth = 50
const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
const expectedHtml = `<iframe width="50" height="50" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
`src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>' 'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml) expect(res.body.html).to.equal(expectedHtml)
@ -69,10 +70,5 @@ describe('Test services', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,10 +5,31 @@ import { keyBy } from 'lodash'
import 'mocha' import 'mocha'
import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoPrivacy } from '../../../../shared/models/videos'
import { import {
checkVideoFilesWereRemoved, completeVideoCheck, flushTests, getVideo, getVideoCategories, getVideoLanguages, getVideoLicences, checkVideoFilesWereRemoved,
getVideoPrivacies, getVideosList, getVideosListPagination, getVideosListSort, killallServers, rateVideo, removeVideo, runServer, completeVideoCheck,
searchVideo, searchVideoWithPagination, searchVideoWithSort, ServerInfo, setAccessTokensToServers, testImage, updateVideo, uploadVideo, flushTests,
viewVideo, wait getVideo,
getVideoCategories,
getVideoLanguages,
getVideoLicences,
getVideoPrivacies,
getVideosList,
getVideosListPagination,
getVideosListSort,
killallServers,
rateVideo,
removeVideo,
runServer,
searchVideo,
searchVideoWithPagination,
searchVideoWithSort,
ServerInfo,
setAccessTokensToServers,
testImage,
updateVideo,
uploadVideo,
viewVideo,
wait
} from '../../utils' } from '../../utils'
const expect = chai.expect const expect = chai.expect

View File

@ -5,17 +5,16 @@ import 'mocha'
import { VideoAbuse } from '../../../../shared/models/videos' import { VideoAbuse } from '../../../../shared/models/videos'
import { import {
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getVideoAbusesList, getVideoAbusesList,
getVideosList, getVideosList,
killallServers, killallServers,
reportVideoAbuse, reportVideoAbuse,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../../utils/index' } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -48,7 +47,7 @@ describe('Test video abuses', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes) await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes)
// Wait videos propagation, server 2 has transcoding enabled // Wait videos propagation, server 2 has transcoding enabled
await wait(15000) await waitJobs(servers)
const res = await getVideosList(servers[0].url) const res = await getVideosList(servers[0].url)
const videos = res.body.data const videos = res.body.data
@ -68,13 +67,13 @@ describe('Test video abuses', function () {
}) })
it('Should report abuse on a local video', async function () { it('Should report abuse on a local video', async function () {
this.timeout(10000) this.timeout(15000)
const reason = 'my super bad reason' const reason = 'my super bad reason'
await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason) await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason)
// We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
await wait(5000) await waitJobs(servers)
}) })
it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { it('Should have 1 video abuses on server 1 and 0 on server 2', async function () {
@ -103,7 +102,7 @@ describe('Test video abuses', function () {
await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason) await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason)
// We wait requests propagation // We wait requests propagation
await wait(5000) await waitJobs(servers)
}) })
it('Should have 2 video abuse on server 1 and 1 on server 2', async function () { it('Should have 2 video abuse on server 1 and 1 on server 2', async function () {
@ -137,10 +136,5 @@ describe('Test video abuses', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -6,7 +6,6 @@ import 'mocha'
import { import {
addVideoToBlacklist, addVideoToBlacklist,
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getBlacklistedVideosList, getBlacklistedVideosList,
getSortedBlacklistedVideosList, getSortedBlacklistedVideosList,
getVideosList, getVideosList,
@ -14,10 +13,10 @@ import {
removeVideoFromBlacklist, removeVideoFromBlacklist,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../../utils/index' } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
const orderBy = lodash.orderBy const orderBy = lodash.orderBy
@ -51,7 +50,7 @@ describe('Test video blacklist management', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' }) await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' })
// Wait videos propagation, server 2 has transcoding enabled // Wait videos propagation, server 2 has transcoding enabled
await wait(15000) await waitJobs(servers)
// Blacklist the two videos on server 1 // Blacklist the two videos on server 1
await blacklistVideosOnServer(servers[0]) await blacklistVideosOnServer(servers[0])
@ -154,9 +153,5 @@ describe('Test video blacklist management', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,16 +5,15 @@ import 'mocha'
import { import {
addVideoToBlacklist, addVideoToBlacklist,
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getVideosList, getVideosList,
killallServers, killallServers,
searchVideo, searchVideo,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../../utils/index' } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -41,7 +40,7 @@ describe('Test video blacklists', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
// Wait videos propagation, server 2 has transcoding enabled // Wait videos propagation, server 2 has transcoding enabled
await wait(10000) await waitJobs(servers)
const res = await getVideosList(servers[0].url) const res = await getVideosList(servers[0].url)
const videos = res.body.data const videos = res.body.data
@ -89,10 +88,5 @@ describe('Test video blacklists', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -3,7 +3,7 @@
import * as chai from 'chai' import * as chai from 'chai'
import 'mocha' import 'mocha'
import { User, Video } from '../../../../shared/index' import { User, Video } from '../../../../shared/index'
import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils' import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo } from '../../utils'
import { import {
addVideoChannel, addVideoChannel,
deleteVideoChannel, deleteVideoChannel,
@ -17,6 +17,7 @@ import {
setAccessTokensToServers, setAccessTokensToServers,
updateVideoChannel updateVideoChannel
} from '../../utils/index' } from '../../utils/index'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -49,7 +50,7 @@ describe('Test video channels', function () {
firstVideoChannelUUID = user.videoChannels[0].uuid firstVideoChannelUUID = user.videoChannels[0].uuid
} }
await wait(5000) await waitJobs(servers)
}) })
it('Should have one video channel (created with root)', async () => { it('Should have one video channel (created with root)', async () => {
@ -80,7 +81,7 @@ describe('Test video channels', function () {
videoUUID = res.body.video.uuid videoUUID = res.body.video.uuid
} }
await wait(3000) await waitJobs(servers)
}) })
it('Should have two video channels when getting my information', async () => { it('Should have two video channels when getting my information', async () => {
@ -142,7 +143,7 @@ describe('Test video channels', function () {
await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes) await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes)
await wait(3000) await waitJobs(servers)
}) })
it('Should have video channel updated', async function () { it('Should have video channel updated', async function () {
@ -184,7 +185,7 @@ describe('Test video channels', function () {
await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId }) await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { channelId: firstVideoChannelId })
await wait(5000) await waitJobs(servers)
}) })
it('Should list the first video channel videos', async function () { it('Should list the first video channel videos', async function () {
@ -219,10 +220,5 @@ describe('Test video channels', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,11 +5,20 @@ import 'mocha'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { testImage } from '../../utils' import { testImage } from '../../utils'
import { import {
dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, updateMyAvatar, dateIsValid,
flushTests,
killallServers,
runServer,
ServerInfo,
setAccessTokensToServers,
updateMyAvatar,
uploadVideo uploadVideo
} from '../../utils/index' } from '../../utils/index'
import { import {
addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads, addVideoCommentReply,
addVideoCommentThread,
deleteVideoComment,
getVideoCommentThreads,
getVideoThreadComments getVideoThreadComments
} from '../../utils/videos/video-comments' } from '../../utils/videos/video-comments'
@ -194,10 +203,5 @@ describe('Test video comments', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -4,7 +4,6 @@ import * as chai from 'chai'
import 'mocha' import 'mocha'
import { import {
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getVideo, getVideo,
getVideoDescription, getVideoDescription,
getVideosList, getVideosList,
@ -12,10 +11,10 @@ import {
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
updateVideo, updateVideo,
uploadVideo, uploadVideo
wait
} from '../../utils/index' } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -46,7 +45,7 @@ describe('Test video description', function () {
} }
await uploadVideo(servers[0].url, servers[0].accessToken, attributes) await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
await wait(5000) await waitJobs(servers)
const res = await getVideosList(servers[0].url) const res = await getVideosList(servers[0].url)
@ -85,7 +84,7 @@ describe('Test video description', function () {
} }
await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes) await updateVideo(servers[0].url, servers[0].accessToken, videoId, attributes)
await wait(5000) await waitJobs(servers)
}) })
it('Should have a small description on each server', async function () { it('Should have a small description on each server', async function () {
@ -102,10 +101,5 @@ describe('Test video description', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -8,12 +8,15 @@ import { createUser } from '../../utils/users/users'
import { getMyVideos } from '../../utils/videos/videos' import { getMyVideos } from '../../utils/videos/videos'
import { import {
getAccountVideos, getAccountVideos,
getConfig, getCustomConfig, getConfig,
getMyUserInformation, getVideoChannelVideos, getCustomConfig,
getMyUserInformation,
getVideoChannelVideos,
getVideosListWithToken, getVideosListWithToken,
runServer, runServer,
searchVideo, searchVideo,
searchVideoWithToken, updateCustomConfig, searchVideoWithToken,
updateCustomConfig,
updateMyUser updateMyUser
} from '../../utils' } from '../../utils'
import { ServerConfig } from '../../../../shared/models' import { ServerConfig } from '../../../../shared/models'
@ -201,10 +204,5 @@ describe('Test video NSFW policy', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -5,18 +5,17 @@ import 'mocha'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import { import {
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getVideosList, getVideosList,
killallServers, killallServers,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../../utils/index' } from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows' import { doubleFollow } from '../../utils/server/follows'
import { userLogin } from '../../utils/users/login' import { userLogin } from '../../utils/users/login'
import { createUser } from '../../utils/users/users' import { createUser } from '../../utils/users/users'
import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos' import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -48,7 +47,7 @@ describe('Test video privacy', function () {
} }
await uploadVideo(servers[0].url, servers[0].accessToken, attributes) await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
await wait(5000) await waitJobs(servers)
}) })
it('Should not have this private video on server 2', async function () { it('Should not have this private video on server 2', async function () {
@ -99,7 +98,7 @@ describe('Test video privacy', function () {
await uploadVideo(servers[1].url, servers[1].accessToken, attributes) await uploadVideo(servers[1].url, servers[1].accessToken, attributes)
// Server 2 has transcoding enabled // Server 2 has transcoding enabled
await wait(10000) await waitJobs(servers)
}) })
it('Should not have this unlisted video listed on server 1 and 2', async function () { it('Should not have this unlisted video listed on server 1 and 2', async function () {
@ -139,7 +138,7 @@ describe('Test video privacy', function () {
now = Date.now() now = Date.now()
await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute) await updateVideo(servers[0].url, servers[0].accessToken, privateVideoId, attribute)
await wait(5000) await waitJobs(servers)
}) })
it('Should have this new public video listed on server 1 and 2', async function () { it('Should have this new public video listed on server 1 and 2', async function () {
@ -155,10 +154,5 @@ describe('Test video privacy', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -7,7 +7,6 @@ import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils'
import { import {
doubleFollow, doubleFollow,
flushAndRunMultipleServers, flushAndRunMultipleServers,
flushTests,
getMyVideos, getMyVideos,
getVideo, getVideo,
getVideosList, getVideosList,
@ -16,10 +15,10 @@ import {
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo,
wait,
webtorrentAdd webtorrentAdd
} from '../../utils' } from '../../utils'
import { join } from 'path' import { join } from 'path'
import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -45,7 +44,7 @@ describe('Test video transcoding', function () {
} }
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes) await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
await wait(10000) await waitJobs(servers)
const res = await getVideosList(servers[0].url) const res = await getVideosList(servers[0].url)
const video = res.body.data[0] const video = res.body.data[0]
@ -73,7 +72,7 @@ describe('Test video transcoding', function () {
} }
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
await wait(20000) await waitJobs(servers)
const res = await getVideosList(servers[1].url) const res = await getVideosList(servers[1].url)
@ -102,7 +101,7 @@ describe('Test video transcoding', function () {
} }
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
await wait(20000) await waitJobs(servers)
const res = await getVideosList(servers[1].url) const res = await getVideosList(servers[1].url)
@ -125,7 +124,7 @@ describe('Test video transcoding', function () {
await doubleFollow(servers[0], servers[1]) await doubleFollow(servers[0], servers[1])
await wait(15000) await waitJobs(servers)
{ {
// Upload the video, but wait transcoding // Upload the video, but wait transcoding
@ -161,7 +160,7 @@ describe('Test video transcoding', function () {
await getVideo(servers[0].url, videoId, 404) await getVideo(servers[0].url, videoId, 404)
} }
await wait(30000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
@ -179,10 +178,5 @@ describe('Test video transcoding', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -14,9 +14,9 @@ import {
killallServers, killallServers,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../utils' } from '../utils'
import { waitJobs } from '../utils/server/jobs'
const expect = chai.expect const expect = chai.expect
@ -54,14 +54,14 @@ describe('Test create import video jobs', function () {
video2UUID = res2.body.video.uuid video2UUID = res2.body.video.uuid
// Transcoding // Transcoding
await wait(40000) await waitJobs(servers)
}) })
it('Should run a import job on video 1 with a lower resolution', async function () { it('Should run a import job on video 1 with a lower resolution', async function () {
const env = getEnvCli(servers[0]) const env = getEnvCli(servers[0])
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`)
await wait(30000) await waitJobs(servers)
let magnetUri: string let magnetUri: string
for (const server of servers) { for (const server of servers) {
@ -85,7 +85,7 @@ describe('Test create import video jobs', function () {
const env = getEnvCli(servers[1]) const env = getEnvCli(servers[1])
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`)
await wait(30000) await waitJobs(servers)
let magnetUri: string let magnetUri: string
for (const server of servers) { for (const server of servers) {
@ -111,7 +111,7 @@ describe('Test create import video jobs', function () {
const env = getEnvCli(servers[0]) const env = getEnvCli(servers[0])
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`) await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`)
await wait(30000) await waitJobs(servers)
let magnetUri: string let magnetUri: string
for (const server of servers) { for (const server of servers) {
@ -133,10 +133,5 @@ describe('Test create import video jobs', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -3,22 +3,22 @@
import 'mocha' import 'mocha'
import * as chai from 'chai' import * as chai from 'chai'
import { VideoDetails } from '../../../shared/models/videos' import { VideoDetails } from '../../../shared/models/videos'
const expect = chai.expect
import { import {
doubleFollow,
execCLI, execCLI,
flushAndRunMultipleServers,
flushTests, flushTests,
getEnvCli, getEnvCli,
getVideo,
getVideosList, getVideosList,
killallServers, killallServers,
parseTorrentVideo,
runServer,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo, wait
wait,
getVideo, flushAndRunMultipleServers, doubleFollow
} from '../utils' } from '../utils'
import { waitJobs } from '../utils/server/jobs'
const expect = chai.expect
describe('Test create transcoding jobs', function () { describe('Test create transcoding jobs', function () {
let servers: ServerInfo[] = [] let servers: ServerInfo[] = []
@ -40,7 +40,7 @@ describe('Test create transcoding jobs', function () {
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' }) const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
video2UUID = res.body.video.uuid video2UUID = res.body.video.uuid
await wait(3000) await waitJobs(servers)
}) })
it('Should have two video files on each server', async function () { it('Should have two video files on each server', async function () {
@ -65,7 +65,7 @@ describe('Test create transcoding jobs', function () {
const env = getEnvCli(servers[0]) const env = getEnvCli(servers[0])
await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`) await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`)
await wait(40000) await waitJobs(servers)
for (const server of servers) { for (const server of servers) {
const res = await getVideosList(server.url) const res = await getVideosList(server.url)
@ -102,10 +102,5 @@ describe('Test create transcoding jobs', function () {
after(async function () { after(async function () {
killallServers(servers) killallServers(servers)
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -36,10 +36,5 @@ describe('Test reset password scripts', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -3,22 +3,22 @@
import 'mocha' import 'mocha'
import * as chai from 'chai' import * as chai from 'chai'
import { VideoDetails } from '../../../shared/models/videos' import { VideoDetails } from '../../../shared/models/videos'
const expect = chai.expect
import { import {
execCLI, execCLI,
flushTests, flushTests,
getEnvCli, getEnvCli,
getVideo,
getVideosList, getVideosList,
killallServers, killallServers,
parseTorrentVideo, parseTorrentVideo,
runServer, runServer,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait,
getVideo
} from '../utils' } from '../utils'
import { waitJobs } from '../utils/server/jobs'
const expect = chai.expect
describe('Test update host scripts', function () { describe('Test update host scripts', function () {
let server: ServerInfo let server: ServerInfo
@ -41,7 +41,8 @@ describe('Test update host scripts', function () {
const videoAttributes = {} const videoAttributes = {}
await uploadVideo(server.url, server.accessToken, videoAttributes) await uploadVideo(server.url, server.accessToken, videoAttributes)
await uploadVideo(server.url, server.accessToken, videoAttributes) await uploadVideo(server.url, server.accessToken, videoAttributes)
await wait(30000)
await waitJobs(server)
}) })
it('Should update torrent hosts', async function () { it('Should update torrent hosts', async function () {
@ -82,10 +83,5 @@ describe('Test update host scripts', function () {
after(async function () { after(async function () {
killallServers([ server ]) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -11,7 +11,7 @@ import {
runServer, runServer,
serverLogin, serverLogin,
uploadVideo, uploadVideo,
getVideosList, updateCustomConfig, getCustomConfig getVideosList, updateCustomConfig, getCustomConfig, killallServers
} from './utils' } from './utils'
describe('Test a client controllers', function () { describe('Test a client controllers', function () {
@ -102,11 +102,6 @@ describe('Test a client controllers', function () {
}) })
after(async function () { after(async function () {
process.kill(-server.app.pid) killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
await flushTests()
}
}) })
}) })

View File

@ -11,12 +11,12 @@ import {
killallServers, killallServers,
ServerInfo, ServerInfo,
setAccessTokensToServers, setAccessTokensToServers,
uploadVideo, uploadVideo
wait
} from '../utils' } from '../utils'
import { join } from 'path' import { join } from 'path'
import * as libxmljs from 'libxmljs' import * as libxmljs from 'libxmljs'
import { addVideoCommentThread } from '../utils/videos/video-comments' import { addVideoCommentThread } from '../utils/videos/video-comments'
import { waitJobs } from '../utils/server/jobs'
chai.use(require('chai-xml')) chai.use(require('chai-xml'))
chai.use(require('chai-json-schema')) chai.use(require('chai-json-schema'))
@ -46,7 +46,7 @@ describe('Test syndication feeds', () => {
await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 1') await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 1')
await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 2') await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoId, 'super comment 2')
await wait(10000) await waitJobs(servers)
}) })
describe('All feed', function () { describe('All feed', function () {

View File

@ -5,6 +5,7 @@ import { isAbsolute, join } from 'path'
import * as request from 'supertest' import * as request from 'supertest'
import * as WebTorrent from 'webtorrent' import * as WebTorrent from 'webtorrent'
import { readFileBufferPromise } from '../../../helpers/core-utils' import { readFileBufferPromise } from '../../../helpers/core-utils'
import { ServerInfo } from '..'
const expect = chai.expect const expect = chai.expect
let webtorrent = new WebTorrent() let webtorrent = new WebTorrent()

View File

@ -1,6 +1,7 @@
import * as request from 'supertest' import * as request from 'supertest'
import { wait } from '../miscs/miscs' import { wait } from '../miscs/miscs'
import { ServerInfo } from './servers' import { ServerInfo } from './servers'
import { waitJobs } from './jobs'
function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) { function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
const path = '/api/v1/server/followers' const path = '/api/v1/server/followers'
@ -61,7 +62,7 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
]) ])
// Wait request propagation // Wait request propagation
await wait(10000) await waitJobs([ server1, server2 ])
return true return true
} }

View File

@ -1,5 +1,6 @@
import * as request from 'supertest' import * as request from 'supertest'
import { JobState } from '../../../../shared/models' import { JobState } from '../../../../shared/models'
import { ServerInfo, wait } from '../index'
function getJobsList (url: string, accessToken: string, state: JobState) { function getJobsList (url: string, accessToken: string, state: JobState) {
const path = '/api/v1/jobs/' + state const path = '/api/v1/jobs/' + state
@ -26,9 +27,49 @@ function getJobsListPaginationAndSort (url: string, accessToken: string, state:
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
} }
async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
let servers: ServerInfo[]
if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ]
else servers = serversArg as ServerInfo[]
const states: JobState[] = [ 'inactive', 'active', 'delayed' ]
const tasks: Promise<any>[] = []
let pendingRequests: boolean
do {
pendingRequests = false
// Check if each server has pending request
for (const server of servers) {
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)
// Retry, in case of new jobs were created
if (pendingRequests === false) {
await wait(1000)
await Promise.all(tasks)
}
if (pendingRequests) {
await wait(1000)
}
} while (pendingRequests)
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
export { export {
getJobsList, getJobsList,
waitJobs,
getJobsListPaginationAndSort getJobsListPaginationAndSort
} }