aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/ffmpeg-utils.ts49
-rw-r--r--server/initializers/config.ts8
-rw-r--r--server/initializers/installer.ts2
-rw-r--r--server/lib/emailer.ts66
-rw-r--r--server/lib/video-transcoding.ts31
-rw-r--r--server/tests/api/activitypub/client.ts11
-rw-r--r--server/tests/api/activitypub/fetch.ts17
-rw-r--r--server/tests/api/activitypub/refresher.ts46
-rw-r--r--server/tests/api/activitypub/security.ts106
-rw-r--r--server/tests/api/index-1.ts3
-rw-r--r--server/tests/api/index-2.ts2
-rw-r--r--server/tests/api/index-3.ts1
-rw-r--r--server/tests/api/index-4.ts2
-rw-r--r--server/tests/api/index.ts12
-rw-r--r--server/tests/api/notifications/index.ts2
-rw-r--r--server/tests/api/notifications/user-notifications.ts41
-rw-r--r--server/tests/api/redundancy/redundancy.ts34
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts39
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts31
-rw-r--r--server/tests/api/search/search-videos.ts10
-rw-r--r--server/tests/api/server/config.ts19
-rw-r--r--server/tests/api/server/contact-form.ts7
-rw-r--r--server/tests/api/server/email.ts36
-rw-r--r--server/tests/api/server/follow-constraints.ts46
-rw-r--r--server/tests/api/server/follows-moderation.ts20
-rw-r--r--server/tests/api/server/follows.ts61
-rw-r--r--server/tests/api/server/handle-down.ts76
-rw-r--r--server/tests/api/server/logs.ts2
-rw-r--r--server/tests/api/travis-1.sh10
-rw-r--r--server/tests/api/travis-2.sh9
-rw-r--r--server/tests/api/travis-3.sh8
-rw-r--r--server/tests/api/travis-4.sh9
-rw-r--r--server/tests/api/users/blocklist.ts28
-rw-r--r--server/tests/api/users/user-subscriptions.ts34
-rw-r--r--server/tests/api/users/users-multiple-servers.ts18
-rw-r--r--server/tests/api/users/users-verification.ts5
-rw-r--r--server/tests/api/users/users.ts6
-rw-r--r--server/tests/api/videos/multiple-servers.ts41
-rw-r--r--server/tests/api/videos/services.ts10
-rw-r--r--server/tests/api/videos/single-server.ts23
-rw-r--r--server/tests/api/videos/video-abuse.ts9
-rw-r--r--server/tests/api/videos/video-change-ownership.ts8
-rw-r--r--server/tests/api/videos/video-channels.ts8
-rw-r--r--server/tests/api/videos/video-comments.ts6
-rw-r--r--server/tests/api/videos/video-hls.ts9
-rw-r--r--server/tests/api/videos/video-playlists.ts4
-rw-r--r--server/tests/api/videos/video-transcoder.ts38
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts16
-rw-r--r--server/tests/cli/optimize-old-videos.ts10
49 files changed, 632 insertions, 457 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 76b744de8..2fdf34cb7 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -1,6 +1,6 @@
1import * as ffmpeg from 'fluent-ffmpeg' 1import * as ffmpeg from 'fluent-ffmpeg'
2import { dirname, join } from 'path' 2import { dirname, join } from 'path'
3import { getTargetBitrate, VideoResolution } from '../../shared/models/videos' 3import { getTargetBitrate, getMaxBitrate, VideoResolution } from '../../shared/models/videos'
4import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants' 4import { FFMPEG_NICE, VIDEO_TRANSCODING_FPS } from '../initializers/constants'
5import { processImage } from './image-utils' 5import { processImage } from './image-utils'
6import { logger } from './logger' 6import { logger } from './logger'
@@ -31,7 +31,7 @@ function computeResolutionsToTranscode (videoFileHeight: number) {
31} 31}
32 32
33async function getVideoFileSize (path: string) { 33async function getVideoFileSize (path: string) {
34 const videoStream = await getVideoFileStream(path) 34 const videoStream = await getVideoStreamFromFile(path)
35 35
36 return { 36 return {
37 width: videoStream.width, 37 width: videoStream.width,
@@ -49,7 +49,7 @@ async function getVideoFileResolution (path: string) {
49} 49}
50 50
51async function getVideoFileFPS (path: string) { 51async function getVideoFileFPS (path: string) {
52 const videoStream = await getVideoFileStream(path) 52 const videoStream = await getVideoStreamFromFile(path)
53 53
54 for (const key of [ 'avg_frame_rate', 'r_frame_rate' ]) { 54 for (const key of [ 'avg_frame_rate', 'r_frame_rate' ]) {
55 const valuesText: string = videoStream[key] 55 const valuesText: string = videoStream[key]
@@ -122,6 +122,7 @@ type TranscodeOptions = {
122 outputPath: string 122 outputPath: string
123 resolution: VideoResolution 123 resolution: VideoResolution
124 isPortraitMode?: boolean 124 isPortraitMode?: boolean
125 doQuickTranscode?: Boolean
125 126
126 hlsPlaylist?: { 127 hlsPlaylist?: {
127 videoFilename: string 128 videoFilename: string
@@ -134,7 +135,18 @@ function transcode (options: TranscodeOptions) {
134 let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING }) 135 let command = ffmpeg(options.inputPath, { niceness: FFMPEG_NICE.TRANSCODING })
135 .output(options.outputPath) 136 .output(options.outputPath)
136 137
137 if (options.hlsPlaylist) { 138 if (options.doQuickTranscode) {
139 if (options.hlsPlaylist) {
140 throw(Error("Quick transcode and HLS can't be used at the same time"))
141 }
142
143 command
144 .format('mp4')
145 .addOption('-c:v copy')
146 .addOption('-c:a copy')
147 .outputOption('-map_metadata -1') // strip all metadata
148 .outputOption('-movflags faststart')
149 } else if (options.hlsPlaylist) {
138 command = await buildHLSCommand(command, options) 150 command = await buildHLSCommand(command, options)
139 } else { 151 } else {
140 command = await buildx264Command(command, options) 152 command = await buildx264Command(command, options)
@@ -162,6 +174,30 @@ function transcode (options: TranscodeOptions) {
162 }) 174 })
163} 175}
164 176
177async function canDoQuickTranscode (path: string): Promise<boolean> {
178 // NOTE: This could be optimized by running ffprobe only once (but it runs fast anyway)
179 const videoStream = await getVideoStreamFromFile(path)
180 const parsedAudio = await audio.get(path)
181 const fps = await getVideoFileFPS(path)
182 const bitRate = await getVideoFileBitrate(path)
183 const resolution = await getVideoFileResolution(path)
184
185 // check video params
186 if (videoStream[ 'codec_name' ] !== 'h264') return false
187 if (fps < VIDEO_TRANSCODING_FPS.MIN || fps > VIDEO_TRANSCODING_FPS.MAX) return false
188 if (bitRate > getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) return false
189
190 // check audio params (if audio stream exists)
191 if (parsedAudio.audioStream) {
192 if (parsedAudio.audioStream[ 'codec_name' ] !== 'aac') return false
193
194 const maxAudioBitrate = audio.bitrate[ 'aac' ](parsedAudio.audioStream[ 'bit_rate' ])
195 if (maxAudioBitrate !== -1 && parsedAudio.audioStream[ 'bit_rate' ] > maxAudioBitrate) return false
196 }
197
198 return true
199}
200
165// --------------------------------------------------------------------------- 201// ---------------------------------------------------------------------------
166 202
167export { 203export {
@@ -173,7 +209,8 @@ export {
173 getVideoFileFPS, 209 getVideoFileFPS,
174 computeResolutionsToTranscode, 210 computeResolutionsToTranscode,
175 audio, 211 audio,
176 getVideoFileBitrate 212 getVideoFileBitrate,
213 canDoQuickTranscode
177} 214}
178 215
179// --------------------------------------------------------------------------- 216// ---------------------------------------------------------------------------
@@ -243,7 +280,7 @@ async function onTranscodingSuccess (options: TranscodeOptions) {
243 await writeFile(options.outputPath, newContent) 280 await writeFile(options.outputPath, newContent)
244} 281}
245 282
246function getVideoFileStream (path: string) { 283function getVideoStreamFromFile (path: string) {
247 return new Promise<any>((res, rej) => { 284 return new Promise<any>((res, rej) => {
248 ffmpeg.ffprobe(path, (err, metadata) => { 285 ffmpeg.ffprobe(path, (err, metadata) => {
249 if (err) return rej(err) 286 if (err) return rej(err)
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 4f77e144d..723755c45 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -44,6 +44,14 @@ const CONFIG = {
44 CA_FILE: config.get<string>('smtp.ca_file'), 44 CA_FILE: config.get<string>('smtp.ca_file'),
45 FROM_ADDRESS: config.get<string>('smtp.from_address') 45 FROM_ADDRESS: config.get<string>('smtp.from_address')
46 }, 46 },
47 EMAIL: {
48 BODY: {
49 SIGNATURE: config.get<string>('email.body.signature')
50 },
51 OBJECT: {
52 PREFIX: config.get<string>('email.object.prefix') + ' '
53 }
54 },
47 STORAGE: { 55 STORAGE: {
48 TMP_DIR: buildPath(config.get<string>('storage.tmp')), 56 TMP_DIR: buildPath(config.get<string>('storage.tmp')),
49 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), 57 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')),
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 127449577..33970f0fa 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -128,6 +128,8 @@ async function createOAuthAdminIfNotExist () {
128 128
129 // Our password is weak so do not validate it 129 // Our password is weak so do not validate it
130 validatePassword = false 130 validatePassword = false
131 } else if (process.env.PT_INITIAL_ROOT_PASSWORD) {
132 password = process.env.PT_INITIAL_ROOT_PASSWORD
131 } else { 133 } else {
132 password = passwordGenerator(16, true) 134 password = passwordGenerator(16, true)
133 } 135 }
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 8c06e9751..c4a5a5853 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -100,11 +100,11 @@ class Emailer {
100 `You can view it on ${videoUrl} ` + 100 `You can view it on ${videoUrl} ` +
101 `\n\n` + 101 `\n\n` +
102 `Cheers,\n` + 102 `Cheers,\n` +
103 `PeerTube.` 103 `${CONFIG.EMAIL.BODY.SIGNATURE}`
104 104
105 const emailPayload: EmailPayload = { 105 const emailPayload: EmailPayload = {
106 to, 106 to,
107 subject: channelName + ' just published a new video', 107 subject: CONFIG.EMAIL.OBJECT.PREFIX + channelName + ' just published a new video',
108 text 108 text
109 } 109 }
110 110
@@ -119,11 +119,11 @@ class Emailer {
119 `Your ${followType} ${followingName} has a new subscriber: ${followerName}` + 119 `Your ${followType} ${followingName} has a new subscriber: ${followerName}` +
120 `\n\n` + 120 `\n\n` +
121 `Cheers,\n` + 121 `Cheers,\n` +
122 `PeerTube.` 122 `${CONFIG.EMAIL.BODY.SIGNATURE}`
123 123
124 const emailPayload: EmailPayload = { 124 const emailPayload: EmailPayload = {
125 to, 125 to,
126 subject: 'New follower on your channel ' + followingName, 126 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New follower on your channel ' + followingName,
127 text 127 text
128 } 128 }
129 129
@@ -137,11 +137,11 @@ class Emailer {
137 `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` + 137 `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` +
138 `\n\n` + 138 `\n\n` +
139 `Cheers,\n` + 139 `Cheers,\n` +
140 `PeerTube.` 140 `${CONFIG.EMAIL.BODY.SIGNATURE}`
141 141
142 const emailPayload: EmailPayload = { 142 const emailPayload: EmailPayload = {
143 to, 143 to,
144 subject: 'New instance follower', 144 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New instance follower',
145 text 145 text
146 } 146 }
147 147
@@ -157,11 +157,11 @@ class Emailer {
157 `You can view it on ${videoUrl} ` + 157 `You can view it on ${videoUrl} ` +
158 `\n\n` + 158 `\n\n` +
159 `Cheers,\n` + 159 `Cheers,\n` +
160 `PeerTube.` 160 `${CONFIG.EMAIL.BODY.SIGNATURE}`
161 161
162 const emailPayload: EmailPayload = { 162 const emailPayload: EmailPayload = {
163 to, 163 to,
164 subject: `Your video ${video.name} is published`, 164 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video ${video.name} is published`,
165 text 165 text
166 } 166 }
167 167
@@ -177,11 +177,11 @@ class Emailer {
177 `You can view the imported video on ${videoUrl} ` + 177 `You can view the imported video on ${videoUrl} ` +
178 `\n\n` + 178 `\n\n` +
179 `Cheers,\n` + 179 `Cheers,\n` +
180 `PeerTube.` 180 `${CONFIG.EMAIL.BODY.SIGNATURE}`
181 181
182 const emailPayload: EmailPayload = { 182 const emailPayload: EmailPayload = {
183 to, 183 to,
184 subject: `Your video import ${videoImport.getTargetIdentifier()} is finished`, 184 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} is finished`,
185 text 185 text
186 } 186 }
187 187
@@ -197,11 +197,11 @@ class Emailer {
197 `See your videos import dashboard for more information: ${importUrl}` + 197 `See your videos import dashboard for more information: ${importUrl}` +
198 `\n\n` + 198 `\n\n` +
199 `Cheers,\n` + 199 `Cheers,\n` +
200 `PeerTube.` 200 `${CONFIG.EMAIL.BODY.SIGNATURE}`
201 201
202 const emailPayload: EmailPayload = { 202 const emailPayload: EmailPayload = {
203 to, 203 to,
204 subject: `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, 204 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} encountered an error`,
205 text 205 text
206 } 206 }
207 207
@@ -219,11 +219,11 @@ class Emailer {
219 `You can view it on ${commentUrl} ` + 219 `You can view it on ${commentUrl} ` +
220 `\n\n` + 220 `\n\n` +
221 `Cheers,\n` + 221 `Cheers,\n` +
222 `PeerTube.` 222 `${CONFIG.EMAIL.BODY.SIGNATURE}`
223 223
224 const emailPayload: EmailPayload = { 224 const emailPayload: EmailPayload = {
225 to, 225 to,
226 subject: 'New comment on your video ' + video.name, 226 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New comment on your video ' + video.name,
227 text 227 text
228 } 228 }
229 229
@@ -241,11 +241,11 @@ class Emailer {
241 `You can view the comment on ${commentUrl} ` + 241 `You can view the comment on ${commentUrl} ` +
242 `\n\n` + 242 `\n\n` +
243 `Cheers,\n` + 243 `Cheers,\n` +
244 `PeerTube.` 244 `${CONFIG.EMAIL.BODY.SIGNATURE}`
245 245
246 const emailPayload: EmailPayload = { 246 const emailPayload: EmailPayload = {
247 to, 247 to,
248 subject: 'Mention on video ' + video.name, 248 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Mention on video ' + video.name,
249 text 249 text
250 } 250 }
251 251
@@ -258,11 +258,11 @@ class Emailer {
258 const text = `Hi,\n\n` + 258 const text = `Hi,\n\n` +
259 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + 259 `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` +
260 `Cheers,\n` + 260 `Cheers,\n` +
261 `PeerTube.` 261 `${CONFIG.EMAIL.BODY.SIGNATURE}`
262 262
263 const emailPayload: EmailPayload = { 263 const emailPayload: EmailPayload = {
264 to, 264 to,
265 subject: '[PeerTube] Received a video abuse', 265 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Received a video abuse',
266 text 266 text
267 } 267 }
268 268
@@ -281,11 +281,11 @@ class Emailer {
281 `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` + 281 `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` +
282 `\n\n` + 282 `\n\n` +
283 `Cheers,\n` + 283 `Cheers,\n` +
284 `PeerTube.` 284 `${CONFIG.EMAIL.BODY.SIGNATURE}`
285 285
286 const emailPayload: EmailPayload = { 286 const emailPayload: EmailPayload = {
287 to, 287 to,
288 subject: '[PeerTube] An auto-blacklisted video is awaiting review', 288 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'An auto-blacklisted video is awaiting review',
289 text 289 text
290 } 290 }
291 291
@@ -296,11 +296,11 @@ class Emailer {
296 const text = `Hi,\n\n` + 296 const text = `Hi,\n\n` +
297 `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` + 297 `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` +
298 `Cheers,\n` + 298 `Cheers,\n` +
299 `PeerTube.` 299 `${CONFIG.EMAIL.BODY.SIGNATURE}`
300 300
301 const emailPayload: EmailPayload = { 301 const emailPayload: EmailPayload = {
302 to, 302 to,
303 subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST, 303 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New user registration on ' + WEBSERVER.HOST,
304 text 304 text
305 } 305 }
306 306
@@ -318,11 +318,11 @@ class Emailer {
318 blockedString + 318 blockedString +
319 '\n\n' + 319 '\n\n' +
320 'Cheers,\n' + 320 'Cheers,\n' +
321 `PeerTube.` 321 `${CONFIG.EMAIL.BODY.SIGNATURE}`
322 322
323 const emailPayload: EmailPayload = { 323 const emailPayload: EmailPayload = {
324 to, 324 to,
325 subject: `[PeerTube] Video ${videoName} blacklisted`, 325 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${videoName} blacklisted`,
326 text 326 text
327 } 327 }
328 328
@@ -336,11 +336,11 @@ class Emailer {
336 `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` + 336 `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` +
337 '\n\n' + 337 '\n\n' +
338 'Cheers,\n' + 338 'Cheers,\n' +
339 `PeerTube.` 339 `${CONFIG.EMAIL.BODY.SIGNATURE}`
340 340
341 const emailPayload: EmailPayload = { 341 const emailPayload: EmailPayload = {
342 to, 342 to,
343 subject: `[PeerTube] Video ${video.name} unblacklisted`, 343 subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${video.name} unblacklisted`,
344 text 344 text
345 } 345 }
346 346
@@ -353,11 +353,11 @@ class Emailer {
353 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + 353 `Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
354 `If you are not the person who initiated this request, please ignore this email.\n\n` + 354 `If you are not the person who initiated this request, please ignore this email.\n\n` +
355 `Cheers,\n` + 355 `Cheers,\n` +
356 `PeerTube.` 356 `${CONFIG.EMAIL.BODY.SIGNATURE}`
357 357
358 const emailPayload: EmailPayload = { 358 const emailPayload: EmailPayload = {
359 to: [ to ], 359 to: [ to ],
360 subject: 'Reset your PeerTube password', 360 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Reset your password',
361 text 361 text
362 } 362 }
363 363
@@ -370,11 +370,11 @@ class Emailer {
370 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + 370 `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` +
371 `If you are not the person who initiated this request, please ignore this email.\n\n` + 371 `If you are not the person who initiated this request, please ignore this email.\n\n` +
372 `Cheers,\n` + 372 `Cheers,\n` +
373 `PeerTube.` 373 `${CONFIG.EMAIL.BODY.SIGNATURE}`
374 374
375 const emailPayload: EmailPayload = { 375 const emailPayload: EmailPayload = {
376 to: [ to ], 376 to: [ to ],
377 subject: 'Verify your PeerTube email', 377 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Verify your email',
378 text 378 text
379 } 379 }
380 380
@@ -390,12 +390,12 @@ class Emailer {
390 blockedString + 390 blockedString +
391 '\n\n' + 391 '\n\n' +
392 'Cheers,\n' + 392 'Cheers,\n' +
393 `PeerTube.` 393 `${CONFIG.EMAIL.BODY.SIGNATURE}`
394 394
395 const to = user.email 395 const to = user.email
396 const emailPayload: EmailPayload = { 396 const emailPayload: EmailPayload = {
397 to: [ to ], 397 to: [ to ],
398 subject: '[PeerTube] Account ' + blockedWord, 398 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Account ' + blockedWord,
399 text 399 text
400 } 400 }
401 401
@@ -415,7 +415,7 @@ class Emailer {
415 fromDisplayName: fromEmail, 415 fromDisplayName: fromEmail,
416 replyTo: fromEmail, 416 replyTo: fromEmail,
417 to: [ CONFIG.ADMIN.EMAIL ], 417 to: [ CONFIG.ADMIN.EMAIL ],
418 subject: '[PeerTube] Contact form submitted', 418 subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Contact form submitted',
419 text 419 text
420 } 420 }
421 421
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts
index 0fe0ff12a..d6b6b251a 100644
--- a/server/lib/video-transcoding.ts
+++ b/server/lib/video-transcoding.ts
@@ -1,6 +1,6 @@
1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants' 1import { HLS_STREAMING_PLAYLIST_DIRECTORY, P2P_MEDIA_LOADER_PEER_VERSION, WEBSERVER } from '../initializers/constants'
2import { join } from 'path' 2import { join } from 'path'
3import { getVideoFileFPS, transcode } from '../helpers/ffmpeg-utils' 3import { getVideoFileFPS, transcode, canDoQuickTranscode } from '../helpers/ffmpeg-utils'
4import { ensureDir, move, remove, stat } from 'fs-extra' 4import { ensureDir, move, remove, stat } from 'fs-extra'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { VideoResolution } from '../../shared/models/videos' 6import { VideoResolution } from '../../shared/models/videos'
@@ -11,18 +11,25 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type' 11import { VideoStreamingPlaylistType } from '../../shared/models/videos/video-streaming-playlist.type'
12import { CONFIG } from '../initializers/config' 12import { CONFIG } from '../initializers/config'
13 13
14/**
15 * Optimize the original video file and replace it. The resolution is not changed.
16 */
14async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { 17async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) {
15 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 18 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
19 const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
16 const newExtname = '.mp4' 20 const newExtname = '.mp4'
17 21
18 const inputVideoFile = inputVideoFileArg ? inputVideoFileArg : video.getOriginalFile() 22 const inputVideoFile = inputVideoFileArg ? inputVideoFileArg : video.getOriginalFile()
19 const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) 23 const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile))
20 const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) 24 const videoTranscodedPath = join(transcodeDirectory, video.id + '-transcoded' + newExtname)
25
26 const doQuickTranscode = await(canDoQuickTranscode(videoInputPath))
21 27
22 const transcodeOptions = { 28 const transcodeOptions = {
23 inputPath: videoInputPath, 29 inputPath: videoInputPath,
24 outputPath: videoTranscodedPath, 30 outputPath: videoTranscodedPath,
25 resolution: inputVideoFile.resolution 31 resolution: inputVideoFile.resolution,
32 doQuickTranscode
26 } 33 }
27 34
28 // Could be very long! 35 // Could be very long!
@@ -34,10 +41,11 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi
34 // Important to do this before getVideoFilename() to take in account the new file extension 41 // Important to do this before getVideoFilename() to take in account the new file extension
35 inputVideoFile.set('extname', newExtname) 42 inputVideoFile.set('extname', newExtname)
36 43
44 const stats = await stat(videoTranscodedPath)
45 const fps = await getVideoFileFPS(videoTranscodedPath)
46
37 const videoOutputPath = video.getVideoFilePath(inputVideoFile) 47 const videoOutputPath = video.getVideoFilePath(inputVideoFile)
38 await move(videoTranscodedPath, videoOutputPath) 48 await move(videoTranscodedPath, videoOutputPath)
39 const stats = await stat(videoOutputPath)
40 const fps = await getVideoFileFPS(videoOutputPath)
41 49
42 inputVideoFile.set('size', stats.size) 50 inputVideoFile.set('size', stats.size)
43 inputVideoFile.set('fps', fps) 51 inputVideoFile.set('fps', fps)
@@ -52,8 +60,12 @@ async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFi
52 } 60 }
53} 61}
54 62
63/**
64 * Transcode the original video file to a lower resolution.
65 */
55async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) { 66async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoResolution, isPortrait: boolean) {
56 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 67 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR
68 const transcodeDirectory = CONFIG.STORAGE.TMP_DIR
57 const extname = '.mp4' 69 const extname = '.mp4'
58 70
59 // We are sure it's x264 in mp4 because optimizeOriginalVideofile was already executed 71 // We are sure it's x264 in mp4 because optimizeOriginalVideofile was already executed
@@ -66,18 +78,21 @@ async function transcodeOriginalVideofile (video: VideoModel, resolution: VideoR
66 videoId: video.id 78 videoId: video.id
67 }) 79 })
68 const videoOutputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(newVideoFile)) 80 const videoOutputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(newVideoFile))
81 const videoTranscodedPath = join(transcodeDirectory, video.getVideoFilename(newVideoFile))
69 82
70 const transcodeOptions = { 83 const transcodeOptions = {
71 inputPath: videoInputPath, 84 inputPath: videoInputPath,
72 outputPath: videoOutputPath, 85 outputPath: videoTranscodedPath,
73 resolution, 86 resolution,
74 isPortraitMode: isPortrait 87 isPortraitMode: isPortrait
75 } 88 }
76 89
77 await transcode(transcodeOptions) 90 await transcode(transcodeOptions)
78 91
79 const stats = await stat(videoOutputPath) 92 const stats = await stat(videoTranscodedPath)
80 const fps = await getVideoFileFPS(videoOutputPath) 93 const fps = await getVideoFileFPS(videoTranscodedPath)
94
95 await move(videoTranscodedPath, videoOutputPath)
81 96
82 newVideoFile.set('size', stats.size) 97 newVideoFile.set('size', stats.size)
83 newVideoFile.set('fps', fps) 98 newVideoFile.set('fps', fps)
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index edf588c16..34c6be49b 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -3,6 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 doubleFollow, 7 doubleFollow,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 flushTests, 9 flushTests,
@@ -39,7 +40,7 @@ describe('Test activitypub', function () {
39 const object = res.body 40 const object = res.body
40 41
41 expect(object.type).to.equal('Person') 42 expect(object.type).to.equal('Person')
42 expect(object.id).to.equal('http://localhost:9001/accounts/root') 43 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')
43 expect(object.name).to.equal('root') 44 expect(object.name).to.equal('root')
44 expect(object.preferredUsername).to.equal('root') 45 expect(object.preferredUsername).to.equal('root')
45 }) 46 })
@@ -49,17 +50,17 @@ describe('Test activitypub', function () {
49 const object = res.body 50 const object = res.body
50 51
51 expect(object.type).to.equal('Video') 52 expect(object.type).to.equal('Video')
52 expect(object.id).to.equal('http://localhost:9001/videos/watch/' + videoUUID) 53 expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
53 expect(object.name).to.equal('video') 54 expect(object.name).to.equal('video')
54 }) 55 })
55 56
56 it('Should redirect to the origin video object', async function () { 57 it('Should redirect to the origin video object', async function () {
57 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) 58 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)
58 59
59 expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID) 60 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
60 }) 61 })
61 62
62 after(function () { 63 after(async function () {
63 killallServers(servers) 64 await cleanupTests(servers)
64 }) 65 })
65}) 66})
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 7240bb0fb..3a1c0d321 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 closeAllSequelize, 7 closeAllSequelize,
7 createUser, 8 createUser,
8 doubleFollow, 9 doubleFollow,
@@ -48,8 +49,16 @@ describe('Test ActivityPub fetcher', function () {
48 const badVideoUUID = res.body.video.uuid 49 const badVideoUUID = res.body.video.uuid
49 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' }) 50 await uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })
50 51
51 await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1') 52 {
52 await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID) 53 const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
54 const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
55 await setActorField(servers[0].internalServerNumber, to, 'url', value)
56 }
57
58 {
59 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID
60 await setVideoField(servers[0].internalServerNumber, badVideoUUID, 'url', value)
61 }
53 }) 62 })
54 63
55 it('Should add only the video with a valid actor URL', async function () { 64 it('Should add only the video with a valid actor URL', async function () {
@@ -78,7 +87,9 @@ describe('Test ActivityPub fetcher', function () {
78 }) 87 })
79 88
80 after(async function () { 89 after(async function () {
81 killallServers(servers) 90 this.timeout(10000)
91
92 await cleanupTests(servers)
82 93
83 await closeAllSequelize(servers) 94 await closeAllSequelize(servers)
84 }) 95 })
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 9be9aa495..921ee874c 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -2,13 +2,14 @@
2 2
3import 'mocha' 3import 'mocha'
4import { 4import {
5 cleanupTests, closeAllSequelize,
5 createVideoPlaylist, 6 createVideoPlaylist,
6 doubleFollow, 7 doubleFollow,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 generateUserAccessToken, 9 generateUserAccessToken,
9 getVideo, 10 getVideo,
10 getVideoPlaylist, 11 getVideoPlaylist,
11 killallServers, rateVideo, 12 killallServers,
12 reRunServer, 13 reRunServer,
13 ServerInfo, 14 ServerInfo,
14 setAccessTokensToServers, 15 setAccessTokensToServers,
@@ -48,26 +49,26 @@ describe('Test AP refresher', function () {
48 } 49 }
49 50
50 { 51 {
51 const a1 = await generateUserAccessToken(servers[1], 'user1') 52 const a1 = await generateUserAccessToken(servers[ 1 ], 'user1')
52 await uploadVideo(servers[1].url, a1, { name: 'video4' }) 53 await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' })
53 54
54 const a2 = await generateUserAccessToken(servers[1], 'user2') 55 const a2 = await generateUserAccessToken(servers[ 1 ], 'user2')
55 await uploadVideo(servers[1].url, a2, { name: 'video5' }) 56 await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' })
56 } 57 }
57 58
58 { 59 {
59 const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } 60 const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
60 const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) 61 const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
61 playlistUUID1 = res.body.videoPlaylist.uuid 62 playlistUUID1 = res.body.videoPlaylist.uuid
62 } 63 }
63 64
64 { 65 {
65 const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } 66 const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }
66 const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) 67 const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })
67 playlistUUID2 = res.body.videoPlaylist.uuid 68 playlistUUID2 = res.body.videoPlaylist.uuid
68 } 69 }
69 70
70 await doubleFollow(servers[0], servers[1]) 71 await doubleFollow(servers[ 0 ], servers[ 1 ])
71 }) 72 })
72 73
73 describe('Videos refresher', function () { 74 describe('Videos refresher', function () {
@@ -78,7 +79,7 @@ describe('Test AP refresher', function () {
78 await wait(10000) 79 await wait(10000)
79 80
80 // Change UUID so the remote server returns a 404 81 // Change UUID so the remote server returns a 404
81 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') 82 await setVideoField(servers[ 1 ].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
82 83
83 await getVideo(servers[ 0 ].url, videoUUID1) 84 await getVideo(servers[ 0 ].url, videoUUID1)
84 await getVideo(servers[ 0 ].url, videoUUID2) 85 await getVideo(servers[ 0 ].url, videoUUID2)
@@ -94,7 +95,7 @@ describe('Test AP refresher', function () {
94 95
95 killallServers([ servers[ 1 ] ]) 96 killallServers([ servers[ 1 ] ])
96 97
97 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') 98 await setVideoField(servers[ 1 ].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
98 99
99 // Video will need a refresh 100 // Video will need a refresh
100 await wait(10000) 101 await wait(10000)
@@ -121,15 +122,16 @@ describe('Test AP refresher', function () {
121 await wait(10000) 122 await wait(10000)
122 123
123 // Change actor name so the remote server returns a 404 124 // Change actor name so the remote server returns a 404
124 await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto') 125 const to = 'http://localhost:' + servers[ 1 ].port + '/accounts/user2'
126 await setActorField(servers[ 1 ].internalServerNumber, to, 'preferredUsername', 'toto')
125 127
126 await getAccount(servers[ 0 ].url, 'user1@localhost:9002') 128 await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port)
127 await getAccount(servers[ 0 ].url, 'user2@localhost:9002') 129 await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port)
128 130
129 await waitJobs(servers) 131 await waitJobs(servers)
130 132
131 await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200) 133 await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200)
132 await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404) 134 await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404)
133 }) 135 })
134 }) 136 })
135 137
@@ -141,7 +143,7 @@ describe('Test AP refresher', function () {
141 await wait(10000) 143 await wait(10000)
142 144
143 // Change UUID so the remote server returns a 404 145 // Change UUID so the remote server returns a 404
144 await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') 146 await setPlaylistField(servers[ 1 ].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
145 147
146 await getVideoPlaylist(servers[ 0 ].url, playlistUUID1) 148 await getVideoPlaylist(servers[ 0 ].url, playlistUUID1)
147 await getVideoPlaylist(servers[ 0 ].url, playlistUUID2) 149 await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
@@ -153,7 +155,11 @@ describe('Test AP refresher', function () {
153 }) 155 })
154 }) 156 })
155 157
156 after(function () { 158 after(async function () {
157 killallServers(servers) 159 this.timeout(10000)
160
161 await cleanupTests(servers)
162
163 await closeAllSequelize(servers)
158 }) 164 })
159}) 165})
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index 11e6859bf..dc960c5c3 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -3,9 +3,9 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 closeAllSequelize, 7 closeAllSequelize,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 flushTests,
9 killallServers, 9 killallServers,
10 ServerInfo, 10 ServerInfo,
11 setActorField 11 setActorField
@@ -18,18 +18,26 @@ import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-u
18 18
19const expect = chai.expect 19const expect = chai.expect
20 20
21function setKeysOfServer2 (serverNumber: number, publicKey: string, privateKey: string) { 21function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) {
22 return Promise.all([ 22 return Promise.all([
23 setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'publicKey', publicKey), 23 setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'publicKey', publicKey),
24 setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'privateKey', privateKey) 24 setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'privateKey', privateKey)
25 ]) 25 ])
26} 26}
27 27
28function setKeysOfServer3 (serverNumber: number, publicKey: string, privateKey: string) { 28function getAnnounceWithoutContext (server2: ServerInfo) {
29 return Promise.all([ 29 const json = require('./json/peertube/announce-without-context.json')
30 setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'publicKey', publicKey), 30 const result: typeof json = {}
31 setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'privateKey', privateKey) 31
32 ]) 32 for (const key of Object.keys(json)) {
33 if (Array.isArray(json[key])) {
34 result[key] = json[key].map(v => v.replace(':9002', `:${server2.port}`))
35 } else {
36 result[ key ] = json[ key ].replace(':9002', `:${server2.port}`)
37 }
38 }
39
40 return result
33} 41}
34 42
35describe('Test ActivityPub security', function () { 43describe('Test ActivityPub security', function () {
@@ -38,13 +46,13 @@ describe('Test ActivityPub security', function () {
38 46
39 const keys = require('./json/peertube/keys.json') 47 const keys = require('./json/peertube/keys.json')
40 const invalidKeys = require('./json/peertube/invalid-keys.json') 48 const invalidKeys = require('./json/peertube/invalid-keys.json')
41 const baseHttpSignature = { 49 const baseHttpSignature = () => ({
42 algorithm: HTTP_SIGNATURE.ALGORITHM, 50 algorithm: HTTP_SIGNATURE.ALGORITHM,
43 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME, 51 authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,
44 keyId: 'acct:peertube@localhost:9002', 52 keyId: 'acct:peertube@localhost:' + servers[1].port,
45 key: keys.privateKey, 53 key: keys.privateKey,
46 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN 54 headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
47 } 55 })
48 56
49 // --------------------------------------------------------------- 57 // ---------------------------------------------------------------
50 58
@@ -55,56 +63,56 @@ describe('Test ActivityPub security', function () {
55 63
56 url = servers[0].url + '/inbox' 64 url = servers[0].url + '/inbox'
57 65
58 await setKeysOfServer2(1, keys.publicKey, keys.privateKey) 66 await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)
59 67
60 const to = { url: 'http://localhost:9001/accounts/peertube' } 68 const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
61 const by = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey } 69 const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey }
62 await makeFollowRequest(to, by) 70 await makeFollowRequest(to, by)
63 }) 71 })
64 72
65 describe('When checking HTTP signature', function () { 73 describe('When checking HTTP signature', function () {
66 74
67 it('Should fail with an invalid digest', async function () { 75 it('Should fail with an invalid digest', async function () {
68 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 76 const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
69 const headers = { 77 const headers = {
70 Digest: buildDigest({ hello: 'coucou' }) 78 Digest: buildDigest({ hello: 'coucou' })
71 } 79 }
72 80
73 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) 81 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
74 82
75 expect(response.statusCode).to.equal(403) 83 expect(response.statusCode).to.equal(403)
76 }) 84 })
77 85
78 it('Should fail with an invalid date', async function () { 86 it('Should fail with an invalid date', async function () {
79 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 87 const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
80 const headers = buildGlobalHeaders(body) 88 const headers = buildGlobalHeaders(body)
81 headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT' 89 headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
82 90
83 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) 91 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
84 92
85 expect(response.statusCode).to.equal(403) 93 expect(response.statusCode).to.equal(403)
86 }) 94 })
87 95
88 it('Should fail with bad keys', async function () { 96 it('Should fail with bad keys', async function () {
89 await setKeysOfServer2(1, invalidKeys.publicKey, invalidKeys.privateKey) 97 await setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)
90 await setKeysOfServer2(2, invalidKeys.publicKey, invalidKeys.privateKey) 98 await setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)
91 99
92 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 100 const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
93 const headers = buildGlobalHeaders(body) 101 const headers = buildGlobalHeaders(body)
94 102
95 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) 103 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
96 104
97 expect(response.statusCode).to.equal(403) 105 expect(response.statusCode).to.equal(403)
98 }) 106 })
99 107
100 it('Should succeed with a valid HTTP signature', async function () { 108 it('Should succeed with a valid HTTP signature', async function () {
101 await setKeysOfServer2(1, keys.publicKey, keys.privateKey) 109 await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)
102 await setKeysOfServer2(2, keys.publicKey, keys.privateKey) 110 await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey)
103 111
104 const body = activityPubContextify(require('./json/peertube/announce-without-context.json')) 112 const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
105 const headers = buildGlobalHeaders(body) 113 const headers = buildGlobalHeaders(body)
106 114
107 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers) 115 const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
108 116
109 expect(response.statusCode).to.equal(204) 117 expect(response.statusCode).to.equal(204)
110 }) 118 })
@@ -112,28 +120,28 @@ describe('Test ActivityPub security', function () {
112 120
113 describe('When checking Linked Data Signature', function () { 121 describe('When checking Linked Data Signature', function () {
114 before(async () => { 122 before(async () => {
115 await setKeysOfServer3(3, keys.publicKey, keys.privateKey) 123 await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey)
116 124
117 const to = { url: 'http://localhost:9001/accounts/peertube' } 125 const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }
118 const by = { url: 'http://localhost:9003/accounts/peertube', privateKey: keys.privateKey } 126 const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey }
119 await makeFollowRequest(to, by) 127 await makeFollowRequest(to, by)
120 }) 128 })
121 129
122 it('Should fail with bad keys', async function () { 130 it('Should fail with bad keys', async function () {
123 this.timeout(10000) 131 this.timeout(10000)
124 132
125 await setKeysOfServer3(1, invalidKeys.publicKey, invalidKeys.privateKey) 133 await setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
126 await setKeysOfServer3(3, invalidKeys.publicKey, invalidKeys.privateKey) 134 await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)
127 135
128 const body = require('./json/peertube/announce-without-context.json') 136 const body = getAnnounceWithoutContext(servers[1])
129 body.actor = 'http://localhost:9003/accounts/peertube' 137 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
130 138
131 const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:9003/accounts/peertube' } 139 const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
132 const signedBody = await buildSignedActivity(signer, body) 140 const signedBody = await buildSignedActivity(signer, body)
133 141
134 const headers = buildGlobalHeaders(signedBody) 142 const headers = buildGlobalHeaders(signedBody)
135 143
136 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) 144 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
137 145
138 expect(response.statusCode).to.equal(403) 146 expect(response.statusCode).to.equal(403)
139 }) 147 })
@@ -141,20 +149,20 @@ describe('Test ActivityPub security', function () {
141 it('Should fail with an altered body', async function () { 149 it('Should fail with an altered body', async function () {
142 this.timeout(10000) 150 this.timeout(10000)
143 151
144 await setKeysOfServer3(1, keys.publicKey, keys.privateKey) 152 await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
145 await setKeysOfServer3(3, keys.publicKey, keys.privateKey) 153 await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)
146 154
147 const body = require('./json/peertube/announce-without-context.json') 155 const body = getAnnounceWithoutContext(servers[1])
148 body.actor = 'http://localhost:9003/accounts/peertube' 156 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
149 157
150 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' } 158 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
151 const signedBody = await buildSignedActivity(signer, body) 159 const signedBody = await buildSignedActivity(signer, body)
152 160
153 signedBody.actor = 'http://localhost:9003/account/peertube' 161 signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube'
154 162
155 const headers = buildGlobalHeaders(signedBody) 163 const headers = buildGlobalHeaders(signedBody)
156 164
157 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) 165 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
158 166
159 expect(response.statusCode).to.equal(403) 167 expect(response.statusCode).to.equal(403)
160 }) 168 })
@@ -162,22 +170,24 @@ describe('Test ActivityPub security', function () {
162 it('Should succeed with a valid signature', async function () { 170 it('Should succeed with a valid signature', async function () {
163 this.timeout(10000) 171 this.timeout(10000)
164 172
165 const body = require('./json/peertube/announce-without-context.json') 173 const body = getAnnounceWithoutContext(servers[1])
166 body.actor = 'http://localhost:9003/accounts/peertube' 174 body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'
167 175
168 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' } 176 const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }
169 const signedBody = await buildSignedActivity(signer, body) 177 const signedBody = await buildSignedActivity(signer, body)
170 178
171 const headers = buildGlobalHeaders(signedBody) 179 const headers = buildGlobalHeaders(signedBody)
172 180
173 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers) 181 const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
174 182
175 expect(response.statusCode).to.equal(204) 183 expect(response.statusCode).to.equal(204)
176 }) 184 })
177 }) 185 })
178 186
179 after(async function () { 187 after(async function () {
180 killallServers(servers) 188 this.timeout(10000)
189
190 await cleanupTests(servers)
181 191
182 await closeAllSequelize(servers) 192 await closeAllSequelize(servers)
183 }) 193 })
diff --git a/server/tests/api/index-1.ts b/server/tests/api/index-1.ts
deleted file mode 100644
index 75cdd9025..000000000
--- a/server/tests/api/index-1.ts
+++ /dev/null
@@ -1,3 +0,0 @@
1import './check-params'
2import './notifications'
3import './search'
diff --git a/server/tests/api/index-2.ts b/server/tests/api/index-2.ts
deleted file mode 100644
index ed93faa91..000000000
--- a/server/tests/api/index-2.ts
+++ /dev/null
@@ -1,2 +0,0 @@
1import './server'
2import './users'
diff --git a/server/tests/api/index-3.ts b/server/tests/api/index-3.ts
deleted file mode 100644
index 39823b82c..000000000
--- a/server/tests/api/index-3.ts
+++ /dev/null
@@ -1 +0,0 @@
1import './videos'
diff --git a/server/tests/api/index-4.ts b/server/tests/api/index-4.ts
deleted file mode 100644
index 7d8be2b3d..000000000
--- a/server/tests/api/index-4.ts
+++ /dev/null
@@ -1,2 +0,0 @@
1import './redundancy'
2import './activitypub'
diff --git a/server/tests/api/index.ts b/server/tests/api/index.ts
index bc140f860..bac77ab2e 100644
--- a/server/tests/api/index.ts
+++ b/server/tests/api/index.ts
@@ -1,5 +1,9 @@
1// Order of the tests we want to execute 1// Order of the tests we want to execute
2import './index-1' 2import './activitypub'
3import './index-2' 3import './check-params'
4import './index-3' 4import './notifications'
5import './index-4' 5import './redundancy'
6import './search'
7import './server'
8import './users'
9import './videos'
diff --git a/server/tests/api/notifications/index.ts b/server/tests/api/notifications/index.ts
index 95ac8fc51..b573f850e 100644
--- a/server/tests/api/notifications/index.ts
+++ b/server/tests/api/notifications/index.ts
@@ -1 +1 @@
export * from './user-notifications' import './user-notifications'
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index f479e1785..662b64e05 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -114,11 +114,12 @@ describe('Test users notifications', function () {
114 before(async function () { 114 before(async function () {
115 this.timeout(120000) 115 this.timeout(120000)
116 116
117 await MockSmtpServer.Instance.collectEmails(emails) 117 const port = await MockSmtpServer.Instance.collectEmails(emails)
118 118
119 const overrideConfig = { 119 const overrideConfig = {
120 smtp: { 120 smtp: {
121 hostname: 'localhost' 121 hostname: 'localhost',
122 port
122 } 123 }
123 } 124 }
124 servers = await flushAndRunMultipleServers(3, overrideConfig) 125 servers = await flushAndRunMultipleServers(3, overrideConfig)
@@ -194,7 +195,7 @@ describe('Test users notifications', function () {
194 it('Should send a new video notification if the user follows the local video publisher', async function () { 195 it('Should send a new video notification if the user follows the local video publisher', async function () {
195 this.timeout(15000) 196 this.timeout(15000)
196 197
197 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001') 198 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port)
198 await waitJobs(servers) 199 await waitJobs(servers)
199 200
200 const { name, uuid } = await uploadVideoByLocalAccount(servers) 201 const { name, uuid } = await uploadVideoByLocalAccount(servers)
@@ -204,7 +205,7 @@ describe('Test users notifications', function () {
204 it('Should send a new video notification from a remote account', async function () { 205 it('Should send a new video notification from a remote account', async function () {
205 this.timeout(50000) // Server 2 has transcoding enabled 206 this.timeout(50000) // Server 2 has transcoding enabled
206 207
207 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002') 208 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port)
208 await waitJobs(servers) 209 await waitJobs(servers)
209 210
210 const { name, uuid } = await uploadVideoByRemoteAccount(servers) 211 const { name, uuid } = await uploadVideoByRemoteAccount(servers)
@@ -578,7 +579,9 @@ describe('Test users notifications', function () {
578 const uuid = resVideo.body.video.uuid 579 const uuid = resVideo.body.video.uuid
579 580
580 await waitJobs(servers) 581 await waitJobs(servers)
581 const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'hello @user_1@localhost:9001 1') 582
583 const text1 = `hello @user_1@localhost:${servers[ 0 ].port} 1`
584 const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1)
582 const server2ThreadId = resThread.body.comment.id 585 const server2ThreadId = resThread.body.comment.id
583 586
584 await waitJobs(servers) 587 await waitJobs(servers)
@@ -588,8 +591,8 @@ describe('Test users notifications', function () {
588 const server1ThreadId = resThread2.body.data[0].id 591 const server1ThreadId = resThread2.body.data[0].id
589 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 592 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
590 593
591 const text = '@user_1@localhost:9001 hello 2 @root@localhost:9001' 594 const text2 = `@user_1@localhost:${servers[ 0 ].port} hello 2 @root@localhost:${servers[ 0 ].port}`
592 await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text) 595 await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2)
593 596
594 await waitJobs(servers) 597 await waitJobs(servers)
595 598
@@ -889,10 +892,10 @@ describe('Test users notifications', function () {
889 892
890 await waitJobs(servers) 893 await waitJobs(servers)
891 894
892 await checkNewInstanceFollower(baseParams, 'localhost:9003', 'presence') 895 await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence')
893 896
894 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } 897 const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } }
895 await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:9003', 'absence') 898 await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence')
896 }) 899 })
897 }) 900 })
898 901
@@ -933,29 +936,29 @@ describe('Test users notifications', function () {
933 it('Should notify when a local channel is following one of our channel', async function () { 936 it('Should notify when a local channel is following one of our channel', async function () {
934 this.timeout(10000) 937 this.timeout(10000)
935 938
936 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 939 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
937 await waitJobs(servers) 940 await waitJobs(servers)
938 941
939 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 942 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
940 943
941 await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 944 await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
942 }) 945 })
943 946
944 it('Should notify when a remote channel is following one of our channel', async function () { 947 it('Should notify when a remote channel is following one of our channel', async function () {
945 this.timeout(10000) 948 this.timeout(10000)
946 949
947 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 950 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
948 await waitJobs(servers) 951 await waitJobs(servers)
949 952
950 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 953 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
951 954
952 await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 955 await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
953 }) 956 })
954 957
955 it('Should notify when a local account is following one of our channel', async function () { 958 it('Should notify when a local account is following one of our channel', async function () {
956 this.timeout(10000) 959 this.timeout(10000)
957 960
958 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:9001') 961 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port)
959 962
960 await waitJobs(servers) 963 await waitJobs(servers)
961 964
@@ -965,7 +968,7 @@ describe('Test users notifications', function () {
965 it('Should notify when a remote account is following one of our channel', async function () { 968 it('Should notify when a remote account is following one of our channel', async function () {
966 this.timeout(10000) 969 this.timeout(10000)
967 970
968 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:9001') 971 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port)
969 972
970 await waitJobs(servers) 973 await waitJobs(servers)
971 974
@@ -1019,8 +1022,8 @@ describe('Test users notifications', function () {
1019 autoBlacklistTestsCustomConfig.transcoding.enabled = true 1022 autoBlacklistTestsCustomConfig.transcoding.enabled = true
1020 await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig) 1023 await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig)
1021 1024
1022 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 1025 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
1023 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 1026 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
1024 1027
1025 }) 1028 })
1026 1029
@@ -1142,8 +1145,8 @@ describe('Test users notifications', function () {
1142 after(async () => { 1145 after(async () => {
1143 await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig) 1146 await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig)
1144 1147
1145 await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 1148 await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port)
1146 await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 1149 await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port)
1147 }) 1150 })
1148 }) 1151 })
1149 1152
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index e31329c25..6f2c59076 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -100,7 +100,7 @@ async function check1WebSeed (videoUUID?: string) {
100 if (!videoUUID) videoUUID = video1Server2UUID 100 if (!videoUUID) videoUUID = video1Server2UUID
101 101
102 const webseeds = [ 102 const webseeds = [
103 'http://localhost:9002/static/webseed/' + videoUUID 103 `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}`
104 ] 104 ]
105 105
106 for (const server of servers) { 106 for (const server of servers) {
@@ -118,8 +118,8 @@ async function check2Webseeds (videoUUID?: string) {
118 if (!videoUUID) videoUUID = video1Server2UUID 118 if (!videoUUID) videoUUID = video1Server2UUID
119 119
120 const webseeds = [ 120 const webseeds = [
121 'http://localhost:9001/static/redundancy/' + videoUUID, 121 `http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`,
122 'http://localhost:9002/static/webseed/' + videoUUID 122 `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}`
123 ] 123 ]
124 124
125 for (const server of servers) { 125 for (const server of servers) {
@@ -145,7 +145,12 @@ async function check2Webseeds (videoUUID?: string) {
145 } 145 }
146 } 146 }
147 147
148 for (const directory of [ 'test1/redundancy', 'test2/videos' ]) { 148 const directories = [
149 'test' + servers[0].internalServerNumber + '/redundancy',
150 'test' + servers[1].internalServerNumber + '/videos'
151 ]
152
153 for (const directory of directories) {
149 const files = await readdir(join(root(), directory)) 154 const files = await readdir(join(root(), directory))
150 expect(files).to.have.length.at.least(4) 155 expect(files).to.have.length.at.least(4)
151 156
@@ -194,7 +199,12 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
194 await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) 199 await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist)
195 } 200 }
196 201
197 for (const directory of [ 'test1/redundancy/hls', 'test2/streaming-playlists/hls' ]) { 202 const directories = [
203 'test' + servers[0].internalServerNumber + '/redundancy/hls',
204 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls'
205 ]
206
207 for (const directory of directories) {
198 const files = await readdir(join(root(), directory, videoUUID)) 208 const files = await readdir(join(root(), directory, videoUUID))
199 expect(files).to.have.length.at.least(4) 209 expect(files).to.have.length.at.least(4)
200 210
@@ -239,8 +249,8 @@ async function enableRedundancyOnServer1 () {
239 249
240 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') 250 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt')
241 const follows: ActorFollow[] = res.body.data 251 const follows: ActorFollow[] = res.body.data
242 const server2 = follows.find(f => f.following.host === 'localhost:9002') 252 const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`)
243 const server3 = follows.find(f => f.following.host === 'localhost:9003') 253 const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`)
244 254
245 expect(server3).to.not.be.undefined 255 expect(server3).to.not.be.undefined
246 expect(server3.following.hostRedundancyAllowed).to.be.false 256 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -254,8 +264,8 @@ async function disableRedundancyOnServer1 () {
254 264
255 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') 265 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt')
256 const follows: ActorFollow[] = res.body.data 266 const follows: ActorFollow[] = res.body.data
257 const server2 = follows.find(f => f.following.host === 'localhost:9002') 267 const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`)
258 const server3 = follows.find(f => f.following.host === 'localhost:9003') 268 const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`)
259 269
260 expect(server3).to.not.be.undefined 270 expect(server3).to.not.be.undefined
261 expect(server3.following.hostRedundancyAllowed).to.be.false 271 expect(server3.following.hostRedundancyAllowed).to.be.false
@@ -475,12 +485,12 @@ describe('Test videos redundancy', function () {
475 await wait(10000) 485 await wait(10000)
476 486
477 try { 487 try {
478 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') 488 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
479 } catch { 489 } catch {
480 // Maybe a server deleted a redundancy in the scheduler 490 // Maybe a server deleted a redundancy in the scheduler
481 await wait(2000) 491 await wait(2000)
482 492
483 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') 493 await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
484 } 494 }
485 }) 495 })
486 496
@@ -491,7 +501,7 @@ describe('Test videos redundancy', function () {
491 501
492 await wait(15000) 502 await wait(15000)
493 503
494 await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') 504 await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A' + servers[0].port)
495 }) 505 })
496 506
497 after(async function () { 507 after(async function () {
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index 4d1ceb767..8a008b8c6 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -3,16 +3,17 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 addVideoChannel, cleanupTests, 6 addVideoChannel,
7 cleanupTests,
7 createUser, 8 createUser,
8 deleteVideoChannel, 9 deleteVideoChannel,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
10 flushTests, 11 getVideoChannelsList,
11 getVideoChannelsList, getVideoChannelVideos, 12 getVideoChannelVideos,
12 killallServers,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 updateMyUser, updateVideo, 15 updateMyUser,
16 updateVideo,
16 updateVideoChannel, 17 updateVideoChannel,
17 uploadVideo, 18 uploadVideo,
18 userLogin, 19 userLogin,
@@ -24,7 +25,7 @@ import { searchVideoChannel } from '../../../../shared/extra-utils/search/video-
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
27describe('Test a ActivityPub video channels search', function () { 28describe('Test ActivityPub video channels search', function () {
28 let servers: ServerInfo[] 29 let servers: ServerInfo[]
29 let userServer2Token: string 30 let userServer2Token: string
30 let videoServer2UUID: string 31 let videoServer2UUID: string
@@ -67,7 +68,7 @@ describe('Test a ActivityPub video channels search', function () {
67 68
68 it('Should not find a remote video channel', async function () { 69 it('Should not find a remote video channel', async function () {
69 { 70 {
70 const search = 'http://localhost:9002/video-channels/channel1_server3' 71 const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server3'
71 const res = await searchVideoChannel(servers[ 0 ].url, search, servers[ 0 ].accessToken) 72 const res = await searchVideoChannel(servers[ 0 ].url, search, servers[ 0 ].accessToken)
72 73
73 expect(res.body.total).to.equal(0) 74 expect(res.body.total).to.equal(0)
@@ -77,7 +78,7 @@ describe('Test a ActivityPub video channels search', function () {
77 78
78 { 79 {
79 // Without token 80 // Without token
80 const search = 'http://localhost:9002/video-channels/channel1_server2' 81 const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
81 const res = await searchVideoChannel(servers[0].url, search) 82 const res = await searchVideoChannel(servers[0].url, search)
82 83
83 expect(res.body.total).to.equal(0) 84 expect(res.body.total).to.equal(0)
@@ -88,8 +89,8 @@ describe('Test a ActivityPub video channels search', function () {
88 89
89 it('Should search a local video channel', async function () { 90 it('Should search a local video channel', async function () {
90 const searches = [ 91 const searches = [
91 'http://localhost:9001/video-channels/channel1_server1', 92 'http://localhost:' + servers[ 0 ].port + '/video-channels/channel1_server1',
92 'channel1_server1@localhost:9001' 93 'channel1_server1@localhost:' + servers[ 0 ].port
93 ] 94 ]
94 95
95 for (const search of searches) { 96 for (const search of searches) {
@@ -105,8 +106,8 @@ describe('Test a ActivityPub video channels search', function () {
105 106
106 it('Should search a remote video channel with URL or handle', async function () { 107 it('Should search a remote video channel with URL or handle', async function () {
107 const searches = [ 108 const searches = [
108 'http://localhost:9002/video-channels/channel1_server2', 109 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2',
109 'channel1_server2@localhost:9002' 110 'channel1_server2@localhost:' + servers[ 1 ].port
110 ] 111 ]
111 112
112 for (const search of searches) { 113 for (const search of searches) {
@@ -134,13 +135,13 @@ describe('Test a ActivityPub video channels search', function () {
134 135
135 await waitJobs(servers) 136 await waitJobs(servers)
136 137
137 const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:9002', 0, 5) 138 const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5)
138 expect(res.body.total).to.equal(0) 139 expect(res.body.total).to.equal(0)
139 expect(res.body.data).to.have.lengthOf(0) 140 expect(res.body.data).to.have.lengthOf(0)
140 }) 141 })
141 142
142 it('Should list video channel videos of server 2 with token', async function () { 143 it('Should list video channel videos of server 2 with token', async function () {
143 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5) 144 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5)
144 145
145 expect(res.body.total).to.equal(1) 146 expect(res.body.total).to.equal(1)
146 expect(res.body.data[0].name).to.equal('video 1 server 2') 147 expect(res.body.data[0].name).to.equal('video 1 server 2')
@@ -156,7 +157,7 @@ describe('Test a ActivityPub video channels search', function () {
156 // Expire video channel 157 // Expire video channel
157 await wait(10000) 158 await wait(10000)
158 159
159 const search = 'http://localhost:9002/video-channels/channel1_server2' 160 const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
160 const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) 161 const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
161 expect(res.body.total).to.equal(1) 162 expect(res.body.total).to.equal(1)
162 expect(res.body.data).to.have.lengthOf(1) 163 expect(res.body.data).to.have.lengthOf(1)
@@ -179,12 +180,13 @@ describe('Test a ActivityPub video channels search', function () {
179 // Expire video channel 180 // Expire video channel
180 await wait(10000) 181 await wait(10000)
181 182
182 const search = 'http://localhost:9002/video-channels/channel1_server2' 183 const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
183 await searchVideoChannel(servers[0].url, search, servers[0].accessToken) 184 await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
184 185
185 await waitJobs(servers) 186 await waitJobs(servers)
186 187
187 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5, '-createdAt') 188 const videoChannelName = 'channel1_server2@localhost:' + servers[ 1 ].port
189 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt')
188 190
189 expect(res.body.total).to.equal(2) 191 expect(res.body.total).to.equal(2)
190 expect(res.body.data[0].name).to.equal('video 2 server 2') 192 expect(res.body.data[0].name).to.equal('video 2 server 2')
@@ -200,7 +202,8 @@ describe('Test a ActivityPub video channels search', function () {
200 // Expire video 202 // Expire video
201 await wait(10000) 203 await wait(10000)
202 204
203 const res = await searchVideoChannel(servers[0].url, 'http://localhost:9002/video-channels/channel1_server2', servers[0].accessToken) 205 const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2'
206 const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken)
204 expect(res.body.total).to.equal(0) 207 expect(res.body.total).to.equal(0)
205 expect(res.body.data).to.have.lengthOf(0) 208 expect(res.body.data).to.have.lengthOf(0)
206 }) 209 })
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index e039961cb..dbfefadda 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -4,25 +4,24 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 addVideoChannel, 6 addVideoChannel,
7 cleanupTests,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 flushTests,
9 getVideosList, 9 getVideosList,
10 killallServers,
11 removeVideo, 10 removeVideo,
11 searchVideo,
12 searchVideoWithToken, 12 searchVideoWithToken,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 updateVideo, 15 updateVideo,
16 uploadVideo, 16 uploadVideo,
17 wait, 17 wait
18 searchVideo, cleanupTests
19} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { Video, VideoPrivacy } from '../../../../shared/models/videos' 20import { Video, VideoPrivacy } from '../../../../shared/models/videos'
22 21
23const expect = chai.expect 22const expect = chai.expect
24 23
25describe('Test a ActivityPub videos search', function () { 24describe('Test ActivityPub videos search', function () {
26 let servers: ServerInfo[] 25 let servers: ServerInfo[]
27 let videoServer1UUID: string 26 let videoServer1UUID: string
28 let videoServer2UUID: string 27 let videoServer2UUID: string
@@ -49,7 +48,8 @@ describe('Test a ActivityPub videos search', function () {
49 48
50 it('Should not find a remote video', async function () { 49 it('Should not find a remote video', async function () {
51 { 50 {
52 const res = await searchVideoWithToken(servers[ 0 ].url, 'http://localhost:9002/videos/watch/43', servers[ 0 ].accessToken) 51 const search = 'http://localhost:' + servers[1].port + '/videos/watch/43'
52 const res = await searchVideoWithToken(servers[ 0 ].url, search, servers[ 0 ].accessToken)
53 53
54 expect(res.body.total).to.equal(0) 54 expect(res.body.total).to.equal(0)
55 expect(res.body.data).to.be.an('array') 55 expect(res.body.data).to.be.an('array')
@@ -58,7 +58,8 @@ describe('Test a ActivityPub videos search', function () {
58 58
59 { 59 {
60 // Without token 60 // Without token
61 const res = await searchVideo(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID) 61 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
62 const res = await searchVideo(servers[0].url, search)
62 63
63 expect(res.body.total).to.equal(0) 64 expect(res.body.total).to.equal(0)
64 expect(res.body.data).to.be.an('array') 65 expect(res.body.data).to.be.an('array')
@@ -67,7 +68,8 @@ describe('Test a ActivityPub videos search', function () {
67 }) 68 })
68 69
69 it('Should search a local video', async function () { 70 it('Should search a local video', async function () {
70 const res = await searchVideo(servers[0].url, 'http://localhost:9001/videos/watch/' + videoServer1UUID) 71 const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID
72 const res = await searchVideo(servers[0].url, search)
71 73
72 expect(res.body.total).to.equal(1) 74 expect(res.body.total).to.equal(1)
73 expect(res.body.data).to.be.an('array') 75 expect(res.body.data).to.be.an('array')
@@ -76,7 +78,8 @@ describe('Test a ActivityPub videos search', function () {
76 }) 78 })
77 79
78 it('Should search a remote video', async function () { 80 it('Should search a remote video', async function () {
79 const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) 81 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
82 const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
80 83
81 expect(res.body.total).to.equal(1) 84 expect(res.body.total).to.equal(1)
82 expect(res.body.data).to.be.an('array') 85 expect(res.body.data).to.be.an('array')
@@ -114,12 +117,13 @@ describe('Test a ActivityPub videos search', function () {
114 await wait(10000) 117 await wait(10000)
115 118
116 // Will run refresh async 119 // Will run refresh async
117 await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) 120 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
121 await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
118 122
119 // Wait refresh 123 // Wait refresh
120 await wait(5000) 124 await wait(5000)
121 125
122 const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) 126 const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
123 expect(res.body.total).to.equal(1) 127 expect(res.body.total).to.equal(1)
124 expect(res.body.data).to.have.lengthOf(1) 128 expect(res.body.data).to.have.lengthOf(1)
125 129
@@ -139,12 +143,13 @@ describe('Test a ActivityPub videos search', function () {
139 await wait(10000) 143 await wait(10000)
140 144
141 // Will run refresh async 145 // Will run refresh async
142 await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) 146 const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID
147 await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
143 148
144 // Wait refresh 149 // Wait refresh
145 await wait(5000) 150 await wait(5000)
146 151
147 const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) 152 const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken)
148 expect(res.body.total).to.equal(0) 153 expect(res.body.total).to.equal(0)
149 expect(res.body.data).to.have.lengthOf(0) 154 expect(res.body.data).to.have.lengthOf(0)
150 }) 155 })
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 1a086b33a..92cc0dc71 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -4,21 +4,19 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 advancedVideosSearch, 6 advancedVideosSearch,
7 flushTests, 7 cleanupTests,
8 killallServers,
9 flushAndRunServer, 8 flushAndRunServer,
9 immutableAssign,
10 searchVideo, 10 searchVideo,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, 13 uploadVideo,
14 wait, 14 wait
15 immutableAssign,
16 cleanupTests
17} from '../../../../shared/extra-utils' 15} from '../../../../shared/extra-utils'
18 16
19const expect = chai.expect 17const expect = chai.expect
20 18
21describe('Test a videos search', function () { 19describe('Test videos search', function () {
22 let server: ServerInfo = null 20 let server: ServerInfo = null
23 let startDate: string 21 let startDate: string
24 22
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index c0d11914b..ca389b7b6 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -11,9 +11,9 @@ import {
11 getAbout, 11 getAbout,
12 getConfig, 12 getConfig,
13 getCustomConfig, 13 getCustomConfig,
14 killallServers, 14 killallServers, parallelTests,
15 registerUser, 15 registerUser,
16 reRunServer, 16 reRunServer, ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateCustomConfig 18 updateCustomConfig
19} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
@@ -21,7 +21,7 @@ import { ServerConfig } from '../../../../shared/models'
21 21
22const expect = chai.expect 22const expect = chai.expect
23 23
24function checkInitialConfig (data: CustomConfig) { 24function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
25 expect(data.instance.name).to.equal('PeerTube') 25 expect(data.instance.name).to.equal('PeerTube')
26 expect(data.instance.shortDescription).to.equal( 26 expect(data.instance.shortDescription).to.equal(
27 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' + 27 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
@@ -45,7 +45,7 @@ function checkInitialConfig (data: CustomConfig) {
45 expect(data.signup.limit).to.equal(4) 45 expect(data.signup.limit).to.equal(4)
46 expect(data.signup.requiresEmailVerification).to.be.false 46 expect(data.signup.requiresEmailVerification).to.be.false
47 47
48 expect(data.admin.email).to.equal('admin1@example.com') 48 expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
49 expect(data.contactForm.enabled).to.be.true 49 expect(data.contactForm.enabled).to.be.true
50 50
51 expect(data.user.videoQuota).to.equal(5242880) 51 expect(data.user.videoQuota).to.equal(5242880)
@@ -89,7 +89,11 @@ function checkUpdatedConfig (data: CustomConfig) {
89 expect(data.signup.limit).to.equal(5) 89 expect(data.signup.limit).to.equal(5)
90 expect(data.signup.requiresEmailVerification).to.be.false 90 expect(data.signup.requiresEmailVerification).to.be.false
91 91
92 expect(data.admin.email).to.equal('superadmin1@example.com') 92 // We override admin email in parallel tests, so skip this exception
93 if (parallelTests() === false) {
94 expect(data.admin.email).to.equal('superadmin1@example.com')
95 }
96
93 expect(data.contactForm.enabled).to.be.false 97 expect(data.contactForm.enabled).to.be.false
94 98
95 expect(data.user.videoQuota).to.equal(5242881) 99 expect(data.user.videoQuota).to.equal(5242881)
@@ -118,6 +122,7 @@ describe('Test config', function () {
118 122
119 before(async function () { 123 before(async function () {
120 this.timeout(30000) 124 this.timeout(30000)
125
121 server = await flushAndRunServer(1) 126 server = await flushAndRunServer(1)
122 await setAccessTokensToServers([ server ]) 127 await setAccessTokensToServers([ server ])
123 }) 128 })
@@ -160,7 +165,7 @@ describe('Test config', function () {
160 const res = await getCustomConfig(server.url, server.accessToken) 165 const res = await getCustomConfig(server.url, server.accessToken)
161 const data = res.body as CustomConfig 166 const data = res.body as CustomConfig
162 167
163 checkInitialConfig(data) 168 checkInitialConfig(server, data)
164 }) 169 })
165 170
166 it('Should update the customized configuration', async function () { 171 it('Should update the customized configuration', async function () {
@@ -297,7 +302,7 @@ describe('Test config', function () {
297 const res = await getCustomConfig(server.url, server.accessToken) 302 const res = await getCustomConfig(server.url, server.accessToken)
298 const data = res.body 303 const data = res.body
299 304
300 checkInitialConfig(data) 305 checkInitialConfig(server, data)
301 }) 306 })
302 307
303 after(async function () { 308 after(async function () {
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index ba51198b3..87e55060c 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -24,11 +24,12 @@ describe('Test contact form', function () {
24 before(async function () { 24 before(async function () {
25 this.timeout(30000) 25 this.timeout(30000)
26 26
27 await MockSmtpServer.Instance.collectEmails(emails) 27 const port = await MockSmtpServer.Instance.collectEmails(emails)
28 28
29 const overrideConfig = { 29 const overrideConfig = {
30 smtp: { 30 smtp: {
31 hostname: 'localhost' 31 hostname: 'localhost',
32 port
32 } 33 }
33 } 34 }
34 server = await flushAndRunServer(1, overrideConfig) 35 server = await flushAndRunServer(1, overrideConfig)
@@ -53,7 +54,7 @@ describe('Test contact form', function () {
53 54
54 expect(email['from'][0]['address']).equal('test-admin@localhost') 55 expect(email['from'][0]['address']).equal('test-admin@localhost')
55 expect(email['from'][0]['name']).equal('toto@example.com') 56 expect(email['from'][0]['name']).equal('toto@example.com')
56 expect(email['to'][0]['address']).equal('admin1@example.com') 57 expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
57 expect(email['subject']).contains('Contact form') 58 expect(email['subject']).contains('Contact form')
58 expect(email['text']).contains('my super message') 59 expect(email['text']).contains('my super message')
59 }) 60 })
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index bacdf1b1b..5929a3adb 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -7,18 +7,18 @@ import {
7 askResetPassword, 7 askResetPassword,
8 askSendVerifyEmail, 8 askSendVerifyEmail,
9 blockUser, 9 blockUser,
10 createUser, removeVideoFromBlacklist, 10 cleanupTests,
11 createUser,
12 flushAndRunServer,
13 removeVideoFromBlacklist,
11 reportVideoAbuse, 14 reportVideoAbuse,
12 resetPassword, 15 resetPassword,
13 flushAndRunServer, 16 ServerInfo,
17 setAccessTokensToServers,
14 unblockUser, 18 unblockUser,
15 uploadVideo, 19 uploadVideo,
16 userLogin, 20 userLogin,
17 verifyEmail, 21 verifyEmail
18 flushTests,
19 killallServers,
20 ServerInfo,
21 setAccessTokensToServers, cleanupTests
22} from '../../../../shared/extra-utils' 22} from '../../../../shared/extra-utils'
23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -37,15 +37,17 @@ describe('Test emails', function () {
37 username: 'user_1', 37 username: 'user_1',
38 password: 'super_password' 38 password: 'super_password'
39 } 39 }
40 let emailPort: number
40 41
41 before(async function () { 42 before(async function () {
42 this.timeout(30000) 43 this.timeout(30000)
43 44
44 await MockSmtpServer.Instance.collectEmails(emails) 45 emailPort = await MockSmtpServer.Instance.collectEmails(emails)
45 46
46 const overrideConfig = { 47 const overrideConfig = {
47 smtp: { 48 smtp: {
48 hostname: 'localhost' 49 hostname: 'localhost',
50 port: emailPort
49 } 51 }
50 } 52 }
51 server = await flushAndRunServer(1, overrideConfig) 53 server = await flushAndRunServer(1, overrideConfig)
@@ -87,7 +89,7 @@ describe('Test emails', function () {
87 89
88 const email = emails[0] 90 const email = emails[0]
89 91
90 expect(email['from'][0]['name']).equal('localhost:9001') 92 expect(email['from'][0]['name']).equal('localhost:' + server.port)
91 expect(email['from'][0]['address']).equal('test-admin@localhost') 93 expect(email['from'][0]['address']).equal('test-admin@localhost')
92 expect(email['to'][0]['address']).equal('user_1@example.com') 94 expect(email['to'][0]['address']).equal('user_1@example.com')
93 expect(email['subject']).contains('password') 95 expect(email['subject']).contains('password')
@@ -132,9 +134,9 @@ describe('Test emails', function () {
132 134
133 const email = emails[1] 135 const email = emails[1]
134 136
135 expect(email['from'][0]['name']).equal('localhost:9001') 137 expect(email['from'][0]['name']).equal('localhost:' + server.port)
136 expect(email['from'][0]['address']).equal('test-admin@localhost') 138 expect(email['from'][0]['address']).equal('test-admin@localhost')
137 expect(email['to'][0]['address']).equal('admin1@example.com') 139 expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
138 expect(email['subject']).contains('abuse') 140 expect(email['subject']).contains('abuse')
139 expect(email['text']).contains(videoUUID) 141 expect(email['text']).contains(videoUUID)
140 }) 142 })
@@ -153,7 +155,7 @@ describe('Test emails', function () {
153 155
154 const email = emails[2] 156 const email = emails[2]
155 157
156 expect(email['from'][0]['name']).equal('localhost:9001') 158 expect(email['from'][0]['name']).equal('localhost:' + server.port)
157 expect(email['from'][0]['address']).equal('test-admin@localhost') 159 expect(email['from'][0]['address']).equal('test-admin@localhost')
158 expect(email['to'][0]['address']).equal('user_1@example.com') 160 expect(email['to'][0]['address']).equal('user_1@example.com')
159 expect(email['subject']).contains(' blocked') 161 expect(email['subject']).contains(' blocked')
@@ -171,7 +173,7 @@ describe('Test emails', function () {
171 173
172 const email = emails[3] 174 const email = emails[3]
173 175
174 expect(email['from'][0]['name']).equal('localhost:9001') 176 expect(email['from'][0]['name']).equal('localhost:' + server.port)
175 expect(email['from'][0]['address']).equal('test-admin@localhost') 177 expect(email['from'][0]['address']).equal('test-admin@localhost')
176 expect(email['to'][0]['address']).equal('user_1@example.com') 178 expect(email['to'][0]['address']).equal('user_1@example.com')
177 expect(email['subject']).contains(' unblocked') 179 expect(email['subject']).contains(' unblocked')
@@ -191,7 +193,7 @@ describe('Test emails', function () {
191 193
192 const email = emails[4] 194 const email = emails[4]
193 195
194 expect(email['from'][0]['name']).equal('localhost:9001') 196 expect(email['from'][0]['name']).equal('localhost:' + server.port)
195 expect(email['from'][0]['address']).equal('test-admin@localhost') 197 expect(email['from'][0]['address']).equal('test-admin@localhost')
196 expect(email['to'][0]['address']).equal('user_1@example.com') 198 expect(email['to'][0]['address']).equal('user_1@example.com')
197 expect(email['subject']).contains(' blacklisted') 199 expect(email['subject']).contains(' blacklisted')
@@ -209,7 +211,7 @@ describe('Test emails', function () {
209 211
210 const email = emails[5] 212 const email = emails[5]
211 213
212 expect(email['from'][0]['name']).equal('localhost:9001') 214 expect(email['from'][0]['name']).equal('localhost:' + server.port)
213 expect(email['from'][0]['address']).equal('test-admin@localhost') 215 expect(email['from'][0]['address']).equal('test-admin@localhost')
214 expect(email['to'][0]['address']).equal('user_1@example.com') 216 expect(email['to'][0]['address']).equal('user_1@example.com')
215 expect(email['subject']).contains(' unblacklisted') 217 expect(email['subject']).contains(' unblacklisted')
@@ -229,7 +231,7 @@ describe('Test emails', function () {
229 231
230 const email = emails[6] 232 const email = emails[6]
231 233
232 expect(email['from'][0]['name']).equal('localhost:9001') 234 expect(email['from'][0]['name']).equal('localhost:' + server.port)
233 expect(email['from'][0]['address']).equal('test-admin@localhost') 235 expect(email['from'][0]['address']).equal('test-admin@localhost')
234 expect(email['to'][0]['address']).equal('user_1@example.com') 236 expect(email['to'][0]['address']).equal('user_1@example.com')
235 expect(email['subject']).contains('Verify') 237 expect(email['subject']).contains('Verify')
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index 4285a9e7a..ac3ff37f0 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -3,16 +3,16 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 doubleFollow, 7 doubleFollow,
8 flushAndRunMultipleServers,
7 getAccountVideos, 9 getAccountVideos,
8 getVideo, 10 getVideo,
9 getVideoChannelVideos, 11 getVideoChannelVideos,
10 getVideoWithToken, 12 getVideoWithToken,
11 flushAndRunMultipleServers,
12 killallServers,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 uploadVideo, cleanupTests 15 uploadVideo
16} from '../../../../shared/extra-utils' 16} from '../../../../shared/extra-utils'
17import { unfollow } from '../../../../shared/extra-utils/server/follows' 17import { unfollow } from '../../../../shared/extra-utils/server/follows'
18import { userLogin } from '../../../../shared/extra-utils/users/login' 18import { userLogin } from '../../../../shared/extra-utils/users/login'
@@ -66,28 +66,30 @@ describe('Test follow constraints', function () {
66 }) 66 })
67 67
68 it('Should list local account videos', async function () { 68 it('Should list local account videos', async function () {
69 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) 69 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5)
70 70
71 expect(res.body.total).to.equal(1) 71 expect(res.body.total).to.equal(1)
72 expect(res.body.data).to.have.lengthOf(1) 72 expect(res.body.data).to.have.lengthOf(1)
73 }) 73 })
74 74
75 it('Should list remote account videos', async function () { 75 it('Should list remote account videos', async function () {
76 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) 76 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5)
77 77
78 expect(res.body.total).to.equal(1) 78 expect(res.body.total).to.equal(1)
79 expect(res.body.data).to.have.lengthOf(1) 79 expect(res.body.data).to.have.lengthOf(1)
80 }) 80 })
81 81
82 it('Should list local channel videos', async function () { 82 it('Should list local channel videos', async function () {
83 const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) 83 const videoChannelName = 'root_channel@localhost:' + servers[0].port
84 const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
84 85
85 expect(res.body.total).to.equal(1) 86 expect(res.body.total).to.equal(1)
86 expect(res.body.data).to.have.lengthOf(1) 87 expect(res.body.data).to.have.lengthOf(1)
87 }) 88 })
88 89
89 it('Should list remote channel videos', async function () { 90 it('Should list remote channel videos', async function () {
90 const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) 91 const videoChannelName = 'root_channel@localhost:' + servers[1].port
92 const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
91 93
92 expect(res.body.total).to.equal(1) 94 expect(res.body.total).to.equal(1)
93 expect(res.body.data).to.have.lengthOf(1) 95 expect(res.body.data).to.have.lengthOf(1)
@@ -104,28 +106,30 @@ describe('Test follow constraints', function () {
104 }) 106 })
105 107
106 it('Should list local account videos', async function () { 108 it('Should list local account videos', async function () {
107 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) 109 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5)
108 110
109 expect(res.body.total).to.equal(1) 111 expect(res.body.total).to.equal(1)
110 expect(res.body.data).to.have.lengthOf(1) 112 expect(res.body.data).to.have.lengthOf(1)
111 }) 113 })
112 114
113 it('Should list remote account videos', async function () { 115 it('Should list remote account videos', async function () {
114 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) 116 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5)
115 117
116 expect(res.body.total).to.equal(1) 118 expect(res.body.total).to.equal(1)
117 expect(res.body.data).to.have.lengthOf(1) 119 expect(res.body.data).to.have.lengthOf(1)
118 }) 120 })
119 121
120 it('Should list local channel videos', async function () { 122 it('Should list local channel videos', async function () {
121 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) 123 const videoChannelName = 'root_channel@localhost:' + servers[0].port
124 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
122 125
123 expect(res.body.total).to.equal(1) 126 expect(res.body.total).to.equal(1)
124 expect(res.body.data).to.have.lengthOf(1) 127 expect(res.body.data).to.have.lengthOf(1)
125 }) 128 })
126 129
127 it('Should list remote channel videos', async function () { 130 it('Should list remote channel videos', async function () {
128 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) 131 const videoChannelName = 'root_channel@localhost:' + servers[1].port
132 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
129 133
130 expect(res.body.total).to.equal(1) 134 expect(res.body.total).to.equal(1)
131 expect(res.body.data).to.have.lengthOf(1) 135 expect(res.body.data).to.have.lengthOf(1)
@@ -152,28 +156,30 @@ describe('Test follow constraints', function () {
152 }) 156 })
153 157
154 it('Should list local account videos', async function () { 158 it('Should list local account videos', async function () {
155 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) 159 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5)
156 160
157 expect(res.body.total).to.equal(1) 161 expect(res.body.total).to.equal(1)
158 expect(res.body.data).to.have.lengthOf(1) 162 expect(res.body.data).to.have.lengthOf(1)
159 }) 163 })
160 164
161 it('Should not list remote account videos', async function () { 165 it('Should not list remote account videos', async function () {
162 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) 166 const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5)
163 167
164 expect(res.body.total).to.equal(0) 168 expect(res.body.total).to.equal(0)
165 expect(res.body.data).to.have.lengthOf(0) 169 expect(res.body.data).to.have.lengthOf(0)
166 }) 170 })
167 171
168 it('Should list local channel videos', async function () { 172 it('Should list local channel videos', async function () {
169 const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) 173 const videoChannelName = 'root_channel@localhost:' + servers[0].port
174 const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
170 175
171 expect(res.body.total).to.equal(1) 176 expect(res.body.total).to.equal(1)
172 expect(res.body.data).to.have.lengthOf(1) 177 expect(res.body.data).to.have.lengthOf(1)
173 }) 178 })
174 179
175 it('Should not list remote channel videos', async function () { 180 it('Should not list remote channel videos', async function () {
176 const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) 181 const videoChannelName = 'root_channel@localhost:' + servers[1].port
182 const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5)
177 183
178 expect(res.body.total).to.equal(0) 184 expect(res.body.total).to.equal(0)
179 expect(res.body.data).to.have.lengthOf(0) 185 expect(res.body.data).to.have.lengthOf(0)
@@ -190,28 +196,30 @@ describe('Test follow constraints', function () {
190 }) 196 })
191 197
192 it('Should list local account videos', async function () { 198 it('Should list local account videos', async function () {
193 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) 199 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5)
194 200
195 expect(res.body.total).to.equal(1) 201 expect(res.body.total).to.equal(1)
196 expect(res.body.data).to.have.lengthOf(1) 202 expect(res.body.data).to.have.lengthOf(1)
197 }) 203 })
198 204
199 it('Should list remote account videos', async function () { 205 it('Should list remote account videos', async function () {
200 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) 206 const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5)
201 207
202 expect(res.body.total).to.equal(1) 208 expect(res.body.total).to.equal(1)
203 expect(res.body.data).to.have.lengthOf(1) 209 expect(res.body.data).to.have.lengthOf(1)
204 }) 210 })
205 211
206 it('Should list local channel videos', async function () { 212 it('Should list local channel videos', async function () {
207 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) 213 const videoChannelName = 'root_channel@localhost:' + servers[0].port
214 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
208 215
209 expect(res.body.total).to.equal(1) 216 expect(res.body.total).to.equal(1)
210 expect(res.body.data).to.have.lengthOf(1) 217 expect(res.body.data).to.have.lengthOf(1)
211 }) 218 })
212 219
213 it('Should list remote channel videos', async function () { 220 it('Should list remote channel videos', async function () {
214 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) 221 const videoChannelName = 'root_channel@localhost:' + servers[1].port
222 const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5)
215 223
216 expect(res.body.total).to.equal(1) 224 expect(res.body.total).to.equal(1)
217 expect(res.body.data).to.have.lengthOf(1) 225 expect(res.body.data).to.have.lengthOf(1)
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
index 2a3a4d5c8..a82acdb34 100644
--- a/server/tests/api/server/follows-moderation.ts
+++ b/server/tests/api/server/follows-moderation.ts
@@ -3,9 +3,9 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 acceptFollower, cleanupTests, 6 acceptFollower,
7 cleanupTests,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 killallServers,
9 ServerInfo, 9 ServerInfo,
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 updateCustomSubConfig 11 updateCustomSubConfig
@@ -14,8 +14,8 @@ import {
14 follow, 14 follow,
15 getFollowersListPaginationAndSort, 15 getFollowersListPaginationAndSort,
16 getFollowingListPaginationAndSort, 16 getFollowingListPaginationAndSort,
17 removeFollower, 17 rejectFollower,
18 rejectFollower 18 removeFollower
19} from '../../../../shared/extra-utils/server/follows' 19} from '../../../../shared/extra-utils/server/follows'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { ActorFollow } from '../../../../shared/models/actors' 21import { ActorFollow } from '../../../../shared/models/actors'
@@ -29,8 +29,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
29 29
30 const follow = res.body.data[0] as ActorFollow 30 const follow = res.body.data[0] as ActorFollow
31 expect(follow.state).to.equal(state) 31 expect(follow.state).to.equal(state)
32 expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube') 32 expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
33 expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube') 33 expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
34 } 34 }
35 35
36 { 36 {
@@ -39,8 +39,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
39 39
40 const follow = res.body.data[0] as ActorFollow 40 const follow = res.body.data[0] as ActorFollow
41 expect(follow.state).to.equal(state) 41 expect(follow.state).to.equal(state)
42 expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube') 42 expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')
43 expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube') 43 expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')
44 } 44 }
45} 45}
46 46
@@ -151,7 +151,7 @@ describe('Test follows moderation', function () {
151 }) 151 })
152 152
153 it('Should accept a follower', async function () { 153 it('Should accept a follower', async function () {
154 await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:9001') 154 await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:' + servers[0].port)
155 await waitJobs(servers) 155 await waitJobs(servers)
156 156
157 await checkServer1And2HasFollowers(servers) 157 await checkServer1And2HasFollowers(servers)
@@ -178,7 +178,7 @@ describe('Test follows moderation', function () {
178 expect(res.body.total).to.equal(1) 178 expect(res.body.total).to.equal(1)
179 } 179 }
180 180
181 await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:9001') 181 await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:' + servers[0].port)
182 await waitJobs(servers) 182 await waitJobs(servers)
183 183
184 await checkServer1And2HasFollowers(servers) 184 await checkServer1And2HasFollowers(servers)
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 397093cdb..e8d6f5138 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -8,7 +8,6 @@ import { cleanupTests, completeVideoCheck } from '../../../../shared/extra-utils
8import { 8import {
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideosList, 10 getVideosList,
11 killallServers,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 uploadVideo 13 uploadVideo
@@ -89,8 +88,8 @@ describe('Test follows', function () {
89 res = await getFollowingListPaginationAndSort(servers[0].url, 1, 1, 'createdAt') 88 res = await getFollowingListPaginationAndSort(servers[0].url, 1, 1, 'createdAt')
90 follows = follows.concat(res.body.data) 89 follows = follows.concat(res.body.data)
91 90
92 const server2Follow = follows.find(f => f.following.host === 'localhost:9002') 91 const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port)
93 const server3Follow = follows.find(f => f.following.host === 'localhost:9003') 92 const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port)
94 93
95 expect(server2Follow).to.not.be.undefined 94 expect(server2Follow).to.not.be.undefined
96 expect(server3Follow).to.not.be.undefined 95 expect(server3Follow).to.not.be.undefined
@@ -100,12 +99,12 @@ describe('Test follows', function () {
100 99
101 it('Should search followings on server 1', async function () { 100 it('Should search followings on server 1', async function () {
102 { 101 {
103 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':9002') 102 const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':' + servers[1].port)
104 const follows = res.body.data 103 const follows = res.body.data
105 104
106 expect(res.body.total).to.equal(1) 105 expect(res.body.total).to.equal(1)
107 expect(follows.length).to.equal(1) 106 expect(follows.length).to.equal(1)
108 expect(follows[ 0 ].following.host).to.equal('localhost:9002') 107 expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[1].port)
109 } 108 }
110 109
111 { 110 {
@@ -136,18 +135,18 @@ describe('Test follows', function () {
136 expect(res.body.total).to.equal(1) 135 expect(res.body.total).to.equal(1)
137 expect(follows).to.be.an('array') 136 expect(follows).to.be.an('array')
138 expect(follows.length).to.equal(1) 137 expect(follows.length).to.equal(1)
139 expect(follows[0].follower.host).to.equal('localhost:9001') 138 expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port)
140 } 139 }
141 }) 140 })
142 141
143 it('Should search followers on server 2', async function () { 142 it('Should search followers on server 2', async function () {
144 { 143 {
145 const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001') 144 const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', servers[0].port + '')
146 const follows = res.body.data 145 const follows = res.body.data
147 146
148 expect(res.body.total).to.equal(1) 147 expect(res.body.total).to.equal(1)
149 expect(follows.length).to.equal(1) 148 expect(follows.length).to.equal(1)
150 expect(follows[ 0 ].following.host).to.equal('localhost:9003') 149 expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[2].port)
151 } 150 }
152 151
153 { 152 {
@@ -169,16 +168,16 @@ describe('Test follows', function () {
169 }) 168 })
170 169
171 it('Should have the correct follows counts', async function () { 170 it('Should have the correct follows counts', async function () {
172 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) 171 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2)
173 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 172 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
174 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) 173 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0)
175 174
176 // Server 2 and 3 does not know server 1 follow another server (there was not a refresh) 175 // Server 2 and 3 does not know server 1 follow another server (there was not a refresh)
177 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) 176 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
178 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) 177 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
179 178
180 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 1) 179 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 1)
181 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) 180 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0)
182 }) 181 })
183 182
184 it('Should unfollow server 3 on server 1', async function () { 183 it('Should unfollow server 3 on server 1', async function () {
@@ -197,7 +196,7 @@ describe('Test follows', function () {
197 expect(follows).to.be.an('array') 196 expect(follows).to.be.an('array')
198 expect(follows.length).to.equal(1) 197 expect(follows.length).to.equal(1)
199 198
200 expect(follows[0].following.host).to.equal('localhost:9002') 199 expect(follows[0].following.host).to.equal('localhost:' + servers[1].port)
201 }) 200 })
202 201
203 it('Should not have server 1 as follower on server 3 anymore', async function () { 202 it('Should not have server 1 as follower on server 3 anymore', async function () {
@@ -210,14 +209,14 @@ describe('Test follows', function () {
210 }) 209 })
211 210
212 it('Should have the correct follows counts 2', async function () { 211 it('Should have the correct follows counts 2', async function () {
213 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1) 212 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 1)
214 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 213 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
215 214
216 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) 215 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
217 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) 216 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
218 217
219 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 0) 218 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 0)
220 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 0, 0) 219 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 0, 0)
221 }) 220 })
222 221
223 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { 222 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
@@ -310,15 +309,15 @@ describe('Test follows', function () {
310 }) 309 })
311 310
312 it('Should have the correct follows counts 3', async function () { 311 it('Should have the correct follows counts 3', async function () {
313 await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) 312 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2)
314 await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) 313 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0)
315 await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) 314 await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0)
316 315
317 await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) 316 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1)
318 await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) 317 await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0)
319 318
320 await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 2) 319 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 2)
321 await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) 320 await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0)
322 }) 321 })
323 322
324 it('Should have propagated videos', async function () { 323 it('Should have propagated videos', async function () {
@@ -344,7 +343,7 @@ describe('Test follows', function () {
344 support: 'my super support text', 343 support: 'my super support text',
345 account: { 344 account: {
346 name: 'root', 345 name: 'root',
347 host: 'localhost:9003' 346 host: 'localhost:' + servers[2].port
348 }, 347 },
349 isLocal, 348 isLocal,
350 commentsEnabled: true, 349 commentsEnabled: true,
@@ -384,7 +383,7 @@ describe('Test follows', function () {
384 expect(comment.videoId).to.equal(video4.id) 383 expect(comment.videoId).to.equal(video4.id)
385 expect(comment.id).to.equal(comment.threadId) 384 expect(comment.id).to.equal(comment.threadId)
386 expect(comment.account.name).to.equal('root') 385 expect(comment.account.name).to.equal('root')
387 expect(comment.account.host).to.equal('localhost:9003') 386 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
388 expect(comment.totalReplies).to.equal(3) 387 expect(comment.totalReplies).to.equal(3)
389 expect(dateIsValid(comment.createdAt as string)).to.be.true 388 expect(dateIsValid(comment.createdAt as string)).to.be.true
390 expect(dateIsValid(comment.updatedAt as string)).to.be.true 389 expect(dateIsValid(comment.updatedAt as string)).to.be.true
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 19010dbc1..068654d8c 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -60,48 +60,50 @@ describe('Test handle downs', function () {
60 privacy: VideoPrivacy.UNLISTED 60 privacy: VideoPrivacy.UNLISTED
61 }) 61 })
62 62
63 const checkAttributes = { 63 let checkAttributes: any
64 name: 'my super name for server 1', 64 let unlistedCheckAttributes: any
65 category: 5,
66 licence: 4,
67 language: 'ja',
68 nsfw: true,
69 description: 'my super description for server 1',
70 support: 'my super support text for server 1',
71 account: {
72 name: 'root',
73 host: 'localhost:9001'
74 },
75 isLocal: false,
76 duration: 10,
77 tags: [ 'tag1p1', 'tag2p1' ],
78 privacy: VideoPrivacy.PUBLIC,
79 commentsEnabled: true,
80 downloadEnabled: true,
81 channel: {
82 name: 'root_channel',
83 displayName: 'Main root channel',
84 description: '',
85 isLocal: false
86 },
87 fixture: 'video_short1.webm',
88 files: [
89 {
90 resolution: 720,
91 size: 572456
92 }
93 ]
94 }
95
96 const unlistedCheckAttributes = immutableAssign(checkAttributes, {
97 privacy: VideoPrivacy.UNLISTED
98 })
99 65
100 before(async function () { 66 before(async function () {
101 this.timeout(30000) 67 this.timeout(30000)
102 68
103 servers = await flushAndRunMultipleServers(3) 69 servers = await flushAndRunMultipleServers(3)
104 70
71 checkAttributes = {
72 name: 'my super name for server 1',
73 category: 5,
74 licence: 4,
75 language: 'ja',
76 nsfw: true,
77 description: 'my super description for server 1',
78 support: 'my super support text for server 1',
79 account: {
80 name: 'root',
81 host: 'localhost:' + servers[0].port
82 },
83 isLocal: false,
84 duration: 10,
85 tags: [ 'tag1p1', 'tag2p1' ],
86 privacy: VideoPrivacy.PUBLIC,
87 commentsEnabled: true,
88 downloadEnabled: true,
89 channel: {
90 name: 'root_channel',
91 displayName: 'Main root channel',
92 description: '',
93 isLocal: false
94 },
95 fixture: 'video_short1.webm',
96 files: [
97 {
98 resolution: 720,
99 size: 572456
100 }
101 ]
102 }
103 unlistedCheckAttributes = immutableAssign(checkAttributes, {
104 privacy: VideoPrivacy.UNLISTED
105 })
106
105 // Get the access tokens 107 // Get the access tokens
106 await setAccessTokensToServers(servers) 108 await setAccessTokensToServers(servers)
107 }) 109 })
@@ -172,7 +174,7 @@ describe('Test handle downs', function () {
172 const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 2, 'createdAt') 174 const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 2, 'createdAt')
173 expect(res.body.data).to.be.an('array') 175 expect(res.body.data).to.be.an('array')
174 expect(res.body.data).to.have.lengthOf(1) 176 expect(res.body.data).to.have.lengthOf(1)
175 expect(res.body.data[0].follower.host).to.equal('localhost:9003') 177 expect(res.body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
176 }) 178 })
177 179
178 it('Should not have pending/processing jobs anymore', async function () { 180 it('Should not have pending/processing jobs anymore', async function () {
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts
index 3644fa0d3..68f442199 100644
--- a/server/tests/api/server/logs.ts
+++ b/server/tests/api/server/logs.ts
@@ -45,7 +45,7 @@ describe('Test logs', function () {
45 }) 45 })
46 46
47 it('Should get logs with an end date', async function () { 47 it('Should get logs with an end date', async function () {
48 this.timeout(10000) 48 this.timeout(20000)
49 49
50 await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) 50 await uploadVideo(server.url, server.accessToken, { name: 'video 3' })
51 await waitJobs([ server ]) 51 await waitJobs([ server ])
diff --git a/server/tests/api/travis-1.sh b/server/tests/api/travis-1.sh
new file mode 100644
index 000000000..db4021b25
--- /dev/null
+++ b/server/tests/api/travis-1.sh
@@ -0,0 +1,10 @@
1#!/usr/bin/env sh
2
3set -eu
4
5checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo)
6notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo)
7searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo)
8
9MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
10 $notificationsFiles $searchFiles $checkParamFiles
diff --git a/server/tests/api/travis-2.sh b/server/tests/api/travis-2.sh
new file mode 100644
index 000000000..82c1864b4
--- /dev/null
+++ b/server/tests/api/travis-2.sh
@@ -0,0 +1,9 @@
1#!/usr/bin/env sh
2
3set -eu
4
5serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)
6usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)
7
8MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel $1 --timeout 5000 --exit --require ts-node/register --bail \
9 $serverFiles $usersFiles
diff --git a/server/tests/api/travis-3.sh b/server/tests/api/travis-3.sh
new file mode 100644
index 000000000..82457222c
--- /dev/null
+++ b/server/tests/api/travis-3.sh
@@ -0,0 +1,8 @@
1#!/usr/bin/env sh
2
3set -eu
4
5videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo)
6
7MOCHA_PARALLEL=true mocha --timeout 5000 --exit --require ts-node/register --bail \
8 $videosFiles
diff --git a/server/tests/api/travis-4.sh b/server/tests/api/travis-4.sh
new file mode 100644
index 000000000..875986182
--- /dev/null
+++ b/server/tests/api/travis-4.sh
@@ -0,0 +1,9 @@
1#!/usr/bin/env sh
2
3set -eu
4
5redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo)
6activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo)
7
8MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel $1 --timeout 5000 --exit --require ts-node/register --bail \
9 $redundancyFiles $activitypubFiles
diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts
index fbc57e0ef..c25e85ada 100644
--- a/server/tests/api/users/blocklist.ts
+++ b/server/tests/api/users/blocklist.ts
@@ -144,7 +144,7 @@ describe('Test blocklist', function () {
144 }) 144 })
145 145
146 it('Should block a remote account', async function () { 146 it('Should block a remote account', async function () {
147 await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') 147 await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
148 }) 148 })
149 149
150 it('Should hide its videos', async function () { 150 it('Should hide its videos', async function () {
@@ -209,7 +209,7 @@ describe('Test blocklist', function () {
209 expect(block.byAccount.name).to.equal('root') 209 expect(block.byAccount.name).to.equal('root')
210 expect(block.blockedAccount.displayName).to.equal('user2') 210 expect(block.blockedAccount.displayName).to.equal('user2')
211 expect(block.blockedAccount.name).to.equal('user2') 211 expect(block.blockedAccount.name).to.equal('user2')
212 expect(block.blockedAccount.host).to.equal('localhost:9002') 212 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
213 } 213 }
214 214
215 { 215 {
@@ -223,12 +223,12 @@ describe('Test blocklist', function () {
223 expect(block.byAccount.name).to.equal('root') 223 expect(block.byAccount.name).to.equal('root')
224 expect(block.blockedAccount.displayName).to.equal('user1') 224 expect(block.blockedAccount.displayName).to.equal('user1')
225 expect(block.blockedAccount.name).to.equal('user1') 225 expect(block.blockedAccount.name).to.equal('user1')
226 expect(block.blockedAccount.host).to.equal('localhost:9001') 226 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
227 } 227 }
228 }) 228 })
229 229
230 it('Should unblock the remote account', async function () { 230 it('Should unblock the remote account', async function () {
231 await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') 231 await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
232 }) 232 })
233 233
234 it('Should display its videos', async function () { 234 it('Should display its videos', async function () {
@@ -260,7 +260,7 @@ describe('Test blocklist', function () {
260 }) 260 })
261 261
262 it('Should block a remote server', async function () { 262 it('Should block a remote server', async function () {
263 await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') 263 await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
264 }) 264 })
265 265
266 it('Should hide its videos', async function () { 266 it('Should hide its videos', async function () {
@@ -291,11 +291,11 @@ describe('Test blocklist', function () {
291 const block = blocks[ 0 ] 291 const block = blocks[ 0 ]
292 expect(block.byAccount.displayName).to.equal('root') 292 expect(block.byAccount.displayName).to.equal('root')
293 expect(block.byAccount.name).to.equal('root') 293 expect(block.byAccount.name).to.equal('root')
294 expect(block.blockedServer.host).to.equal('localhost:9002') 294 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
295 }) 295 })
296 296
297 it('Should unblock the remote server', async function () { 297 it('Should unblock the remote server', async function () {
298 await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') 298 await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
299 }) 299 })
300 300
301 it('Should display its videos', function () { 301 it('Should display its videos', function () {
@@ -324,7 +324,7 @@ describe('Test blocklist', function () {
324 }) 324 })
325 325
326 it('Should block a remote account', async function () { 326 it('Should block a remote account', async function () {
327 await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') 327 await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
328 }) 328 })
329 329
330 it('Should hide its videos', async function () { 330 it('Should hide its videos', async function () {
@@ -387,7 +387,7 @@ describe('Test blocklist', function () {
387 expect(block.byAccount.name).to.equal('peertube') 387 expect(block.byAccount.name).to.equal('peertube')
388 expect(block.blockedAccount.displayName).to.equal('user2') 388 expect(block.blockedAccount.displayName).to.equal('user2')
389 expect(block.blockedAccount.name).to.equal('user2') 389 expect(block.blockedAccount.name).to.equal('user2')
390 expect(block.blockedAccount.host).to.equal('localhost:9002') 390 expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
391 } 391 }
392 392
393 { 393 {
@@ -401,12 +401,12 @@ describe('Test blocklist', function () {
401 expect(block.byAccount.name).to.equal('peertube') 401 expect(block.byAccount.name).to.equal('peertube')
402 expect(block.blockedAccount.displayName).to.equal('user1') 402 expect(block.blockedAccount.displayName).to.equal('user1')
403 expect(block.blockedAccount.name).to.equal('user1') 403 expect(block.blockedAccount.name).to.equal('user1')
404 expect(block.blockedAccount.host).to.equal('localhost:9001') 404 expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
405 } 405 }
406 }) 406 })
407 407
408 it('Should unblock the remote account', async function () { 408 it('Should unblock the remote account', async function () {
409 await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') 409 await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
410 }) 410 })
411 411
412 it('Should display its videos', async function () { 412 it('Should display its videos', async function () {
@@ -446,7 +446,7 @@ describe('Test blocklist', function () {
446 }) 446 })
447 447
448 it('Should block a remote server', async function () { 448 it('Should block a remote server', async function () {
449 await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') 449 await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
450 }) 450 })
451 451
452 it('Should hide its videos', async function () { 452 it('Should hide its videos', async function () {
@@ -478,11 +478,11 @@ describe('Test blocklist', function () {
478 const block = blocks[ 0 ] 478 const block = blocks[ 0 ]
479 expect(block.byAccount.displayName).to.equal('peertube') 479 expect(block.byAccount.displayName).to.equal('peertube')
480 expect(block.byAccount.name).to.equal('peertube') 480 expect(block.byAccount.name).to.equal('peertube')
481 expect(block.blockedServer.host).to.equal('localhost:9002') 481 expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
482 }) 482 })
483 483
484 it('Should unblock the remote server', async function () { 484 it('Should unblock the remote server', async function () {
485 await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') 485 await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
486 }) 486 })
487 487
488 it('Should list all videos', async function () { 488 it('Should list all videos', async function () {
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 48811e647..c8a89d6be 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -71,8 +71,8 @@ describe('Test users subscriptions', function () {
71 it('User of server 1 should follow user of server 3 and root of server 1', async function () { 71 it('User of server 1 should follow user of server 3 and root of server 1', async function () {
72 this.timeout(60000) 72 this.timeout(60000)
73 73
74 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') 74 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
75 await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') 75 await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
76 76
77 await waitJobs(servers) 77 await waitJobs(servers)
78 78
@@ -116,22 +116,22 @@ describe('Test users subscriptions', function () {
116 116
117 it('Should get subscription', async function () { 117 it('Should get subscription', async function () {
118 { 118 {
119 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003') 119 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:' + servers[2].port)
120 const videoChannel: VideoChannel = res.body 120 const videoChannel: VideoChannel = res.body
121 121
122 expect(videoChannel.name).to.equal('user3_channel') 122 expect(videoChannel.name).to.equal('user3_channel')
123 expect(videoChannel.host).to.equal('localhost:9003') 123 expect(videoChannel.host).to.equal('localhost:' + servers[2].port)
124 expect(videoChannel.displayName).to.equal('Main user3 channel') 124 expect(videoChannel.displayName).to.equal('Main user3 channel')
125 expect(videoChannel.followingCount).to.equal(0) 125 expect(videoChannel.followingCount).to.equal(0)
126 expect(videoChannel.followersCount).to.equal(1) 126 expect(videoChannel.followersCount).to.equal(1)
127 } 127 }
128 128
129 { 129 {
130 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001') 130 const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:' + servers[0].port)
131 const videoChannel: VideoChannel = res.body 131 const videoChannel: VideoChannel = res.body
132 132
133 expect(videoChannel.name).to.equal('root_channel') 133 expect(videoChannel.name).to.equal('root_channel')
134 expect(videoChannel.host).to.equal('localhost:9001') 134 expect(videoChannel.host).to.equal('localhost:' + servers[0].port)
135 expect(videoChannel.displayName).to.equal('Main root channel') 135 expect(videoChannel.displayName).to.equal('Main root channel')
136 expect(videoChannel.followingCount).to.equal(0) 136 expect(videoChannel.followingCount).to.equal(0)
137 expect(videoChannel.followersCount).to.equal(1) 137 expect(videoChannel.followersCount).to.equal(1)
@@ -140,19 +140,19 @@ describe('Test users subscriptions', function () {
140 140
141 it('Should return the existing subscriptions', async function () { 141 it('Should return the existing subscriptions', async function () {
142 const uris = [ 142 const uris = [
143 'user3_channel@localhost:9003', 143 'user3_channel@localhost:' + servers[2].port,
144 'root2_channel@localhost:9001', 144 'root2_channel@localhost:' + servers[0].port,
145 'root_channel@localhost:9001', 145 'root_channel@localhost:' + servers[0].port,
146 'user3_channel@localhost:9001' 146 'user3_channel@localhost:' + servers[0].port
147 ] 147 ]
148 148
149 const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris) 149 const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)
150 const body = res.body 150 const body = res.body
151 151
152 expect(body['user3_channel@localhost:9003']).to.be.true 152 expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true
153 expect(body['root2_channel@localhost:9001']).to.be.false 153 expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false
154 expect(body['root_channel@localhost:9001']).to.be.true 154 expect(body['root_channel@localhost:' + servers[0].port]).to.be.true
155 expect(body['user3_channel@localhost:9001']).to.be.false 155 expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false
156 }) 156 })
157 157
158 it('Should list subscription videos', async function () { 158 it('Should list subscription videos', async function () {
@@ -291,7 +291,7 @@ describe('Test users subscriptions', function () {
291 it('Should remove user of server 3 subscription', async function () { 291 it('Should remove user of server 3 subscription', async function () {
292 this.timeout(30000) 292 this.timeout(30000)
293 293
294 await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') 294 await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
295 295
296 await waitJobs(servers) 296 await waitJobs(servers)
297 }) 297 })
@@ -312,7 +312,7 @@ describe('Test users subscriptions', function () {
312 it('Should remove the root subscription and not display the videos anymore', async function () { 312 it('Should remove the root subscription and not display the videos anymore', async function () {
313 this.timeout(30000) 313 this.timeout(30000)
314 314
315 await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001') 315 await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)
316 316
317 await waitJobs(servers) 317 await waitJobs(servers)
318 318
@@ -340,7 +340,7 @@ describe('Test users subscriptions', function () {
340 it('Should follow user of server 3 again', async function () { 340 it('Should follow user of server 3 again', async function () {
341 this.timeout(60000) 341 this.timeout(60000)
342 342
343 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003') 343 await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)
344 344
345 await waitJobs(servers) 345 await waitJobs(servers)
346 346
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 9a971adb3..988fdad3f 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -151,13 +151,13 @@ describe('Test users with multiple servers', function () {
151 for (const server of servers) { 151 for (const server of servers) {
152 const resAccounts = await getAccountsList(server.url, '-createdAt') 152 const resAccounts = await getAccountsList(server.url, '-createdAt')
153 153
154 const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account 154 const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Account
155 expect(rootServer1List).not.to.be.undefined 155 expect(rootServer1List).not.to.be.undefined
156 156
157 const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host) 157 const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
158 const rootServer1Get = resAccount.body as Account 158 const rootServer1Get = resAccount.body as Account
159 expect(rootServer1Get.name).to.equal('root') 159 expect(rootServer1Get.name).to.equal('root')
160 expect(rootServer1Get.host).to.equal('localhost:9001') 160 expect(rootServer1Get.host).to.equal('localhost:' + servers[0].port)
161 expect(rootServer1Get.displayName).to.equal('my super display name') 161 expect(rootServer1Get.displayName).to.equal('my super display name')
162 expect(rootServer1Get.description).to.equal('my super description updated') 162 expect(rootServer1Get.description).to.equal('my super description updated')
163 163
@@ -188,12 +188,12 @@ describe('Test users with multiple servers', function () {
188 for (const server of servers) { 188 for (const server of servers) {
189 const resAccounts = await getAccountsList(server.url, '-createdAt') 189 const resAccounts = await getAccountsList(server.url, '-createdAt')
190 190
191 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account 191 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
192 expect(accountDeleted).not.to.be.undefined 192 expect(accountDeleted).not.to.be.undefined
193 193
194 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 194 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
195 const videoChannelDeleted = resVideoChannels.body.data.find(a => { 195 const videoChannelDeleted = resVideoChannels.body.data.find(a => {
196 return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001' 196 return a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port
197 }) as VideoChannel 197 }) as VideoChannel
198 expect(videoChannelDeleted).not.to.be.undefined 198 expect(videoChannelDeleted).not.to.be.undefined
199 } 199 }
@@ -205,12 +205,12 @@ describe('Test users with multiple servers', function () {
205 for (const server of servers) { 205 for (const server of servers) {
206 const resAccounts = await getAccountsList(server.url, '-createdAt') 206 const resAccounts = await getAccountsList(server.url, '-createdAt')
207 207
208 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account 208 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account
209 expect(accountDeleted).to.be.undefined 209 expect(accountDeleted).to.be.undefined
210 210
211 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 211 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
212 const videoChannelDeleted = resVideoChannels.body.data.find(a => { 212 const videoChannelDeleted = resVideoChannels.body.data.find(a => {
213 return a.name === 'Main user1 channel' && a.host === 'localhost:9001' 213 return a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port
214 }) as VideoChannel 214 }) as VideoChannel
215 expect(videoChannelDeleted).to.be.undefined 215 expect(videoChannelDeleted).to.be.undefined
216 } 216 }
@@ -218,14 +218,14 @@ describe('Test users with multiple servers', function () {
218 218
219 it('Should not have actor files', async () => { 219 it('Should not have actor files', async () => {
220 for (const server of servers) { 220 for (const server of servers) {
221 await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber) 221 await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber)
222 await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber) 222 await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)
223 } 223 }
224 }) 224 })
225 225
226 it('Should not have video files', async () => { 226 it('Should not have video files', async () => {
227 for (const server of servers) { 227 for (const server of servers) {
228 await checkVideoFilesWereRemoved(videoUUID, server.serverNumber) 228 await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)
229 } 229 }
230 }) 230 })
231 231
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index 514acf2e7..3b37a26cf 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -30,11 +30,12 @@ describe('Test users account verification', function () {
30 before(async function () { 30 before(async function () {
31 this.timeout(30000) 31 this.timeout(30000)
32 32
33 await MockSmtpServer.Instance.collectEmails(emails) 33 const port = await MockSmtpServer.Instance.collectEmails(emails)
34 34
35 const overrideConfig = { 35 const overrideConfig = {
36 smtp: { 36 smtp: {
37 hostname: 'localhost' 37 hostname: 'localhost',
38 port
38 } 39 }
39 } 40 }
40 server = await flushAndRunServer(1, overrideConfig) 41 server = await flushAndRunServer(1, overrideConfig)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index c8e32f3f5..c1a24b838 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -316,7 +316,7 @@ describe('Test users', function () {
316 316
317 const rootUser = users[ 1 ] 317 const rootUser = users[ 1 ]
318 expect(rootUser.username).to.equal('root') 318 expect(rootUser.username).to.equal('root')
319 expect(rootUser.email).to.equal('admin1@example.com') 319 expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
320 expect(user.nsfwPolicy).to.equal('display') 320 expect(user.nsfwPolicy).to.equal('display')
321 321
322 userId = user.id 322 userId = user.id
@@ -334,7 +334,7 @@ describe('Test users', function () {
334 334
335 const user = users[ 0 ] 335 const user = users[ 0 ]
336 expect(user.username).to.equal('root') 336 expect(user.username).to.equal('root')
337 expect(user.email).to.equal('admin1@example.com') 337 expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')
338 expect(user.roleLabel).to.equal('Administrator') 338 expect(user.roleLabel).to.equal('Administrator')
339 expect(user.nsfwPolicy).to.equal('display') 339 expect(user.nsfwPolicy).to.equal('display')
340 }) 340 })
@@ -379,7 +379,7 @@ describe('Test users', function () {
379 expect(users.length).to.equal(2) 379 expect(users.length).to.equal(2)
380 380
381 expect(users[ 0 ].username).to.equal('root') 381 expect(users[ 0 ].username).to.equal('root')
382 expect(users[ 0 ].email).to.equal('admin1@example.com') 382 expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com')
383 expect(users[ 0 ].nsfwPolicy).to.equal('display') 383 expect(users[ 0 ].nsfwPolicy).to.equal('display')
384 384
385 expect(users[ 1 ].username).to.equal('user_1') 385 expect(users[ 1 ].username).to.equal('user_1')
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 68c1e9a8d..09b461200 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -9,18 +9,17 @@ import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/
9import { 9import {
10 addVideoChannel, 10 addVideoChannel,
11 checkTmpIsEmpty, 11 checkTmpIsEmpty,
12 checkVideoFilesWereRemoved, cleanupTests, 12 checkVideoFilesWereRemoved,
13 cleanupTests,
13 completeVideoCheck, 14 completeVideoCheck,
14 createUser, 15 createUser,
15 dateIsValid, 16 dateIsValid,
16 doubleFollow, 17 doubleFollow,
17 flushAndRunMultipleServers, 18 flushAndRunMultipleServers,
18 flushTests,
19 getLocalVideos, 19 getLocalVideos,
20 getVideo, 20 getVideo,
21 getVideoChannelsList, 21 getVideoChannelsList,
22 getVideosList, 22 getVideosList,
23 killallServers,
24 rateVideo, 23 rateVideo,
25 removeVideo, 24 removeVideo,
26 ServerInfo, 25 ServerInfo,
@@ -110,7 +109,7 @@ describe('Test multiple servers', function () {
110 // All servers should have this video 109 // All servers should have this video
111 let publishedAt: string = null 110 let publishedAt: string = null
112 for (const server of servers) { 111 for (const server of servers) {
113 const isLocal = server.url === 'http://localhost:9001' 112 const isLocal = server.port === servers[0].port
114 const checkAttributes = { 113 const checkAttributes = {
115 name: 'my super name for server 1', 114 name: 'my super name for server 1',
116 category: 5, 115 category: 5,
@@ -122,7 +121,7 @@ describe('Test multiple servers', function () {
122 originallyPublishedAt: '2019-02-10T13:38:14.449Z', 121 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
123 account: { 122 account: {
124 name: 'root', 123 name: 'root',
125 host: 'localhost:9001' 124 host: 'localhost:' + servers[0].port
126 }, 125 },
127 isLocal, 126 isLocal,
128 publishedAt, 127 publishedAt,
@@ -187,7 +186,7 @@ describe('Test multiple servers', function () {
187 186
188 // All servers should have this video 187 // All servers should have this video
189 for (const server of servers) { 188 for (const server of servers) {
190 const isLocal = server.url === 'http://localhost:9002' 189 const isLocal = server.url === 'http://localhost:' + servers[1].port
191 const checkAttributes = { 190 const checkAttributes = {
192 name: 'my super name for server 2', 191 name: 'my super name for server 2',
193 category: 4, 192 category: 4,
@@ -198,7 +197,7 @@ describe('Test multiple servers', function () {
198 support: 'my super support text for server 2', 197 support: 'my super support text for server 2',
199 account: { 198 account: {
200 name: 'user1', 199 name: 'user1',
201 host: 'localhost:9002' 200 host: 'localhost:' + servers[1].port
202 }, 201 },
203 isLocal, 202 isLocal,
204 commentsEnabled: true, 203 commentsEnabled: true,
@@ -278,7 +277,7 @@ describe('Test multiple servers', function () {
278 277
279 // All servers should have this video 278 // All servers should have this video
280 for (const server of servers) { 279 for (const server of servers) {
281 const isLocal = server.url === 'http://localhost:9003' 280 const isLocal = server.url === 'http://localhost:' + servers[2].port
282 const res = await getVideosList(server.url) 281 const res = await getVideosList(server.url)
283 282
284 const videos = res.body.data 283 const videos = res.body.data
@@ -306,7 +305,7 @@ describe('Test multiple servers', function () {
306 support: 'my super support text for server 3', 305 support: 'my super support text for server 3',
307 account: { 306 account: {
308 name: 'root', 307 name: 'root',
309 host: 'localhost:9003' 308 host: 'localhost:' + servers[2].port
310 }, 309 },
311 isLocal, 310 isLocal,
312 duration: 5, 311 duration: 5,
@@ -340,7 +339,7 @@ describe('Test multiple servers', function () {
340 support: 'my super support text for server 3-2', 339 support: 'my super support text for server 3-2',
341 account: { 340 account: {
342 name: 'root', 341 name: 'root',
343 host: 'localhost:9003' 342 host: 'localhost:' + servers[2].port
344 }, 343 },
345 commentsEnabled: true, 344 commentsEnabled: true,
346 downloadEnabled: true, 345 downloadEnabled: true,
@@ -646,7 +645,7 @@ describe('Test multiple servers', function () {
646 const videoUpdated = videos.find(video => video.name === 'my super video updated') 645 const videoUpdated = videos.find(video => video.name === 'my super video updated')
647 expect(!!videoUpdated).to.be.true 646 expect(!!videoUpdated).to.be.true
648 647
649 const isLocal = server.url === 'http://localhost:9003' 648 const isLocal = server.url === 'http://localhost:' + servers[2].port
650 const checkAttributes = { 649 const checkAttributes = {
651 name: 'my super video updated', 650 name: 'my super video updated',
652 category: 10, 651 category: 10,
@@ -658,7 +657,7 @@ describe('Test multiple servers', function () {
658 originallyPublishedAt: '2019-02-11T13:38:14.449Z', 657 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
659 account: { 658 account: {
660 name: 'root', 659 name: 'root',
661 host: 'localhost:9003' 660 host: 'localhost:' + servers[2].port
662 }, 661 },
663 isLocal, 662 isLocal,
664 duration: 5, 663 duration: 5,
@@ -813,7 +812,7 @@ describe('Test multiple servers', function () {
813 expect(comment).to.not.be.undefined 812 expect(comment).to.not.be.undefined
814 expect(comment.inReplyToCommentId).to.be.null 813 expect(comment.inReplyToCommentId).to.be.null
815 expect(comment.account.name).to.equal('root') 814 expect(comment.account.name).to.equal('root')
816 expect(comment.account.host).to.equal('localhost:9001') 815 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
817 expect(comment.totalReplies).to.equal(3) 816 expect(comment.totalReplies).to.equal(3)
818 expect(dateIsValid(comment.createdAt as string)).to.be.true 817 expect(dateIsValid(comment.createdAt as string)).to.be.true
819 expect(dateIsValid(comment.updatedAt as string)).to.be.true 818 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -824,7 +823,7 @@ describe('Test multiple servers', function () {
824 expect(comment).to.not.be.undefined 823 expect(comment).to.not.be.undefined
825 expect(comment.inReplyToCommentId).to.be.null 824 expect(comment.inReplyToCommentId).to.be.null
826 expect(comment.account.name).to.equal('root') 825 expect(comment.account.name).to.equal('root')
827 expect(comment.account.host).to.equal('localhost:9003') 826 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
828 expect(comment.totalReplies).to.equal(0) 827 expect(comment.totalReplies).to.equal(0)
829 expect(dateIsValid(comment.createdAt as string)).to.be.true 828 expect(dateIsValid(comment.createdAt as string)).to.be.true
830 expect(dateIsValid(comment.updatedAt as string)).to.be.true 829 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -842,25 +841,25 @@ describe('Test multiple servers', function () {
842 const tree: VideoCommentThreadTree = res2.body 841 const tree: VideoCommentThreadTree = res2.body
843 expect(tree.comment.text).equal('my super first comment') 842 expect(tree.comment.text).equal('my super first comment')
844 expect(tree.comment.account.name).equal('root') 843 expect(tree.comment.account.name).equal('root')
845 expect(tree.comment.account.host).equal('localhost:9001') 844 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
846 expect(tree.children).to.have.lengthOf(2) 845 expect(tree.children).to.have.lengthOf(2)
847 846
848 const firstChild = tree.children[0] 847 const firstChild = tree.children[0]
849 expect(firstChild.comment.text).to.equal('my super answer to thread 1') 848 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
850 expect(firstChild.comment.account.name).equal('root') 849 expect(firstChild.comment.account.name).equal('root')
851 expect(firstChild.comment.account.host).equal('localhost:9002') 850 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
852 expect(firstChild.children).to.have.lengthOf(1) 851 expect(firstChild.children).to.have.lengthOf(1)
853 852
854 childOfFirstChild = firstChild.children[0] 853 childOfFirstChild = firstChild.children[0]
855 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') 854 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
856 expect(childOfFirstChild.comment.account.name).equal('root') 855 expect(childOfFirstChild.comment.account.name).equal('root')
857 expect(childOfFirstChild.comment.account.host).equal('localhost:9003') 856 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
858 expect(childOfFirstChild.children).to.have.lengthOf(0) 857 expect(childOfFirstChild.children).to.have.lengthOf(0)
859 858
860 const secondChild = tree.children[1] 859 const secondChild = tree.children[1]
861 expect(secondChild.comment.text).to.equal('my second answer to thread 1') 860 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
862 expect(secondChild.comment.account.name).equal('root') 861 expect(secondChild.comment.account.name).equal('root')
863 expect(secondChild.comment.account.host).equal('localhost:9003') 862 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
864 expect(secondChild.children).to.have.lengthOf(0) 863 expect(secondChild.children).to.have.lengthOf(0)
865 } 864 }
866 }) 865 })
@@ -915,7 +914,7 @@ describe('Test multiple servers', function () {
915 expect(comment).to.not.be.undefined 914 expect(comment).to.not.be.undefined
916 expect(comment.inReplyToCommentId).to.be.null 915 expect(comment.inReplyToCommentId).to.be.null
917 expect(comment.account.name).to.equal('root') 916 expect(comment.account.name).to.equal('root')
918 expect(comment.account.host).to.equal('localhost:9003') 917 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
919 expect(comment.totalReplies).to.equal(0) 918 expect(comment.totalReplies).to.equal(0)
920 expect(dateIsValid(comment.createdAt as string)).to.be.true 919 expect(dateIsValid(comment.createdAt as string)).to.be.true
921 expect(dateIsValid(comment.updatedAt as string)).to.be.true 920 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -971,7 +970,7 @@ describe('Test multiple servers', function () {
971 const res = await getVideosList(server.url) 970 const res = await getVideosList(server.url)
972 const video = res.body.data.find(v => v.name === 'minimum parameters') 971 const video = res.body.data.find(v => v.name === 'minimum parameters')
973 972
974 const isLocal = server.url === 'http://localhost:9002' 973 const isLocal = server.url === 'http://localhost:' + servers[1].port
975 const checkAttributes = { 974 const checkAttributes = {
976 name: 'minimum parameters', 975 name: 'minimum parameters',
977 category: null, 976 category: null,
@@ -982,7 +981,7 @@ describe('Test multiple servers', function () {
982 support: null, 981 support: null,
983 account: { 982 account: {
984 name: 'root', 983 name: 'root',
985 host: 'localhost:9002' 984 host: 'localhost:' + servers[1].port
986 }, 985 },
987 isLocal, 986 isLocal,
988 duration: 5, 987 duration: 5,
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index e9ad947b2..38e232e5f 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -27,13 +27,13 @@ describe('Test services', function () {
27 }) 27 })
28 28
29 it('Should have a valid oEmbed response', async function () { 29 it('Should have a valid oEmbed response', async function () {
30 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 30 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
31 31
32 const res = await getOEmbed(server.url, oembedUrl) 32 const res = await getOEmbed(server.url, oembedUrl)
33 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + 33 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
34 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + 34 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
35 'frameborder="0" allowfullscreen></iframe>' 35 'frameborder="0" allowfullscreen></iframe>'
36 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' 36 const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg'
37 37
38 expect(res.body.html).to.equal(expectedHtml) 38 expect(res.body.html).to.equal(expectedHtml)
39 expect(res.body.title).to.equal(server.video.name) 39 expect(res.body.title).to.equal(server.video.name)
@@ -46,14 +46,14 @@ describe('Test services', function () {
46 }) 46 })
47 47
48 it('Should have a valid oEmbed response with small max height query', async function () { 48 it('Should have a valid oEmbed response with small max height query', async function () {
49 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 49 const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid
50 const format = 'json' 50 const format = 'json'
51 const maxHeight = 50 51 const maxHeight = 50
52 const maxWidth = 50 52 const maxWidth = 50
53 53
54 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) 54 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
55 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + 55 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
56 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + 56 `src="http://localhost:${server.port}/videos/embed/${server.video.uuid}" ` +
57 'frameborder="0" allowfullscreen></iframe>' 57 'frameborder="0" allowfullscreen></iframe>'
58 58
59 expect(res.body.html).to.equal(expectedHtml) 59 expect(res.body.html).to.equal(expectedHtml)
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 1f366b642..d8f394ac7 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -37,7 +37,7 @@ describe('Test a single server', function () {
37 let videoUUID = '' 37 let videoUUID = ''
38 let videosListBase: any[] = null 38 let videosListBase: any[] = null
39 39
40 const getCheckAttributes = { 40 const getCheckAttributes = () => ({
41 name: 'my super name', 41 name: 'my super name',
42 category: 2, 42 category: 2,
43 licence: 6, 43 licence: 6,
@@ -47,7 +47,7 @@ describe('Test a single server', function () {
47 support: 'my super support text', 47 support: 'my super support text',
48 account: { 48 account: {
49 name: 'root', 49 name: 'root',
50 host: 'localhost:9001' 50 host: 'localhost:' + server.port
51 }, 51 },
52 isLocal: true, 52 isLocal: true,
53 duration: 5, 53 duration: 5,
@@ -68,9 +68,9 @@ describe('Test a single server', function () {
68 size: 218910 68 size: 218910
69 } 69 }
70 ] 70 ]
71 } 71 })
72 72
73 const updateCheckAttributes = { 73 const updateCheckAttributes = () => ({
74 name: 'my super video updated', 74 name: 'my super video updated',
75 category: 4, 75 category: 4,
76 licence: 2, 76 licence: 2,
@@ -80,7 +80,7 @@ describe('Test a single server', function () {
80 support: 'my super support text updated', 80 support: 'my super support text updated',
81 account: { 81 account: {
82 name: 'root', 82 name: 'root',
83 host: 'localhost:9001' 83 host: 'localhost:' + server.port
84 }, 84 },
85 isLocal: true, 85 isLocal: true,
86 tags: [ 'tagup1', 'tagup2' ], 86 tags: [ 'tagup1', 'tagup2' ],
@@ -101,7 +101,7 @@ describe('Test a single server', function () {
101 size: 292677 101 size: 292677
102 } 102 }
103 ] 103 ]
104 } 104 })
105 105
106 before(async function () { 106 before(async function () {
107 this.timeout(30000) 107 this.timeout(30000)
@@ -182,7 +182,7 @@ describe('Test a single server', function () {
182 expect(res.body.data.length).to.equal(1) 182 expect(res.body.data.length).to.equal(1)
183 183
184 const video = res.body.data[0] 184 const video = res.body.data[0]
185 await completeVideoCheck(server.url, video, getCheckAttributes) 185 await completeVideoCheck(server.url, video, getCheckAttributes())
186 }) 186 })
187 187
188 it('Should get the video by UUID', async function () { 188 it('Should get the video by UUID', async function () {
@@ -191,7 +191,7 @@ describe('Test a single server', function () {
191 const res = await getVideo(server.url, videoUUID) 191 const res = await getVideo(server.url, videoUUID)
192 192
193 const video = res.body 193 const video = res.body
194 await completeVideoCheck(server.url, video, getCheckAttributes) 194 await completeVideoCheck(server.url, video, getCheckAttributes())
195 }) 195 })
196 196
197 it('Should have the views updated', async function () { 197 it('Should have the views updated', async function () {
@@ -376,7 +376,7 @@ describe('Test a single server', function () {
376 const res = await getVideo(server.url, videoId) 376 const res = await getVideo(server.url, videoId)
377 const video = res.body 377 const video = res.body
378 378
379 await completeVideoCheck(server.url, video, updateCheckAttributes) 379 await completeVideoCheck(server.url, video, updateCheckAttributes())
380 }) 380 })
381 381
382 it('Should update only the tags of a video', async function () { 382 it('Should update only the tags of a video', async function () {
@@ -388,7 +388,7 @@ describe('Test a single server', function () {
388 const res = await getVideo(server.url, videoId) 388 const res = await getVideo(server.url, videoId)
389 const video = res.body 389 const video = res.body
390 390
391 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) 391 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes))
392 }) 392 })
393 393
394 it('Should update only the description of a video', async function () { 394 it('Should update only the description of a video', async function () {
@@ -400,7 +400,8 @@ describe('Test a single server', function () {
400 const res = await getVideo(server.url, videoId) 400 const res = await getVideo(server.url, videoId)
401 const video = res.body 401 const video = res.body
402 402
403 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) 403 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
404 await completeVideoCheck(server.url, video, expectedAttributes)
404 }) 405 })
405 406
406 it('Should like a video', async function () { 407 it('Should like a video', async function () {
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index 7318497d5..a2f3ee161 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -9,7 +9,6 @@ import {
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideoAbusesList, 10 getVideoAbusesList,
11 getVideosList, 11 getVideosList,
12 killallServers,
13 reportVideoAbuse, 12 reportVideoAbuse,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
@@ -90,7 +89,7 @@ describe('Test video abuses', function () {
90 const abuse: VideoAbuse = res1.body.data[0] 89 const abuse: VideoAbuse = res1.body.data[0]
91 expect(abuse.reason).to.equal('my super bad reason') 90 expect(abuse.reason).to.equal('my super bad reason')
92 expect(abuse.reporterAccount.name).to.equal('root') 91 expect(abuse.reporterAccount.name).to.equal('root')
93 expect(abuse.reporterAccount.host).to.equal('localhost:9001') 92 expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port)
94 expect(abuse.video.id).to.equal(servers[0].video.id) 93 expect(abuse.video.id).to.equal(servers[0].video.id)
95 94
96 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 95 const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
@@ -118,7 +117,7 @@ describe('Test video abuses', function () {
118 const abuse1: VideoAbuse = res1.body.data[0] 117 const abuse1: VideoAbuse = res1.body.data[0]
119 expect(abuse1.reason).to.equal('my super bad reason') 118 expect(abuse1.reason).to.equal('my super bad reason')
120 expect(abuse1.reporterAccount.name).to.equal('root') 119 expect(abuse1.reporterAccount.name).to.equal('root')
121 expect(abuse1.reporterAccount.host).to.equal('localhost:9001') 120 expect(abuse1.reporterAccount.host).to.equal('localhost:' + servers[0].port)
122 expect(abuse1.video.id).to.equal(servers[0].video.id) 121 expect(abuse1.video.id).to.equal(servers[0].video.id)
123 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) 122 expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING)
124 expect(abuse1.state.label).to.equal('Pending') 123 expect(abuse1.state.label).to.equal('Pending')
@@ -127,7 +126,7 @@ describe('Test video abuses', function () {
127 const abuse2: VideoAbuse = res1.body.data[1] 126 const abuse2: VideoAbuse = res1.body.data[1]
128 expect(abuse2.reason).to.equal('my super bad reason 2') 127 expect(abuse2.reason).to.equal('my super bad reason 2')
129 expect(abuse2.reporterAccount.name).to.equal('root') 128 expect(abuse2.reporterAccount.name).to.equal('root')
130 expect(abuse2.reporterAccount.host).to.equal('localhost:9001') 129 expect(abuse2.reporterAccount.host).to.equal('localhost:' + servers[0].port)
131 expect(abuse2.video.id).to.equal(servers[1].video.id) 130 expect(abuse2.video.id).to.equal(servers[1].video.id)
132 expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING) 131 expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING)
133 expect(abuse2.state.label).to.equal('Pending') 132 expect(abuse2.state.label).to.equal('Pending')
@@ -141,7 +140,7 @@ describe('Test video abuses', function () {
141 abuseServer2 = res2.body.data[0] 140 abuseServer2 = res2.body.data[0]
142 expect(abuseServer2.reason).to.equal('my super bad reason 2') 141 expect(abuseServer2.reason).to.equal('my super bad reason 2')
143 expect(abuseServer2.reporterAccount.name).to.equal('root') 142 expect(abuseServer2.reporterAccount.name).to.equal('root')
144 expect(abuseServer2.reporterAccount.host).to.equal('localhost:9001') 143 expect(abuseServer2.reporterAccount.host).to.equal('localhost:' + servers[0].port)
145 expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING) 144 expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING)
146 expect(abuseServer2.state.label).to.equal('Pending') 145 expect(abuseServer2.state.label).to.equal('Pending')
147 expect(abuseServer2.moderationComment).to.be.null 146 expect(abuseServer2.moderationComment).to.be.null
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 1c0327d40..3a3add71b 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -4,7 +4,8 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 acceptChangeOwnership, 6 acceptChangeOwnership,
7 changeVideoOwnership, cleanupTests, 7 changeVideoOwnership,
8 cleanupTests,
8 createUser, 9 createUser,
9 doubleFollow, 10 doubleFollow,
10 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
@@ -13,7 +14,6 @@ import {
13 getVideo, 14 getVideo,
14 getVideoChangeOwnershipList, 15 getVideoChangeOwnershipList,
15 getVideosList, 16 getVideosList,
16 killallServers,
17 refuseChangeOwnership, 17 refuseChangeOwnership,
18 ServerInfo, 18 ServerInfo,
19 setAccessTokensToServers, 19 setAccessTokensToServers,
@@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () {
203 } 203 }
204 }) 204 })
205 205
206 after(function () { 206 after(async function () {
207 killallServers(servers) 207 await cleanupTests(servers)
208 }) 208 })
209}) 209})
210 210
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 345e96f43..41fe3be5c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -41,7 +41,7 @@ describe('Test video channels', function () {
41 let videoUUID: string 41 let videoUUID: string
42 42
43 before(async function () { 43 before(async function () {
44 this.timeout(30000) 44 this.timeout(60000)
45 45
46 servers = await flushAndRunMultipleServers(2) 46 servers = await flushAndRunMultipleServers(2)
47 47
@@ -213,7 +213,7 @@ describe('Test video channels', function () {
213 this.timeout(10000) 213 this.timeout(10000)
214 214
215 for (const server of servers) { 215 for (const server of servers) {
216 const channelURI = 'second_video_channel@localhost:9001' 216 const channelURI = 'second_video_channel@localhost:' + servers[0].port
217 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 217 const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
218 expect(res1.body.total).to.equal(1) 218 expect(res1.body.total).to.equal(1)
219 expect(res1.body.data).to.be.an('array') 219 expect(res1.body.data).to.be.an('array')
@@ -234,11 +234,11 @@ describe('Test video channels', function () {
234 this.timeout(10000) 234 this.timeout(10000)
235 235
236 for (const server of servers) { 236 for (const server of servers) {
237 const secondChannelURI = 'second_video_channel@localhost:9001' 237 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
238 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) 238 const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)
239 expect(res1.body.total).to.equal(0) 239 expect(res1.body.total).to.equal(0)
240 240
241 const channelURI = 'root_channel@localhost:9001' 241 const channelURI = 'root_channel@localhost:' + servers[0].port
242 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) 242 const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
243 expect(res2.body.total).to.equal(1) 243 expect(res2.body.total).to.equal(1)
244 244
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 22fd8c058..82182cc7c 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -66,8 +66,8 @@ describe('Test video comments', function () {
66 expect(comment.videoId).to.equal(videoId) 66 expect(comment.videoId).to.equal(videoId)
67 expect(comment.id).to.equal(comment.threadId) 67 expect(comment.id).to.equal(comment.threadId)
68 expect(comment.account.name).to.equal('root') 68 expect(comment.account.name).to.equal('root')
69 expect(comment.account.host).to.equal('localhost:9001') 69 expect(comment.account.host).to.equal('localhost:' + server.port)
70 expect(comment.account.url).to.equal('http://localhost:9001/accounts/root') 70 expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root')
71 expect(comment.totalReplies).to.equal(0) 71 expect(comment.totalReplies).to.equal(0)
72 expect(dateIsValid(comment.createdAt as string)).to.be.true 72 expect(dateIsValid(comment.createdAt as string)).to.be.true
73 expect(dateIsValid(comment.updatedAt as string)).to.be.true 73 expect(dateIsValid(comment.updatedAt as string)).to.be.true
@@ -86,7 +86,7 @@ describe('Test video comments', function () {
86 expect(comment.videoId).to.equal(videoId) 86 expect(comment.videoId).to.equal(videoId)
87 expect(comment.id).to.equal(comment.threadId) 87 expect(comment.id).to.equal(comment.threadId)
88 expect(comment.account.name).to.equal('root') 88 expect(comment.account.name).to.equal('root')
89 expect(comment.account.host).to.equal('localhost:9001') 89 expect(comment.account.host).to.equal('localhost:' + server.port)
90 90
91 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') 91 await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
92 92
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 22031c18b..504c50dee 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -5,13 +5,12 @@ import 'mocha'
5import { 5import {
6 checkDirectoryIsEmpty, 6 checkDirectoryIsEmpty,
7 checkSegmentHash, 7 checkSegmentHash,
8 checkTmpIsEmpty, cleanupTests, 8 checkTmpIsEmpty,
9 cleanupTests,
9 doubleFollow, 10 doubleFollow,
10 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
11 flushTests,
12 getPlaylist, 12 getPlaylist,
13 getVideo, 13 getVideo,
14 killallServers,
15 removeVideo, 14 removeVideo,
16 ServerInfo, 15 ServerInfo,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -51,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
51 50
52 { 51 {
53 for (const resolution of resolutions) { 52 for (const resolution of resolutions) {
54 const res2 = await getPlaylist(`http://localhost:9001/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) 53 const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)
55 54
56 const subPlaylist = res2.text 55 const subPlaylist = res2.text
57 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) 56 expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)
@@ -59,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {
59 } 58 }
60 59
61 { 60 {
62 const baseUrl = 'http://localhost:9001/static/streaming-playlists/hls' 61 const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls'
63 62
64 for (const resolution of resolutions) { 63 for (const resolution of resolutions) {
65 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) 64 await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index e4d817ff8..83a2f3d4d 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -358,7 +358,7 @@ describe('Test video playlists', function () {
358 358
359 for (const server of servers) { 359 for (const server of servers) {
360 const results = [ 360 const results = [
361 await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'), 361 await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),
362 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') 362 await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')
363 ] 363 ]
364 364
@@ -757,7 +757,7 @@ describe('Test video playlists', function () {
757 this.timeout(30000) 757 this.timeout(30000)
758 758
759 for (const server of servers) { 759 for (const server of servers) {
760 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber) 760 await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)
761 } 761 }
762 }) 762 })
763 763
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 3cd43e99b..cfd0c8430 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,24 +4,24 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
7import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 7import { audio, canDoQuickTranscode, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
8import { 8import {
9 buildAbsoluteFixturePath, cleanupTests, 9 buildAbsoluteFixturePath,
10 cleanupTests,
10 doubleFollow, 11 doubleFollow,
11 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
12 generateHighBitrateVideo, 13 generateHighBitrateVideo,
13 getMyVideos, 14 getMyVideos,
14 getVideo, 15 getVideo,
15 getVideosList, 16 getVideosList,
16 killallServers,
17 root, 17 root,
18 ServerInfo, 18 ServerInfo,
19 setAccessTokensToServers, 19 setAccessTokensToServers,
20 uploadVideo, 20 uploadVideo,
21 waitJobs,
21 webtorrentAdd 22 webtorrentAdd
22} from '../../../../shared/extra-utils' 23} from '../../../../shared/extra-utils'
23import { extname, join } from 'path' 24import { join } from 'path'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
25import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' 25import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
26 26
27const expect = chai.expect 27const expect = chai.expect
@@ -121,7 +121,7 @@ describe('Test video transcoding', function () {
121 121
122 expect(videoDetails.files).to.have.lengthOf(4) 122 expect(videoDetails.files).to.have.lengthOf(4)
123 123
124 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 124 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
125 const probe = await audio.get(path) 125 const probe = await audio.get(path)
126 126
127 if (probe.audioStream) { 127 if (probe.audioStream) {
@@ -152,7 +152,7 @@ describe('Test video transcoding', function () {
152 const videoDetails: VideoDetails = res2.body 152 const videoDetails: VideoDetails = res2.body
153 153
154 expect(videoDetails.files).to.have.lengthOf(4) 154 expect(videoDetails.files).to.have.lengthOf(4)
155 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 155 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
156 const probe = await audio.get(path) 156 const probe = await audio.get(path)
157 expect(probe).to.not.have.property('audioStream') 157 expect(probe).to.not.have.property('audioStream')
158 } 158 }
@@ -179,7 +179,7 @@ describe('Test video transcoding', function () {
179 expect(videoDetails.files).to.have.lengthOf(4) 179 expect(videoDetails.files).to.have.lengthOf(4)
180 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 180 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
181 const fixtureVideoProbe = await audio.get(fixturePath) 181 const fixtureVideoProbe = await audio.get(fixturePath)
182 const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') 182 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
183 const videoProbe = await audio.get(path) 183 const videoProbe = await audio.get(path)
184 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { 184 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
185 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] 185 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
@@ -216,13 +216,13 @@ describe('Test video transcoding', function () {
216 expect(videoDetails.files[ 3 ].fps).to.be.below(31) 216 expect(videoDetails.files[ 3 ].fps).to.be.below(31)
217 217
218 for (const resolution of [ '240', '360', '480' ]) { 218 for (const resolution of [ '240', '360', '480' ]) {
219 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') 219 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
220 const fps = await getVideoFileFPS(path) 220 const fps = await getVideoFileFPS(path)
221 221
222 expect(fps).to.be.below(31) 222 expect(fps).to.be.below(31)
223 } 223 }
224 224
225 const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') 225 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4')
226 const fps = await getVideoFileFPS(path) 226 const fps = await getVideoFileFPS(path)
227 227
228 expect(fps).to.be.above(58).and.below(62) 228 expect(fps).to.be.above(58).and.below(62)
@@ -310,7 +310,7 @@ describe('Test video transcoding', function () {
310 const video = res.body.data.find(v => v.name === videoAttributes.name) 310 const video = res.body.data.find(v => v.name === videoAttributes.name)
311 311
312 for (const resolution of ['240', '360', '480', '720', '1080']) { 312 for (const resolution of ['240', '360', '480', '720', '1080']) {
313 const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') 313 const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4')
314 const bitrate = await getVideoFileBitrate(path) 314 const bitrate = await getVideoFileBitrate(path)
315 const fps = await getVideoFileFPS(path) 315 const fps = await getVideoFileFPS(path)
316 const resolution2 = await getVideoFileResolution(path) 316 const resolution2 = await getVideoFileResolution(path)
@@ -324,6 +324,15 @@ describe('Test video transcoding', function () {
324 it('Should accept and transcode additional extensions', async function () { 324 it('Should accept and transcode additional extensions', async function () {
325 this.timeout(300000) 325 this.timeout(300000)
326 326
327 let tempFixturePath: string
328
329 {
330 tempFixturePath = await generateHighBitrateVideo()
331
332 const bitrate = await getVideoFileBitrate(tempFixturePath)
333 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS))
334 }
335
327 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { 336 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
328 const videoAttributes = { 337 const videoAttributes = {
329 name: fixture, 338 name: fixture,
@@ -349,6 +358,13 @@ describe('Test video transcoding', function () {
349 } 358 }
350 }) 359 })
351 360
361 it('Should correctly detect if quick transcode is possible', async function () {
362 this.timeout(10000)
363
364 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true
365 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false
366 })
367
352 after(async function () { 368 after(async function () {
353 await cleanupTests(servers) 369 await cleanupTests(servers)
354 }) 370 })
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index c21d46d56..fbddd40f4 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -10,7 +10,7 @@ import {
10 flushAndRunServer, 10 flushAndRunServer,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests 13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize
14} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
16import { VideosOverview } from '../../../../shared/models/overviews' 16import { VideosOverview } from '../../../../shared/models/overviews'
@@ -58,14 +58,14 @@ describe('Test video views cleaner', function () {
58 58
59 { 59 {
60 for (const server of servers) { 60 for (const server of servers) {
61 const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) 61 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
62 expect(total).to.equal(2) 62 expect(total).to.equal(2)
63 } 63 }
64 } 64 }
65 65
66 { 66 {
67 for (const server of servers) { 67 for (const server of servers) {
68 const total = await countVideoViewsOf(server.serverNumber, videoIdServer2) 68 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)
69 expect(total).to.equal(2) 69 expect(total).to.equal(2)
70 } 70 }
71 } 71 }
@@ -74,8 +74,6 @@ describe('Test video views cleaner', function () {
74 it('Should clean old video views', async function () { 74 it('Should clean old video views', async function () {
75 this.timeout(50000) 75 this.timeout(50000)
76 76
77 this.timeout(50000)
78
79 killallServers([ servers[0] ]) 77 killallServers([ servers[0] ])
80 78
81 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) 79 await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })
@@ -86,21 +84,23 @@ describe('Test video views cleaner', function () {
86 84
87 { 85 {
88 for (const server of servers) { 86 for (const server of servers) {
89 const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) 87 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
90 expect(total).to.equal(2) 88 expect(total).to.equal(2)
91 } 89 }
92 } 90 }
93 91
94 { 92 {
95 const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2) 93 const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2)
96 expect(totalServer1).to.equal(0) 94 expect(totalServer1).to.equal(0)
97 95
98 const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2) 96 const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2)
99 expect(totalServer2).to.equal(2) 97 expect(totalServer2).to.equal(2)
100 } 98 }
101 }) 99 })
102 100
103 after(async function () { 101 after(async function () {
102 await closeAllSequelize(servers)
103
104 await cleanupTests(servers) 104 await cleanupTests(servers)
105 }) 105 })
106}) 106})
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 5e12c0089..3822fca42 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -8,14 +8,16 @@ import {
8 doubleFollow, 8 doubleFollow,
9 execCLI, 9 execCLI,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 flushTests, generateHighBitrateVideo, 11 generateHighBitrateVideo,
12 getEnvCli, 12 getEnvCli,
13 getVideo, 13 getVideo,
14 getVideosList, 14 getVideosList,
15 killallServers, root, 15 root,
16 ServerInfo, 16 ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 uploadVideo, viewVideo, wait 18 uploadVideo,
19 viewVideo,
20 wait
19} from '../../../shared/extra-utils' 21} from '../../../shared/extra-utils'
20import { waitJobs } from '../../../shared/extra-utils/server/jobs' 22import { waitJobs } from '../../../shared/extra-utils/server/jobs'
21import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils' 23import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils'
@@ -102,7 +104,7 @@ describe('Test optimize old videos', function () {
102 104
103 expect(file.size).to.be.below(5000000) 105 expect(file.size).to.be.below(5000000)
104 106
105 const path = join(root(), 'test1', 'videos', video.uuid + '-' + file.resolution.id + '.mp4') 107 const path = join(root(), 'test' + servers[0].internalServerNumber, 'videos', video.uuid + '-' + file.resolution.id + '.mp4')
106 const bitrate = await getVideoFileBitrate(path) 108 const bitrate = await getVideoFileBitrate(path)
107 const fps = await getVideoFileFPS(path) 109 const fps = await getVideoFileFPS(path)
108 const resolution = await getVideoFileResolution(path) 110 const resolution = await getVideoFileResolution(path)