]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/videos/video-transcoder.ts
Add migration to delete old Authors table
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-transcoder.ts
CommitLineData
0e1dc3e7
C
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 uploadVideo,
11 getVideosList,
12 wait,
13 setAccessTokensToServers,
14 flushAndRunMultipleServers,
15 killallServers,
5f04dd2f
C
16 webtorrentAdd,
17 getVideo
c5d31dba 18} from '../../utils/index'
0e1dc3e7
C
19
20describe('Test video transcoding', function () {
21 let servers: ServerInfo[] = []
22
23 before(async function () {
572f8d3d 24 this.timeout(10000)
0e1dc3e7
C
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 = {
975e6e0e
C
36 name: 'my super name for server 1',
37 description: 'my super description for server 1',
0e1dc3e7
C
38 fixture: 'video_short.webm'
39 }
40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
41
572f8d3d 42 await wait(10000)
0e1dc3e7
C
43
44 const res = await getVideosList(servers[0].url)
45 const video = res.body.data[0]
40298b02 46
5f04dd2f
C
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
0e1dc3e7
C
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 = {
975e6e0e
C
64 name: 'my super name for server 2',
65 description: 'my super description for server 2',
0e1dc3e7
C
66 fixture: 'video_short.webm'
67 }
68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
69
5e3bb76c 70 await wait(20000)
0e1dc3e7
C
71
72 const res = await getVideosList(servers[1].url)
73
74 const video = res.body.data[0]
5f04dd2f
C
75 const res2 = await getVideo(servers[1].url, video.id)
76 const videoDetails = res2.body
77
78 expect(videoDetails.files).to.have.lengthOf(4)
40298b02 79
5f04dd2f 80 const magnetUri = videoDetails.files[0].magnetUri
0e1dc3e7
C
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})