]>
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 const magnetUri
= video
.files
[0].magnetUri
60 expect(magnetUri
).to
.match(/\.webm/)
62 webtorrent
.add(magnetUri
, function (torrent
) {
63 expect(torrent
.files
).to
.exist
64 expect(torrent
.files
.length
).to
.equal(1)
65 expect(torrent
.files
[0].path
).match(/\.webm$/)
74 it('Should transcode video on server 2', function (done
) {
77 const videoAttributes
= {
78 name: 'my super name for pod 2',
79 description: 'my super description for pod 2',
80 fixture: 'video_short.webm'
82 videosUtils
.uploadVideo(servers
[1].url
, servers
[1].accessToken
, videoAttributes
, function (err
) {
85 setTimeout(function () {
86 videosUtils
.getVideosList(servers
[1].url
, function (err
, res
) {
89 const video
= res
.body
.data
[0]
90 const magnetUri
= video
.files
[0].magnetUri
91 expect(magnetUri
).to
.match(/\.mp4/)
93 webtorrent
.add(magnetUri
, function (torrent
) {
94 expect(torrent
.files
).to
.exist
95 expect(torrent
.files
.length
).to
.equal(1)
96 expect(torrent
.files
[0].path
).match(/\.mp4$/)
105 after(function (done
) {
106 servers
.forEach(function (server
) {
107 process
.kill(-server
.app
.pid
)
110 // Keep the logs if the test failed
112 serversUtils
.flushTests(done
)