aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-02 12:20:26 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-03 15:31:26 +0200
commit40298b02546e8225dd21bf6048fe7f224aefc32a (patch)
tree0a0b981dbeb2af47810adff6553a0df995a03734 /server/tests/api
parentf0adb2701c1cf404ff63095f71e542bfe6d025ae (diff)
downloadPeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.tar.gz
PeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.tar.zst
PeerTube-40298b02546e8225dd21bf6048fe7f224aefc32a.zip
Implement video transcoding on server side
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/multiple-pods.ts65
-rw-r--r--server/tests/api/video-transcoder.ts4
2 files changed, 48 insertions, 21 deletions
diff --git a/server/tests/api/multiple-pods.ts b/server/tests/api/multiple-pods.ts
index 7117ab290..9860935e5 100644
--- a/server/tests/api/multiple-pods.ts
+++ b/server/tests/api/multiple-pods.ts
@@ -129,7 +129,7 @@ describe('Test multiple pods', function () {
129 }) 129 })
130 130
131 it('Should upload the video on pod 2 and propagate on each pod', async function () { 131 it('Should upload the video on pod 2 and propagate on each pod', async function () {
132 this.timeout(60000) 132 this.timeout(120000)
133 133
134 const videoAttributes = { 134 const videoAttributes = {
135 name: 'my super name for pod 2', 135 name: 'my super name for pod 2',
@@ -143,12 +143,12 @@ describe('Test multiple pods', function () {
143 } 143 }
144 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) 144 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
145 145
146 // Transcoding, so wait more that 22 seconds 146 // Transcoding, so wait more than 22000
147 await wait(42000) 147 await wait(60000)
148 148
149 // All pods should have this video 149 // All pods should have this video
150 for (const server of servers) { 150 for (const server of servers) {
151 let baseMagnet = null 151 let baseMagnet = {}
152 152
153 const res = await getVideosList(server.url) 153 const res = await getVideosList(server.url)
154 154
@@ -172,28 +172,51 @@ describe('Test multiple pods', function () {
172 expect(dateIsValid(video.updatedAt)).to.be.true 172 expect(dateIsValid(video.updatedAt)).to.be.true
173 expect(video.author).to.equal('root') 173 expect(video.author).to.equal('root')
174 174
175 expect(video.files).to.have.lengthOf(1) 175 expect(video.files).to.have.lengthOf(5)
176 176
177 const file = video.files[0] 177 // Check common attributes
178 const magnetUri = file.magnetUri 178 for (const file of video.files) {
179 expect(file.magnetUri).to.have.lengthOf.above(2) 179 expect(file.magnetUri).to.have.lengthOf.above(2)
180 expect(file.resolution).to.equal(0)
181 expect(file.resolutionLabel).to.equal('original')
182 expect(file.size).to.equal(942961)
183 180
184 if (server.url !== 'http://localhost:9002') { 181 if (server.url !== 'http://localhost:9002') {
185 expect(video.isLocal).to.be.false 182 expect(video.isLocal).to.be.false
186 } else { 183 } else {
187 expect(video.isLocal).to.be.true 184 expect(video.isLocal).to.be.true
188 } 185 }
189 186
190 // All pods should have the same magnet Uri 187 // All pods should have the same magnet Uri
191 if (baseMagnet === null) { 188 if (baseMagnet[file.resolution] === undefined) {
192 baseMagnet = magnetUri 189 baseMagnet[file.resolution] = file.magnet
193 } else { 190 } else {
194 expect(baseMagnet).to.equal(magnetUri) 191 expect(baseMagnet[file.resolution]).to.equal(file.magnet)
192 }
195 } 193 }
196 194
195 const originalFile = video.files.find(f => f.resolution === 0)
196 expect(originalFile).not.to.be.undefined
197 expect(originalFile.resolutionLabel).to.equal('original')
198 expect(originalFile.size).to.equal(711327)
199
200 const file240p = video.files.find(f => f.resolution === 1)
201 expect(file240p).not.to.be.undefined
202 expect(file240p.resolutionLabel).to.equal('240p')
203 expect(file240p.size).to.equal(139953)
204
205 const file360p = video.files.find(f => f.resolution === 2)
206 expect(file360p).not.to.be.undefined
207 expect(file360p.resolutionLabel).to.equal('360p')
208 expect(file360p.size).to.equal(169926)
209
210 const file480p = video.files.find(f => f.resolution === 3)
211 expect(file480p).not.to.be.undefined
212 expect(file480p.resolutionLabel).to.equal('480p')
213 expect(file480p.size).to.equal(206758)
214
215 const file720p = video.files.find(f => f.resolution === 4)
216 expect(file720p).not.to.be.undefined
217 expect(file720p.resolutionLabel).to.equal('720p')
218 expect(file720p.size).to.equal(314913)
219
197 const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath) 220 const test = await testVideoImage(server.url, 'video_short2.webm', video.thumbnailPath)
198 expect(test).to.equal(true) 221 expect(test).to.equal(true)
199 } 222 }
diff --git a/server/tests/api/video-transcoder.ts b/server/tests/api/video-transcoder.ts
index c6d4c61f5..b5d84d9e7 100644
--- a/server/tests/api/video-transcoder.ts
+++ b/server/tests/api/video-transcoder.ts
@@ -42,6 +42,8 @@ describe('Test video transcoding', function () {
42 42
43 const res = await getVideosList(servers[0].url) 43 const res = await getVideosList(servers[0].url)
44 const video = res.body.data[0] 44 const video = res.body.data[0]
45 expect(video.files).to.have.lengthOf(1)
46
45 const magnetUri = video.files[0].magnetUri 47 const magnetUri = video.files[0].magnetUri
46 expect(magnetUri).to.match(/\.webm/) 48 expect(magnetUri).to.match(/\.webm/)
47 49
@@ -66,6 +68,8 @@ describe('Test video transcoding', function () {
66 const res = await getVideosList(servers[1].url) 68 const res = await getVideosList(servers[1].url)
67 69
68 const video = res.body.data[0] 70 const video = res.body.data[0]
71 expect(video.files).to.have.lengthOf(5)
72
69 const magnetUri = video.files[0].magnetUri 73 const magnetUri = video.files[0].magnetUri
70 expect(magnetUri).to.match(/\.mp4/) 74 expect(magnetUri).to.match(/\.mp4/)
71 75