]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/video-transcoder.js
1 /* eslint-disable no-unused-expressions */
5 const chai
= require('chai')
6 const each
= require('async/each')
7 const expect
= chai
.expect
8 const series
= require('async/series')
9 const webtorrent
= new (require('webtorrent'))()
11 const loginUtils
= require('../utils/login')
12 const serversUtils
= require('../utils/servers')
13 const videosUtils
= require('../utils/videos')
15 describe('Test video transcoding', function () {
18 before(function (done
) {
24 serversUtils
.flushAndRunMultipleServers(2, function (serversRun
) {
29 // Get the access tokens
31 each(servers
, function (server
, callbackEach
) {
32 loginUtils
.loginAndGetAccessToken(server
, function (err
, accessToken
) {
33 if (err
) return callbackEach(err
)
35 server
.accessToken
= accessToken
43 it('Should not transcode video on server 1', function (done
) {
46 const videoAttributes
= {
47 name: 'my super name for pod 1',
48 description: 'my super description for pod 1',
49 fixture: 'video_short.webm'
51 videosUtils
.uploadVideo(servers
[0].url
, servers
[0].accessToken
, videoAttributes
, function (err
) {
54 setTimeout(function () {
55 videosUtils
.getVideosList(servers
[0].url
, function (err
, res
) {
58 const video
= res
.body
.data
[0]
59 expect(video
.magnetUri
).to
.match(/\.webm/)
61 webtorrent
.add(video
.magnetUri
, function (torrent
) {
62 expect(torrent
.files
).to
.exist
63 expect(torrent
.files
.length
).to
.equal(1)
64 expect(torrent
.files
[0].path
).match(/\.webm$/)
73 it('Should transcode video on server 2', function (done
) {
76 const videoAttributes
= {
77 name: 'my super name for pod 2',
78 description: 'my super description for pod 2',
79 fixture: 'video_short.webm'
81 videosUtils
.uploadVideo(servers
[1].url
, servers
[1].accessToken
, videoAttributes
, function (err
) {
84 setTimeout(function () {
85 videosUtils
.getVideosList(servers
[1].url
, function (err
, res
) {
88 const video
= res
.body
.data
[0]
89 expect(video
.magnetUri
).to
.match(/\.mp4/)
91 webtorrent
.add(video
.magnetUri
, function (torrent
) {
92 expect(torrent
.files
).to
.exist
93 expect(torrent
.files
.length
).to
.equal(1)
94 expect(torrent
.files
[0].path
).match(/\.mp4$/)
103 after(function (done
) {
104 servers
.forEach(function (server
) {
105 process
.kill(-server
.app
.pid
)
108 // Keep the logs if the test failed
110 serversUtils
.flushTests(done
)