aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/create-import-video-file-job.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli/create-import-video-file-job.ts')
-rw-r--r--server/tests/cli/create-import-video-file-job.ts56
1 files changed, 49 insertions, 7 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index bddcff5e7..9f1b57a2e 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -2,8 +2,19 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' 5import {
6import { VideoFile } from '@shared/models' 6 areObjectStorageTestsDisabled,
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 expectStartWith,
11 makeRawRequest,
12 ObjectStorageCommand,
13 PeerTubeServer,
14 setAccessTokensToServers,
15 waitJobs
16} from '@shared/extra-utils'
17import { HttpStatusCode, VideoDetails, VideoFile } from '@shared/models'
7 18
8const expect = chai.expect 19const expect = chai.expect
9 20
@@ -17,22 +28,35 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s
17 if (size) expect(video.size).to.equal(size) 28 if (size) expect(video.size).to.equal(size)
18} 29}
19 30
20describe('Test create import video jobs', function () { 31async function checkFiles (video: VideoDetails, objectStorage: boolean) {
21 this.timeout(60000) 32 for (const file of video.files) {
33 if (objectStorage) expectStartWith(file.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
22 34
23 let servers: PeerTubeServer[] = [] 35 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
36 }
37}
38
39function runTests (objectStorage: boolean) {
24 let video1UUID: string 40 let video1UUID: string
25 let video2UUID: string 41 let video2UUID: string
26 42
43 let servers: PeerTubeServer[] = []
44
27 before(async function () { 45 before(async function () {
28 this.timeout(90000) 46 this.timeout(90000)
29 47
48 const config = objectStorage
49 ? ObjectStorageCommand.getDefaultConfig()
50 : {}
51
30 // Run server 2 to have transcoding enabled 52 // Run server 2 to have transcoding enabled
31 servers = await createMultipleServers(2) 53 servers = await createMultipleServers(2, config)
32 await setAccessTokensToServers(servers) 54 await setAccessTokensToServers(servers)
33 55
34 await doubleFollow(servers[0], servers[1]) 56 await doubleFollow(servers[0], servers[1])
35 57
58 if (objectStorage) await ObjectStorageCommand.prepareDefaultBuckets()
59
36 // Upload two videos for our needs 60 // Upload two videos for our needs
37 { 61 {
38 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } }) 62 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
@@ -44,7 +68,6 @@ describe('Test create import video jobs', function () {
44 video2UUID = uuid 68 video2UUID = uuid
45 } 69 }
46 70
47 // Transcoding
48 await waitJobs(servers) 71 await waitJobs(servers)
49 }) 72 })
50 73
@@ -65,6 +88,8 @@ describe('Test create import video jobs', function () {
65 const [ originalVideo, transcodedVideo ] = videoDetails.files 88 const [ originalVideo, transcodedVideo ] = videoDetails.files
66 assertVideoProperties(originalVideo, 720, 'webm', 218910) 89 assertVideoProperties(originalVideo, 720, 'webm', 218910)
67 assertVideoProperties(transcodedVideo, 480, 'webm', 69217) 90 assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
91
92 await checkFiles(videoDetails, objectStorage)
68 } 93 }
69 }) 94 })
70 95
@@ -87,6 +112,8 @@ describe('Test create import video jobs', function () {
87 assertVideoProperties(transcodedVideo420, 480, 'mp4') 112 assertVideoProperties(transcodedVideo420, 480, 'mp4')
88 assertVideoProperties(transcodedVideo320, 360, 'mp4') 113 assertVideoProperties(transcodedVideo320, 360, 'mp4')
89 assertVideoProperties(transcodedVideo240, 240, 'mp4') 114 assertVideoProperties(transcodedVideo240, 240, 'mp4')
115
116 await checkFiles(videoDetails, objectStorage)
90 } 117 }
91 }) 118 })
92 119
@@ -107,10 +134,25 @@ describe('Test create import video jobs', function () {
107 const [ video720, video480 ] = videoDetails.files 134 const [ video720, video480 ] = videoDetails.files
108 assertVideoProperties(video720, 720, 'webm', 942961) 135 assertVideoProperties(video720, 720, 'webm', 942961)
109 assertVideoProperties(video480, 480, 'webm', 69217) 136 assertVideoProperties(video480, 480, 'webm', 69217)
137
138 await checkFiles(videoDetails, objectStorage)
110 } 139 }
111 }) 140 })
112 141
113 after(async function () { 142 after(async function () {
114 await cleanupTests(servers) 143 await cleanupTests(servers)
115 }) 144 })
145}
146
147describe('Test create import video jobs', function () {
148
149 describe('On filesystem', function () {
150 runTests(false)
151 })
152
153 describe('On object storage', function () {
154 if (areObjectStorageTestsDisabled()) return
155
156 runTests(true)
157 })
116}) 158})