1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* eslint-disable no-unused-expressions */
'use strict'
const chai = require('chai')
const each = require('async/each')
const expect = chai.expect
const series = require('async/series')
const webtorrent = new (require('webtorrent'))()
const loginUtils = require('../utils/login')
const serversUtils = require('../utils/servers')
const videosUtils = require('../utils/videos')
describe('Test video blacklists', function () {
let servers = []
before(function (done) {
this.timeout(30000)
series([
// Run servers
function (next) {
serversUtils.flushAndRunMultipleServers(2, function (serversRun) {
servers = serversRun
next()
})
},
// Get the access tokens
function (next) {
each(servers, function (server, callbackEach) {
loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
if (err) return callbackEach(err)
server.accessToken = accessToken
callbackEach()
})
}, next)
}
], done)
})
it('Should not transcode video on server 1', function (done) {
this.timeout(60000)
const videoAttributes = {
name: 'my super name for pod 1',
description: 'my super description for pod 1',
fixture: 'video_short.webm'
}
videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, function (err) {
if (err) throw err
setTimeout(function () {
videosUtils.getVideosList(servers[0].url, function (err, res) {
if (err) throw err
const video = res.body.data[0]
expect(video.magnetUri).to.match(/\.webm/)
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist
expect(torrent.files.length).to.equal(1)
expect(torrent.files[0].path).match(/\.webm$/)
done()
})
})
}, 30000)
})
})
it('Should transcode video on server 2', function (done) {
this.timeout(60000)
const videoAttributes = {
name: 'my super name for pod 2',
description: 'my super description for pod 2',
fixture: 'video_short.webm'
}
videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, function (err) {
if (err) throw err
setTimeout(function () {
videosUtils.getVideosList(servers[1].url, function (err, res) {
if (err) throw err
const video = res.body.data[0]
expect(video.magnetUri).to.match(/\.mp4/)
webtorrent.add(video.magnetUri, function (torrent) {
expect(torrent.files).to.exist
expect(torrent.files.length).to.equal(1)
expect(torrent.files[0].path).match(/\.mp4$/)
done()
})
})
}, 30000)
})
})
after(function (done) {
servers.forEach(function (server) {
process.kill(-server.app.pid)
})
// Keep the logs if the test failed
if (this.ok) {
serversUtils.flushTests(done)
} else {
done()
}
})
})
|