diff options
Diffstat (limited to 'server/tests/shared')
-rw-r--r-- | server/tests/shared/checks.ts | 11 | ||||
-rw-r--r-- | server/tests/shared/videos.ts | 23 |
2 files changed, 23 insertions, 11 deletions
diff --git a/server/tests/shared/checks.ts b/server/tests/shared/checks.ts index feaef37c6..90179c6ac 100644 --- a/server/tests/shared/checks.ts +++ b/server/tests/shared/checks.ts | |||
@@ -61,6 +61,16 @@ async function testImageSize (url: string, imageName: string, imageHTTPPath: str | |||
61 | expect(body.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture') | 61 | expect(body.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture') |
62 | } | 62 | } |
63 | 63 | ||
64 | async function testImageGeneratedByFFmpeg (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { | ||
65 | if (process.env.ENABLE_FFMPEG_THUMBNAIL_PIXEL_COMPARISON_TESTS !== 'true') { | ||
66 | console.log( | ||
67 | 'Pixel comparison of image generated by ffmpeg is disabled. ' + | ||
68 | 'You can enable it using `ENABLE_FFMPEG_THUMBNAIL_PIXEL_COMPARISON_TESTS=true env variable') | ||
69 | } | ||
70 | |||
71 | return testImage(url, imageName, imageHTTPPath, extension) | ||
72 | } | ||
73 | |||
64 | async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { | 74 | async function testImage (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { |
65 | const res = await makeGetRequest({ | 75 | const res = await makeGetRequest({ |
66 | url, | 76 | url, |
@@ -148,6 +158,7 @@ async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, du | |||
148 | 158 | ||
149 | export { | 159 | export { |
150 | dateIsValid, | 160 | dateIsValid, |
161 | testImageGeneratedByFFmpeg, | ||
151 | testImageSize, | 162 | testImageSize, |
152 | testImage, | 163 | testImage, |
153 | expectLogDoesNotContain, | 164 | expectLogDoesNotContain, |
diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts index 856fabd11..e09bd60b5 100644 --- a/server/tests/shared/videos.ts +++ b/server/tests/shared/videos.ts | |||
@@ -7,7 +7,7 @@ import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO | |||
7 | import { getLowercaseExtension, pick, uuidRegex } from '@shared/core-utils' | 7 | import { getLowercaseExtension, pick, uuidRegex } from '@shared/core-utils' |
8 | import { HttpStatusCode, VideoCaption, VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' | 8 | import { HttpStatusCode, VideoCaption, VideoDetails, VideoPrivacy, VideoResolution } from '@shared/models' |
9 | import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs } from '@shared/server-commands' | 9 | import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs } from '@shared/server-commands' |
10 | import { dateIsValid, expectStartWith, testImage } from './checks' | 10 | import { dateIsValid, expectStartWith, testImageGeneratedByFFmpeg } from './checks' |
11 | import { checkWebTorrentWorks } from './webtorrent' | 11 | import { checkWebTorrentWorks } from './webtorrent' |
12 | 12 | ||
13 | loadLanguages() | 13 | loadLanguages() |
@@ -28,7 +28,7 @@ async function completeWebVideoFilesCheck (options: { | |||
28 | const serverConfig = await originServer.config.getConfig() | 28 | const serverConfig = await originServer.config.getConfig() |
29 | const requiresAuth = video.privacy.id === VideoPrivacy.PRIVATE || video.privacy.id === VideoPrivacy.INTERNAL | 29 | const requiresAuth = video.privacy.id === VideoPrivacy.PRIVATE || video.privacy.id === VideoPrivacy.INTERNAL |
30 | 30 | ||
31 | const transcodingEnabled = serverConfig.transcoding.webtorrent.enabled | 31 | const transcodingEnabled = serverConfig.transcoding.web_videos.enabled |
32 | 32 | ||
33 | for (const attributeFile of files) { | 33 | for (const attributeFile of files) { |
34 | const file = video.files.find(f => f.resolution.id === attributeFile.resolution) | 34 | const file = video.files.find(f => f.resolution.id === attributeFile.resolution) |
@@ -51,11 +51,12 @@ async function completeWebVideoFilesCheck (options: { | |||
51 | expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`)) | 51 | expect(file.torrentUrl).to.match(new RegExp(`${server.url}/lazy-static/torrents/${nameReg}.torrent`)) |
52 | 52 | ||
53 | if (objectStorageBaseUrl && requiresAuth) { | 53 | if (objectStorageBaseUrl && requiresAuth) { |
54 | expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/object-storage-proxy/webseed/${privatePath}${nameReg}${extension}`)) | 54 | const regexp = new RegExp(`${originServer.url}/object-storage-proxy/web-videos/${privatePath}${nameReg}${extension}`) |
55 | expect(file.fileUrl).to.match(regexp) | ||
55 | } else if (objectStorageBaseUrl) { | 56 | } else if (objectStorageBaseUrl) { |
56 | expectStartWith(file.fileUrl, objectStorageBaseUrl) | 57 | expectStartWith(file.fileUrl, objectStorageBaseUrl) |
57 | } else { | 58 | } else { |
58 | expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/webseed/${privatePath}${nameReg}${extension}`)) | 59 | expect(file.fileUrl).to.match(new RegExp(`${originServer.url}/static/web-videos/${privatePath}${nameReg}${extension}`)) |
59 | } | 60 | } |
60 | 61 | ||
61 | expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`)) | 62 | expect(file.fileDownloadUrl).to.match(new RegExp(`${originServer.url}/download/videos/${nameReg}${extension}`)) |
@@ -197,11 +198,11 @@ async function completeVideoCheck (options: { | |||
197 | expect(video.downloadEnabled).to.equal(attributes.downloadEnabled) | 198 | expect(video.downloadEnabled).to.equal(attributes.downloadEnabled) |
198 | 199 | ||
199 | expect(video.thumbnailPath).to.exist | 200 | expect(video.thumbnailPath).to.exist |
200 | await testImage(server.url, attributes.thumbnailfile || attributes.fixture, video.thumbnailPath) | 201 | await testImageGeneratedByFFmpeg(server.url, attributes.thumbnailfile || attributes.fixture, video.thumbnailPath) |
201 | 202 | ||
202 | if (attributes.previewfile) { | 203 | if (attributes.previewfile) { |
203 | expect(video.previewPath).to.exist | 204 | expect(video.previewPath).to.exist |
204 | await testImage(server.url, attributes.previewfile, video.previewPath) | 205 | await testImageGeneratedByFFmpeg(server.url, attributes.previewfile, video.previewPath) |
205 | } | 206 | } |
206 | 207 | ||
207 | await completeWebVideoFilesCheck({ server, originServer, videoUUID: video.uuid, ...pick(attributes, [ 'fixture', 'files' ]) }) | 208 | await completeWebVideoFilesCheck({ server, originServer, videoUUID: video.uuid, ...pick(attributes, [ 'fixture', 'files' ]) }) |
@@ -215,22 +216,22 @@ async function checkVideoFilesWereRemoved (options: { | |||
215 | }) { | 216 | }) { |
216 | const { video, server, captions = [], onlyVideoFiles = false } = options | 217 | const { video, server, captions = [], onlyVideoFiles = false } = options |
217 | 218 | ||
218 | const webtorrentFiles = video.files || [] | 219 | const webVideoFiles = video.files || [] |
219 | const hlsFiles = video.streamingPlaylists[0]?.files || [] | 220 | const hlsFiles = video.streamingPlaylists[0]?.files || [] |
220 | 221 | ||
221 | const thumbnailName = basename(video.thumbnailPath) | 222 | const thumbnailName = basename(video.thumbnailPath) |
222 | const previewName = basename(video.previewPath) | 223 | const previewName = basename(video.previewPath) |
223 | 224 | ||
224 | const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl)) | 225 | const torrentNames = webVideoFiles.concat(hlsFiles).map(f => basename(f.torrentUrl)) |
225 | 226 | ||
226 | const captionNames = captions.map(c => basename(c.captionPath)) | 227 | const captionNames = captions.map(c => basename(c.captionPath)) |
227 | 228 | ||
228 | const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl)) | 229 | const webVideoFilenames = webVideoFiles.map(f => basename(f.fileUrl)) |
229 | const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl)) | 230 | const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl)) |
230 | 231 | ||
231 | let directories: { [ directory: string ]: string[] } = { | 232 | let directories: { [ directory: string ]: string[] } = { |
232 | videos: webtorrentFilenames, | 233 | videos: webVideoFilenames, |
233 | redundancy: webtorrentFilenames, | 234 | redundancy: webVideoFilenames, |
234 | [join('playlists', 'hls')]: hlsFilenames, | 235 | [join('playlists', 'hls')]: hlsFilenames, |
235 | [join('redundancy', 'hls')]: hlsFilenames | 236 | [join('redundancy', 'hls')]: hlsFilenames |
236 | } | 237 | } |