aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 09:43:59 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit6c5065a011b099618681a37bd77eaa7bd3db752e (patch)
tree352252a00b25013c4b1902f6bcd9668aba295c7b /server/tests/api/videos
parent0d8ecb7592577f54012413a2b5a9b159cfc90399 (diff)
downloadPeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.gz
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.zst
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.zip
Introduce server commands
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/audio-only.ts5
-rw-r--r--server/tests/api/videos/multiple-servers.ts4
-rw-r--r--server/tests/api/videos/resumable-upload.ts5
-rw-r--r--server/tests/api/videos/single-server.ts2
-rw-r--r--server/tests/api/videos/video-captions.ts2
-rw-r--r--server/tests/api/videos/video-imports.ts13
-rw-r--r--server/tests/api/videos/video-transcoder.ts22
7 files changed, 25 insertions, 28 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index 7ddbd5cd9..9b516af81 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' 6import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 buildServerDirectory,
9 cleanupTests, 8 cleanupTests,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -81,8 +80,8 @@ describe('Test audio only video transcoding', function () {
81 80
82 it('0p transcoded video should not have video', async function () { 81 it('0p transcoded video should not have video', async function () {
83 const paths = [ 82 const paths = [
84 buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')), 83 servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')),
85 buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) 84 servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
86 ] 85 ]
87 86
88 for (const path of paths) { 87 for (const path of paths) {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 1b6f0f48a..1905aac83 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -689,8 +689,8 @@ describe('Test multiple servers', function () {
689 689
690 it('Should not have files of videos 3 and 3-2 on each server', async function () { 690 it('Should not have files of videos 3 and 3-2 on each server', async function () {
691 for (const server of servers) { 691 for (const server of servers) {
692 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber) 692 await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
693 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber) 693 await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
694 } 694 }
695 }) 695 })
696 696
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 6c01c7e78..5845efc86 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -7,7 +7,6 @@ import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/core-utils'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 buildServerDirectory,
11 cleanupTests, 10 cleanupTests,
12 flushAndRunServer, 11 flushAndRunServer,
13 getMyUserInformation, 12 getMyUserInformation,
@@ -82,7 +81,7 @@ describe('Test resumable upload', function () {
82 const uploadId = uploadIdArg.replace(/^upload_id=/, '') 81 const uploadId = uploadIdArg.replace(/^upload_id=/, '')
83 82
84 const subPath = join('tmp', 'resumable-uploads', uploadId) 83 const subPath = join('tmp', 'resumable-uploads', uploadId)
85 const filePath = buildServerDirectory(server, subPath) 84 const filePath = server.serversCommand.buildDirectory(subPath)
86 const exists = await pathExists(filePath) 85 const exists = await pathExists(filePath)
87 86
88 if (expectedSize === null) { 87 if (expectedSize === null) {
@@ -97,7 +96,7 @@ describe('Test resumable upload', function () {
97 96
98 async function countResumableUploads () { 97 async function countResumableUploads () {
99 const subPath = join('tmp', 'resumable-uploads') 98 const subPath = join('tmp', 'resumable-uploads')
100 const filePath = buildServerDirectory(server, subPath) 99 const filePath = server.serversCommand.buildDirectory(subPath)
101 100
102 const files = await readdir(filePath) 101 const files = await readdir(filePath)
103 return files.length 102 return files.length
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index 1058a1e9c..af1703e02 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -230,7 +230,7 @@ describe('Test a single server', function () {
230 it('Should remove the video', async function () { 230 it('Should remove the video', async function () {
231 await removeVideo(server.url, server.accessToken, videoId) 231 await removeVideo(server.url, server.accessToken, videoId)
232 232
233 await checkVideoFilesWereRemoved(videoUUID, 1) 233 await checkVideoFilesWereRemoved(videoUUID, server)
234 }) 234 })
235 235
236 it('Should not have videos', async function () { 236 it('Should not have videos', async function () {
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index 83ee809b8..d4a5385ab 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -182,7 +182,7 @@ describe('Test video captions', function () {
182 it('Should remove the video, and thus all video captions', async function () { 182 it('Should remove the video, and thus all video captions', async function () {
183 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) 183 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
184 184
185 await checkVideoFilesWereRemoved(videoUUID, 1) 185 await checkVideoFilesWereRemoved(videoUUID, servers[0])
186 }) 186 })
187 187
188 after(async function () { 188 after(async function () {
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 4f9ecbe8e..f6ae8cab1 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -11,7 +11,6 @@ import {
11 getMyVideos, 11 getMyVideos,
12 getVideo, 12 getVideo,
13 getVideosList, 13 getVideosList,
14 immutableAssign,
15 ImportsCommand, 14 ImportsCommand,
16 ServerInfo, 15 ServerInfo,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -119,7 +118,7 @@ describe('Test video imports', function () {
119 } 118 }
120 119
121 { 120 {
122 const attributes = immutableAssign(baseAttributes, { targetUrl: ImportsCommand.getYoutubeVideoUrl() }) 121 const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
123 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 122 const { video } = await servers[0].importsCommand.importVideo({ attributes })
124 expect(video.name).to.equal('small video - youtube') 123 expect(video.name).to.equal('small video - youtube')
125 124
@@ -169,21 +168,23 @@ Ajouter un sous-titre est vraiment facile`)
169 } 168 }
170 169
171 { 170 {
172 const attributes = immutableAssign(baseAttributes, { 171 const attributes = {
172 ...baseAttributes,
173 magnetUri: ImportsCommand.getMagnetURI(), 173 magnetUri: ImportsCommand.getMagnetURI(),
174 description: 'this is a super torrent description', 174 description: 'this is a super torrent description',
175 tags: [ 'tag_torrent1', 'tag_torrent2' ] 175 tags: [ 'tag_torrent1', 'tag_torrent2' ]
176 }) 176 }
177 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 177 const { video } = await servers[0].importsCommand.importVideo({ attributes })
178 expect(video.name).to.equal('super peertube2 video') 178 expect(video.name).to.equal('super peertube2 video')
179 } 179 }
180 180
181 { 181 {
182 const attributes = immutableAssign(baseAttributes, { 182 const attributes = {
183 ...baseAttributes,
183 torrentfile: 'video-720p.torrent' as any, 184 torrentfile: 'video-720p.torrent' as any,
184 description: 'this is a super torrent description', 185 description: 'this is a super torrent description',
185 tags: [ 'tag_torrent1', 'tag_torrent2' ] 186 tags: [ 'tag_torrent1', 'tag_torrent2' ]
186 }) 187 }
187 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 188 const { video } = await servers[0].importsCommand.importVideo({ attributes })
188 expect(video.name).to.equal('你好 世界 720p.mp4') 189 expect(video.name).to.equal('你好 世界 720p.mp4')
189 } 190 }
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index e74fb5bef..f16b22bae 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -9,14 +9,12 @@ import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
10import { 10import {
11 buildAbsoluteFixturePath, 11 buildAbsoluteFixturePath,
12 buildServerDirectory,
13 cleanupTests, 12 cleanupTests,
14 doubleFollow, 13 doubleFollow,
15 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
16 generateHighBitrateVideo, 15 generateHighBitrateVideo,
17 generateVideoWithFramerate, 16 generateVideoWithFramerate,
18 getMyVideos, 17 getMyVideos,
19 getServerFileSize,
20 getVideo, 18 getVideo,
21 getVideoFileMetadataUrl, 19 getVideoFileMetadataUrl,
22 getVideosList, 20 getVideosList,
@@ -285,7 +283,7 @@ describe('Test video transcoding', function () {
285 283
286 expect(videoDetails.files).to.have.lengthOf(4) 284 expect(videoDetails.files).to.have.lengthOf(4)
287 285
288 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 286 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
289 const probe = await getAudioStream(path) 287 const probe = await getAudioStream(path)
290 288
291 if (probe.audioStream) { 289 if (probe.audioStream) {
@@ -316,7 +314,7 @@ describe('Test video transcoding', function () {
316 const videoDetails: VideoDetails = res2.body 314 const videoDetails: VideoDetails = res2.body
317 315
318 expect(videoDetails.files).to.have.lengthOf(4) 316 expect(videoDetails.files).to.have.lengthOf(4)
319 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 317 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
320 const probe = await getAudioStream(path) 318 const probe = await getAudioStream(path)
321 expect(probe).to.not.have.property('audioStream') 319 expect(probe).to.not.have.property('audioStream')
322 } 320 }
@@ -344,7 +342,7 @@ describe('Test video transcoding', function () {
344 342
345 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) 343 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
346 const fixtureVideoProbe = await getAudioStream(fixturePath) 344 const fixtureVideoProbe = await getAudioStream(fixturePath)
347 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 345 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
348 346
349 const videoProbe = await getAudioStream(path) 347 const videoProbe = await getAudioStream(path)
350 348
@@ -506,13 +504,13 @@ describe('Test video transcoding', function () {
506 expect(videoDetails.files[3].fps).to.be.below(31) 504 expect(videoDetails.files[3].fps).to.be.below(31)
507 505
508 for (const resolution of [ '240', '360', '480' ]) { 506 for (const resolution of [ '240', '360', '480' ]) {
509 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) 507 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
510 const fps = await getVideoFileFPS(path) 508 const fps = await getVideoFileFPS(path)
511 509
512 expect(fps).to.be.below(31) 510 expect(fps).to.be.below(31)
513 } 511 }
514 512
515 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) 513 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
516 const fps = await getVideoFileFPS(path) 514 const fps = await getVideoFileFPS(path)
517 515
518 expect(fps).to.be.above(58).and.below(62) 516 expect(fps).to.be.above(58).and.below(62)
@@ -547,13 +545,13 @@ describe('Test video transcoding', function () {
547 const video = res.body.data.find(v => v.name === videoAttributes.name) 545 const video = res.body.data.find(v => v.name === videoAttributes.name)
548 546
549 { 547 {
550 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) 548 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4'))
551 const fps = await getVideoFileFPS(path) 549 const fps = await getVideoFileFPS(path)
552 expect(fps).to.be.equal(25) 550 expect(fps).to.be.equal(25)
553 } 551 }
554 552
555 { 553 {
556 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) 554 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4'))
557 const fps = await getVideoFileFPS(path) 555 const fps = await getVideoFileFPS(path)
558 expect(fps).to.be.equal(59) 556 expect(fps).to.be.equal(59)
559 } 557 }
@@ -590,7 +588,7 @@ describe('Test video transcoding', function () {
590 const video = res.body.data.find(v => v.name === videoAttributes.name) 588 const video = res.body.data.find(v => v.name === videoAttributes.name)
591 589
592 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 590 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
593 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) 591 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
594 592
595 const bitrate = await getVideoFileBitrate(path) 593 const bitrate = await getVideoFileBitrate(path)
596 const fps = await getVideoFileFPS(path) 594 const fps = await getVideoFileFPS(path)
@@ -636,7 +634,7 @@ describe('Test video transcoding', function () {
636 const resolutions = [ 240, 360, 480, 720, 1080 ] 634 const resolutions = [ 240, 360, 480, 720, 1080 ]
637 for (const r of resolutions) { 635 for (const r of resolutions) {
638 const path = `videos/${videoUUID}-${r}.mp4` 636 const path = `videos/${videoUUID}-${r}.mp4`
639 const size = await getServerFileSize(servers[1], path) 637 const size = await servers[1].serversCommand.getServerFileSize(path)
640 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 638 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
641 } 639 }
642 }) 640 })
@@ -651,7 +649,7 @@ describe('Test video transcoding', function () {
651 await waitJobs(servers) 649 await waitJobs(servers)
652 650
653 { 651 {
654 const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4')) 652 const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
655 const metadata = await getMetadataFromFile(path) 653 const metadata = await getMetadataFromFile(path)
656 654
657 // expected format properties 655 // expected format properties