]>
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 | import { |
7 | execCLI, | |
8 | flushTests, | |
9 | getEnvCli, | |
3cd0734f | 10 | getVideo, |
fdbda9e3 C |
11 | getVideosList, |
12 | killallServers, | |
13 | parseTorrentVideo, | |
14 | runServer, | |
15 | ServerInfo, | |
16 | setAccessTokensToServers, | |
3cd0734f | 17 | uploadVideo |
fdbda9e3 | 18 | } from '../utils' |
3cd0734f C |
19 | import { waitJobs } from '../utils/server/jobs' |
20 | ||
21 | const expect = chai.expect | |
fdbda9e3 C |
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) | |
3cd0734f C |
44 | |
45 | await waitJobs(server) | |
fdbda9e3 C |
46 | }) |
47 | ||
48 | it('Should update torrent hosts', async function () { | |
e95561cd | 49 | this.timeout(30000) |
fdbda9e3 C |
50 | |
51 | killallServers([ server ]) | |
40298b02 C |
52 | // Run server with standard configuration |
53 | server = await runServer(2) | |
fdbda9e3 C |
54 | |
55 | const env = getEnvCli(server) | |
56 | await execCLI(`${env} npm run update-host`) | |
57 | ||
58 | const res = await getVideosList(server.url) | |
59 | const videos = res.body.data | |
40298b02 | 60 | expect(videos).to.have.lengthOf(2) |
fdbda9e3 | 61 | |
40298b02 | 62 | for (const video of videos) { |
5f04dd2f | 63 | const res2 = await getVideo(server.url, video.id) |
5d00a3d7 | 64 | const videoDetails: VideoDetails = res2.body |
fdbda9e3 | 65 | |
5f04dd2f C |
66 | expect(videoDetails.files).to.have.lengthOf(4) |
67 | ||
68 | for (const file of videoDetails.files) { | |
40298b02 C |
69 | expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') |
70 | expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') | |
fdbda9e3 | 71 | |
5d00a3d7 | 72 | const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id) |
adcaf1a8 C |
73 | const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') |
74 | expect(announceWS).to.not.be.undefined | |
75 | ||
76 | const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce') | |
77 | expect(announceHttp).to.not.be.undefined | |
78 | ||
40298b02 C |
79 | expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') |
80 | } | |
81 | } | |
fdbda9e3 C |
82 | }) |
83 | ||
84 | after(async function () { | |
85 | killallServers([ server ]) | |
fdbda9e3 C |
86 | }) |
87 | }) |