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