aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/index.js1
-rw-r--r--server/tests/api/video-transcoder.js115
2 files changed, 116 insertions, 0 deletions
diff --git a/server/tests/api/index.js b/server/tests/api/index.js
index 7ae18f674..cc86a3d3b 100644
--- a/server/tests/api/index.js
+++ b/server/tests/api/index.js
@@ -11,3 +11,4 @@ require('./video-blacklist')
11require('./multiple-pods') 11require('./multiple-pods')
12require('./requests') 12require('./requests')
13require('./friends-advanced') 13require('./friends-advanced')
14require('./video-transcoder')
diff --git a/server/tests/api/video-transcoder.js b/server/tests/api/video-transcoder.js
new file mode 100644
index 000000000..3ff7b230a
--- /dev/null
+++ b/server/tests/api/video-transcoder.js
@@ -0,0 +1,115 @@
1/* eslint-disable no-unused-expressions */
2
3'use strict'
4
5const chai = require('chai')
6const each = require('async/each')
7const expect = chai.expect
8const series = require('async/series')
9const webtorrent = new (require('webtorrent'))()
10
11const loginUtils = require('../utils/login')
12const serversUtils = require('../utils/servers')
13const videosUtils = require('../utils/videos')
14
15describe('Test video blacklists', function () {
16 let servers = []
17
18 before(function (done) {
19 this.timeout(30000)
20
21 series([
22 // Run servers
23 function (next) {
24 serversUtils.flushAndRunMultipleServers(2, function (serversRun) {
25 servers = serversRun
26 next()
27 })
28 },
29 // Get the access tokens
30 function (next) {
31 each(servers, function (server, callbackEach) {
32 loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
33 if (err) return callbackEach(err)
34
35 server.accessToken = accessToken
36 callbackEach()
37 })
38 }, next)
39 }
40 ], done)
41 })
42
43 it('Should not transcode video on server 1', function (done) {
44 this.timeout(60000)
45
46 const videoAttributes = {
47 name: 'my super name for pod 1',
48 description: 'my super description for pod 1',
49 fixture: 'video_short.webm'
50 }
51 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, function (err) {
52 if (err) throw err
53
54 setTimeout(function () {
55 videosUtils.getVideosList(servers[0].url, function (err, res) {
56 if (err) throw err
57
58 const video = res.body.data[0]
59 expect(video.magnetUri).to.match(/\.webm/)
60
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$/)
65
66 done()
67 })
68 })
69 }, 30000)
70 })
71 })
72
73 it('Should transcode video on server 2', function (done) {
74 this.timeout(60000)
75
76 const videoAttributes = {
77 name: 'my super name for pod 2',
78 description: 'my super description for pod 2',
79 fixture: 'video_short.webm'
80 }
81 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, function (err) {
82 if (err) throw err
83
84 setTimeout(function () {
85 videosUtils.getVideosList(servers[1].url, function (err, res) {
86 if (err) throw err
87
88 const video = res.body.data[0]
89 expect(video.magnetUri).to.match(/\.mp4/)
90
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$/)
95
96 done()
97 })
98 })
99 }, 30000)
100 })
101 })
102
103 after(function (done) {
104 servers.forEach(function (server) {
105 process.kill(-server.app.pid)
106 })
107
108 // Keep the logs if the test failed
109 if (this.ok) {
110 serversUtils.flushTests(done)
111 } else {
112 done()
113 }
114 })
115})