// Special constants for a test instance
if (isTestInstance() === true) {
ACTOR_FOLLOW_SCORE.BASE = 20
+
REMOTE_SCHEME.HTTP = 'http'
REMOTE_SCHEME.WS = 'ws'
+
STATIC_MAX_AGE = '0'
+
ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2
ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
+
CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB
+
SCHEDULER_INTERVAL = 10000
VIDEO_VIEW_LIFETIME = 1000 // 1 second
+
+ JOB_ATTEMPTS['email'] = 1
}
updateWebserverConfig()
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 { retryTransactionWrapper } from '../../../helpers/database-utils'
import { logger } from '../../../helpers/logger'
import { VideoFileModel } from '../../../models/video/video-file'
import { fetchAvatarIfExists, getOrCreateActorAndServerAndModel, updateActorAvatarInstance, updateActorInstance } from '../actor'
import {
- fetchRemoteVideo,
generateThumbnailFromUrl,
getOrCreateAccountAndVideoAndChannel,
getOrCreateVideoChannel,
videoActivityObjectToDBAttributes,
videoFileActivityUrlToDBAttributes
} from '../videos'
+import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
async function processUpdateActivity (activity: ActivityUpdate) {
const actor = await getOrCreateActorAndServerAndModel(activity.actor)
return processUpdateActor(actor, activity)
}
- return
+ return undefined
}
// ---------------------------------------------------------------------------
}
async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
- const videoUrl = activity.object.id
+ const videoObject = activity.object as VideoTorrentObject
- const videoObject = await fetchRemoteVideo(videoUrl)
- if (!videoObject) throw new Error('Cannot fetch remote video with url: ' + videoUrl)
+ if (sanitizeAndCheckVideoTorrentObject(videoObject) === false) {
+ logger.debug('Video sent by update is not valid.', { videoObject })
+ return undefined
+ }
const res = await getOrCreateAccountAndVideoAndChannel(videoObject.id)
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
})
after(async function () {
- process.kill(-server.app.pid)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ killallServers([ server ])
})
})
import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils'
import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index'
import { mockSmtpServer } from '../../utils/miscs/email'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
}
}
server = await runServer(1, overrideConfig)
-
- await wait(5000)
await setAccessTokensToServers([ server ])
{
await askResetPassword(server.url, 'user_1@example.com')
- await wait(3000)
+ await waitJobs(server)
expect(emails).to.have.lengthOf(1)
const email = emails[0]
const reason = 'my super bad reason'
await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason)
- await wait(3000)
+ await waitJobs(server)
expect(emails).to.have.lengthOf(2)
const email = emails[1]
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { completeVideoCheck } from '../../utils'
-
import {
- flushAndRunMultipleServers, flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo,
- wait
+ flushAndRunMultipleServers,
+ getVideosList,
+ killallServers,
+ ServerInfo,
+ setAccessTokensToServers,
+ uploadVideo
} from '../../utils/index'
import { dateIsValid } from '../../utils/miscs/miscs'
import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows'
import { userLogin } from '../../utils/users/login'
import { createUser } from '../../utils/users/users'
import {
- addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
+ addVideoCommentReply,
+ addVideoCommentThread,
+ getVideoCommentThreads,
getVideoThreadComments
} from '../../utils/videos/video-comments'
import { rateVideo } from '../../utils/videos/videos'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
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 () {
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 () {
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' })
await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' })
- await wait(5000)
+ await waitJobs(servers)
let res = await getVideosList(servers[0].url)
expect(res.body.total).to.equal(1)
}
}
- await wait(5000)
+ await waitJobs(servers)
// Server 1 follows server 3
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 () {
await unfollow(servers[0].url, servers[0].accessToken, servers[2])
- await wait(3000)
+ await waitJobs(servers)
let res = await getVideosList(servers[ 0 ].url)
expect(res.body.total).to.equal(1)
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
wait
} from '../../utils/index'
import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows'
-import { getJobsListPaginationAndSort } from '../../utils/server/jobs'
+import { getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs'
import {
addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
getVideoThreadComments
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 wait(5000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideosList(server.url)
videos.push(resVideo.body.video)
}
- await wait(2000)
+ await waitJobs(servers[0])
await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
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')
expect(res.body.data).to.be.an('array')
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')
expect(res.body.data).to.be.an('array')
await viewVideo(servers[0].url, videos[0].uuid)
- await wait(5000)
+ await waitJobs(servers)
const res = await getVideosList(servers[1].url)
expect(res.body.data).to.be.an('array')
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)
expect(resVideo.body).not.to.be.undefined
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)
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import 'mocha'
import { flushTests, killallServers, ServerInfo, setAccessTokensToServers, wait } from '../../utils/index'
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 { uploadVideo } from '../../utils/videos/videos'
import { dateIsValid } from '../../utils/miscs/miscs'
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
- await wait(15000)
+ await waitJobs(servers)
})
it('Should list jobs', async function () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
})
after(async function () {
- process.kill(-server.app.pid)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ killallServers([ server ])
})
})
import { flushTests, setAccessTokensToServers } from '../../utils/index'
import { getStats } from '../../utils/server/stats'
import { addVideoCommentThread } from '../../utils/videos/video-comments'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
await viewVideo(servers[0].url, videoUUID)
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 () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import { setAccessTokensToServers } from '../../utils/users/login'
import { User } from '../../../../shared/models/users'
import { VideoChannel } from '../../../../shared/models/videos'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
videoUUID = resVideo.body.video.uuid
}
- await wait(5000)
+ await waitJobs(servers)
})
it('Should be able to update my display name', async function () {
user = res.body
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 () {
expect(user.account.displayName).to.equal('my super display name')
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 () {
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 () {
await removeUser(servers[0].url, userId, servers[0].accessToken)
- await wait(5000)
+ await waitJobs(servers)
for (const server of servers) {
const resAccounts = await getAccountsList(server.url, '-createdAt')
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this[ 'ok' ]) {
- await flushTests()
- }
})
})
dateIsValid,
doubleFollow,
flushAndRunMultipleServers,
- flushTests, getLocalVideos,
+ flushTests,
+ getLocalVideos,
getVideo,
getVideoChannelsList,
getVideosList,
getVideoCommentThreads,
getVideoThreadComments
} from '../../utils/videos/video-comments'
-import { getAccountsList } from '../../utils/users/accounts'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
}
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
- await wait(10000)
+ await waitJobs(servers)
// All servers should have this video
let publishedAt: string = null
await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
// Transcoding
- await wait(30000)
+ await waitJobs(servers)
// All servers should have this video
for (const server of servers) {
}
await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
- await wait(10000)
+ await waitJobs(servers)
// All servers should have this video
for (const server of servers) {
await viewVideo(servers[2].url, localVideosServer3[1])
await Promise.all(tasks)
- await wait(1500)
+ await waitJobs(servers)
await viewVideo(servers[2].url, localVideosServer3[0])
- await wait(1500)
+ await waitJobs(servers)
await viewVideo(servers[2].url, localVideosServer3[0])
- await wait(5000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideosList(server.url)
await Promise.all(tasks)
- await wait(10000)
+ await waitJobs(servers)
let baseVideos = null
await wait(200)
await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
- await wait(10000)
+ await waitJobs(servers)
let baseVideos = null
for (const server of servers) {
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 () {
await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].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 () {
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)
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)
await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
}
- await wait(5000)
+ await waitJobs(servers)
})
it('Should have these threads', async function () {
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 () {
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 wait(5000)
+ await waitJobs(servers)
})
it('Should have the thread comments deleted on other servers too', async function () {
await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
- await wait(5000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideo(server.url, videoUUID)
await req.attach('videofile', filePath)
.expect(200)
- await wait(40000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideosList(server.url)
const maxWidth = 50
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>'
expect(res.body.html).to.equal(expectedHtml)
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import 'mocha'
import { VideoPrivacy } from '../../../../shared/models/videos'
import {
- checkVideoFilesWereRemoved, completeVideoCheck, flushTests, getVideo, getVideoCategories, getVideoLanguages, getVideoLicences,
- getVideoPrivacies, getVideosList, getVideosListPagination, getVideosListSort, killallServers, rateVideo, removeVideo, runServer,
- searchVideo, searchVideoWithPagination, searchVideoWithSort, ServerInfo, setAccessTokensToServers, testImage, updateVideo, uploadVideo,
- viewVideo, wait
+ checkVideoFilesWereRemoved,
+ completeVideoCheck,
+ flushTests,
+ getVideo,
+ getVideoCategories,
+ getVideoLanguages,
+ getVideoLicences,
+ getVideoPrivacies,
+ getVideosList,
+ getVideosListPagination,
+ getVideosListSort,
+ killallServers,
+ rateVideo,
+ removeVideo,
+ runServer,
+ searchVideo,
+ searchVideoWithPagination,
+ searchVideoWithSort,
+ ServerInfo,
+ setAccessTokensToServers,
+ testImage,
+ updateVideo,
+ uploadVideo,
+ viewVideo,
+ wait
} from '../../utils'
const expect = chai.expect
import { VideoAbuse } from '../../../../shared/models/videos'
import {
flushAndRunMultipleServers,
- flushTests,
getVideoAbusesList,
getVideosList,
killallServers,
reportVideoAbuse,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes)
// Wait videos propagation, server 2 has transcoding enabled
- await wait(15000)
+ await waitJobs(servers)
const res = await getVideosList(servers[0].url)
const videos = res.body.data
})
it('Should report abuse on a local video', async function () {
- this.timeout(10000)
+ this.timeout(15000)
const reason = 'my super bad 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
- await wait(5000)
+ await waitJobs(servers)
})
it('Should have 1 video abuses on server 1 and 0 on server 2', async function () {
await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason)
// 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 () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import {
addVideoToBlacklist,
flushAndRunMultipleServers,
- flushTests,
getBlacklistedVideosList,
getSortedBlacklistedVideosList,
getVideosList,
removeVideoFromBlacklist,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
const orderBy = lodash.orderBy
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
- await wait(15000)
+ await waitJobs(servers)
// Blacklist the two videos on server 1
await blacklistVideosOnServer(servers[0])
after(async function () {
killallServers(servers)
-
- if (this['ok']) {
- await flushTests()
- }
})
})
import {
addVideoToBlacklist,
flushAndRunMultipleServers,
- flushTests,
getVideosList,
killallServers,
searchVideo,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
// Wait videos propagation, server 2 has transcoding enabled
- await wait(10000)
+ await waitJobs(servers)
const res = await getVideosList(servers[0].url)
const videos = res.body.data
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import * as chai from 'chai'
import 'mocha'
import { User, Video } from '../../../../shared/index'
-import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo, wait } from '../../utils'
+import { doubleFollow, flushAndRunMultipleServers, getVideoChannelVideos, updateVideo, uploadVideo } from '../../utils'
import {
addVideoChannel,
deleteVideoChannel,
setAccessTokensToServers,
updateVideoChannel
} from '../../utils/index'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
firstVideoChannelUUID = user.videoChannels[0].uuid
}
- await wait(5000)
+ await waitJobs(servers)
})
it('Should have one video channel (created with root)', async () => {
videoUUID = res.body.video.uuid
}
- await wait(3000)
+ await waitJobs(servers)
})
it('Should have two video channels when getting my information', async () => {
await updateVideoChannel(servers[0].url, servers[0].accessToken, secondVideoChannelId, videoChannelAttributes)
- await wait(3000)
+ await waitJobs(servers)
})
it('Should have video channel updated', async function () {
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 () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import { testImage } from '../../utils'
import {
- dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, updateMyAvatar,
+ dateIsValid,
+ flushTests,
+ killallServers,
+ runServer,
+ ServerInfo,
+ setAccessTokensToServers,
+ updateMyAvatar,
uploadVideo
} from '../../utils/index'
import {
- addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads,
+ addVideoCommentReply,
+ addVideoCommentThread,
+ deleteVideoComment,
+ getVideoCommentThreads,
getVideoThreadComments
} from '../../utils/videos/video-comments'
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import 'mocha'
import {
flushAndRunMultipleServers,
- flushTests,
getVideo,
getVideoDescription,
getVideosList,
ServerInfo,
setAccessTokensToServers,
updateVideo,
- uploadVideo,
- wait
+ uploadVideo
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
}
await uploadVideo(servers[0].url, servers[0].accessToken, attributes)
- await wait(5000)
+ await waitJobs(servers)
const res = await getVideosList(servers[0].url)
}
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 () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import { getMyVideos } from '../../utils/videos/videos'
import {
getAccountVideos,
- getConfig, getCustomConfig,
- getMyUserInformation, getVideoChannelVideos,
+ getConfig,
+ getCustomConfig,
+ getMyUserInformation,
+ getVideoChannelVideos,
getVideosListWithToken,
runServer,
searchVideo,
- searchVideoWithToken, updateCustomConfig,
+ searchVideoWithToken,
+ updateCustomConfig,
updateMyUser
} from '../../utils'
import { ServerConfig } from '../../../../shared/models'
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
flushAndRunMultipleServers,
- flushTests,
getVideosList,
killallServers,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../../utils/index'
import { doubleFollow } from '../../utils/server/follows'
import { userLogin } from '../../utils/users/login'
import { createUser } from '../../utils/users/users'
import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
}
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 () {
await uploadVideo(servers[1].url, servers[1].accessToken, attributes)
// 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 () {
now = Date.now()
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 () {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import {
doubleFollow,
flushAndRunMultipleServers,
- flushTests,
getMyVideos,
getVideo,
getVideosList,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
- wait,
webtorrentAdd
} from '../../utils'
import { join } from 'path'
+import { waitJobs } from '../../utils/server/jobs'
const expect = chai.expect
}
await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
- await wait(10000)
+ await waitJobs(servers)
const res = await getVideosList(servers[0].url)
const video = res.body.data[0]
}
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
- await wait(20000)
+ await waitJobs(servers)
const res = await getVideosList(servers[1].url)
}
await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
- await wait(20000)
+ await waitJobs(servers)
const res = await getVideosList(servers[1].url)
await doubleFollow(servers[0], servers[1])
- await wait(15000)
+ await waitJobs(servers)
{
// Upload the video, but wait transcoding
await getVideo(servers[0].url, videoId, 404)
}
- await wait(30000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideosList(server.url)
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
killallServers,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../utils'
+import { waitJobs } from '../utils/server/jobs'
const expect = chai.expect
video2UUID = res2.body.video.uuid
// Transcoding
- await wait(40000)
+ await waitJobs(servers)
})
it('Should run a import job on video 1 with a lower resolution', async function () {
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 wait(30000)
+ await waitJobs(servers)
let magnetUri: string
for (const server of servers) {
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 wait(30000)
+ await waitJobs(servers)
let magnetUri: string
for (const server of servers) {
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 wait(30000)
+ await waitJobs(servers)
let magnetUri: string
for (const server of servers) {
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import 'mocha'
import * as chai from 'chai'
import { VideoDetails } from '../../../shared/models/videos'
-const expect = chai.expect
-
import {
+ doubleFollow,
execCLI,
+ flushAndRunMultipleServers,
flushTests,
getEnvCli,
+ getVideo,
getVideosList,
killallServers,
- parseTorrentVideo,
- runServer,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait,
- getVideo, flushAndRunMultipleServers, doubleFollow
+ uploadVideo, wait
} from '../utils'
+import { waitJobs } from '../utils/server/jobs'
+
+const expect = chai.expect
describe('Test create transcoding jobs', function () {
let servers: ServerInfo[] = []
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
video2UUID = res.body.video.uuid
- await wait(3000)
+ await waitJobs(servers)
})
it('Should have two video files on each server', async function () {
const env = getEnvCli(servers[0])
await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`)
- await wait(40000)
+ await waitJobs(servers)
for (const server of servers) {
const res = await getVideosList(server.url)
after(async function () {
killallServers(servers)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
import 'mocha'
import * as chai from 'chai'
import { VideoDetails } from '../../../shared/models/videos'
-const expect = chai.expect
-
import {
execCLI,
flushTests,
getEnvCli,
+ getVideo,
getVideosList,
killallServers,
parseTorrentVideo,
runServer,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait,
- getVideo
+ uploadVideo
} from '../utils'
+import { waitJobs } from '../utils/server/jobs'
+
+const expect = chai.expect
describe('Test update host scripts', function () {
let server: ServerInfo
const 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 () {
after(async function () {
killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
})
})
runServer,
serverLogin,
uploadVideo,
- getVideosList, updateCustomConfig, getCustomConfig
+ getVideosList, updateCustomConfig, getCustomConfig, killallServers
} from './utils'
describe('Test a client controllers', function () {
})
after(async function () {
- process.kill(-server.app.pid)
-
- // Keep the logs if the test failed
- if (this['ok']) {
- await flushTests()
- }
+ killallServers([ server ])
})
})
killallServers,
ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- wait
+ uploadVideo
} from '../utils'
import { join } from 'path'
import * as libxmljs from 'libxmljs'
import { addVideoCommentThread } from '../utils/videos/video-comments'
+import { waitJobs } from '../utils/server/jobs'
chai.use(require('chai-xml'))
chai.use(require('chai-json-schema'))
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 wait(10000)
+ await waitJobs(servers)
})
describe('All feed', function () {
import * as request from 'supertest'
import * as WebTorrent from 'webtorrent'
import { readFileBufferPromise } from '../../../helpers/core-utils'
+import { ServerInfo } from '..'
const expect = chai.expect
let webtorrent = new WebTorrent()
import * as request from 'supertest'
import { wait } from '../miscs/miscs'
import { ServerInfo } from './servers'
+import { waitJobs } from './jobs'
function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
const path = '/api/v1/server/followers'
])
// Wait request propagation
- await wait(10000)
+ await waitJobs([ server1, server2 ])
return true
}
import * as request from 'supertest'
import { JobState } from '../../../../shared/models'
+import { ServerInfo, wait } from '../index'
function getJobsList (url: string, accessToken: string, state: JobState) {
const path = '/api/v1/jobs/' + state
.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 {
getJobsList,
+ waitJobs,
getJobsListPaginationAndSort
}