]>
Commit | Line | Data |
---|---|---|
fdbda9e3 C |
1 | import 'mocha' |
2 | import * as chai from 'chai' | |
3 | const expect = chai.expect | |
4 | ||
5 | import { | |
6 | execCLI, | |
7 | flushTests, | |
8 | getEnvCli, | |
9 | getVideosList, | |
10 | killallServers, | |
11 | parseTorrentVideo, | |
12 | runServer, | |
13 | ServerInfo, | |
14 | setAccessTokensToServers, | |
40298b02 | 15 | uploadVideo, |
5f04dd2f C |
16 | wait, |
17 | getVideo | |
fdbda9e3 C |
18 | } from '../utils' |
19 | ||
20 | describe('Test update host scripts', function () { | |
21 | let server: ServerInfo | |
22 | ||
23 | before(async function () { | |
40298b02 | 24 | this.timeout(60000) |
fdbda9e3 C |
25 | |
26 | await flushTests() | |
27 | ||
28 | const overrideConfig = { | |
29 | webserver: { | |
30 | port: 9256 | |
31 | } | |
32 | } | |
40298b02 C |
33 | // Run server 2 to have transcoding enabled |
34 | server = await runServer(2, overrideConfig) | |
fdbda9e3 C |
35 | await setAccessTokensToServers([ server ]) |
36 | ||
37 | // Upload two videos for our needs | |
38 | const videoAttributes = {} | |
39 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
40 | await uploadVideo(server.url, server.accessToken, videoAttributes) | |
40298b02 | 41 | await wait(30000) |
fdbda9e3 C |
42 | }) |
43 | ||
44 | it('Should update torrent hosts', async function () { | |
e95561cd | 45 | this.timeout(30000) |
fdbda9e3 C |
46 | |
47 | killallServers([ server ]) | |
40298b02 C |
48 | // Run server with standard configuration |
49 | server = await runServer(2) | |
fdbda9e3 C |
50 | |
51 | const env = getEnvCli(server) | |
52 | await execCLI(`${env} npm run update-host`) | |
53 | ||
54 | const res = await getVideosList(server.url) | |
55 | const videos = res.body.data | |
40298b02 | 56 | expect(videos).to.have.lengthOf(2) |
fdbda9e3 | 57 | |
40298b02 | 58 | for (const video of videos) { |
5f04dd2f C |
59 | const res2 = await getVideo(server.url, video.id) |
60 | const videoDetails = res2.body | |
fdbda9e3 | 61 | |
5f04dd2f C |
62 | expect(videoDetails.files).to.have.lengthOf(4) |
63 | ||
64 | for (const file of videoDetails.files) { | |
40298b02 C |
65 | expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') |
66 | expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') | |
fdbda9e3 | 67 | |
5f04dd2f | 68 | const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution) |
40298b02 C |
69 | expect(torrent.announce[0]).to.equal('ws://localhost:9002/tracker/socket') |
70 | expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') | |
71 | } | |
72 | } | |
fdbda9e3 C |
73 | }) |
74 | ||
75 | after(async function () { | |
76 | killallServers([ server ]) | |
77 | ||
78 | // Keep the logs if the test failed | |
79 | if (this['ok']) { | |
80 | await flushTests() | |
81 | } | |
82 | }) | |
83 | }) |