]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/video-transcoder.ts
Design confirm dialog
[github/Chocobozzz/PeerTube.git] / server / tests / api / video-transcoder.ts
1 /* tslint:disable:no-unused-expression */
2
3 import 'mocha'
4 import * as chai from 'chai'
5 const expect = chai.expect
6
7 import {
8 ServerInfo,
9 flushTests,
10 uploadVideo,
11 getVideosList,
12 wait,
13 setAccessTokensToServers,
14 flushAndRunMultipleServers,
15 killallServers,
16 webtorrentAdd,
17 getVideo
18 } from '../utils'
19
20 describe('Test video transcoding', function () {
21 let servers: ServerInfo[] = []
22
23 before(async function () {
24 this.timeout(10000)
25
26 // Run servers
27 servers = await flushAndRunMultipleServers(2)
28
29 await setAccessTokensToServers(servers)
30 })
31
32 it('Should not transcode video on server 1', async function () {
33 this.timeout(60000)
34
35 const videoAttributes = {
36 name: 'my super name for server 1',
37 description: 'my super description for server 1',
38 fixture: 'video_short.webm'
39 }
40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
41
42 await wait(10000)
43
44 const res = await getVideosList(servers[0].url)
45 const video = res.body.data[0]
46
47 const res2 = await getVideo(servers[0].url, video.id)
48 const videoDetails = res2.body
49 expect(videoDetails.files).to.have.lengthOf(1)
50
51 const magnetUri = videoDetails.files[0].magnetUri
52 expect(magnetUri).to.match(/\.webm/)
53
54 const torrent = await webtorrentAdd(magnetUri)
55 expect(torrent.files).to.be.an('array')
56 expect(torrent.files.length).to.equal(1)
57 expect(torrent.files[0].path).match(/\.webm$/)
58 })
59
60 it('Should transcode video on server 2', async function () {
61 this.timeout(60000)
62
63 const videoAttributes = {
64 name: 'my super name for server 2',
65 description: 'my super description for server 2',
66 fixture: 'video_short.webm'
67 }
68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
69
70 await wait(20000)
71
72 const res = await getVideosList(servers[1].url)
73
74 const video = res.body.data[0]
75 const res2 = await getVideo(servers[1].url, video.id)
76 const videoDetails = res2.body
77
78 expect(videoDetails.files).to.have.lengthOf(4)
79
80 const magnetUri = videoDetails.files[0].magnetUri
81 expect(magnetUri).to.match(/\.mp4/)
82
83 const torrent = await webtorrentAdd(magnetUri)
84 expect(torrent.files).to.be.an('array')
85 expect(torrent.files.length).to.equal(1)
86 expect(torrent.files[0].path).match(/\.mp4$/)
87 })
88
89 after(async function () {
90 killallServers(servers)
91
92 // Keep the logs if the test failed
93 if (this['ok']) {
94 await flushTests()
95 }
96 })
97 })