]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
adcaf1a8 | 2 | |
fdbda9e3 C |
3 | import 'mocha' |
4 | import * as chai from 'chai' | |
5d00a3d7 | 5 | import { VideoDetails } from '../../../shared/models/videos' |
94565d52 C |
6 | import { waitJobs } from '../../../shared/extra-utils/server/jobs' |
7 | import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' | |
fdbda9e3 | 8 | import { |
23687332 | 9 | addVideoChannel, |
7c3b7976 | 10 | cleanupTests, |
23687332 | 11 | createUser, |
fdbda9e3 | 12 | execCLI, |
7c3b7976 | 13 | flushAndRunServer, |
fdbda9e3 | 14 | getEnvCli, |
3cd0734f | 15 | getVideo, |
23687332 | 16 | getVideoChannelsList, |
fdbda9e3 C |
17 | getVideosList, |
18 | killallServers, | |
23687332 | 19 | makeActivityPubGetRequest, |
7c3b7976 | 20 | parseTorrentVideo, reRunServer, |
fdbda9e3 C |
21 | ServerInfo, |
22 | setAccessTokensToServers, | |
3cd0734f | 23 | uploadVideo |
94565d52 C |
24 | } from '../../../shared/extra-utils' |
25 | import { getAccountsList } from '../../../shared/extra-utils/users/accounts' | |
3cd0734f C |
26 | |
27 | const expect = chai.expect | |
fdbda9e3 C |
28 | |
29 | describe('Test update host scripts', function () { | |
30 | let server: ServerInfo | |
31 | ||
32 | before(async function () { | |
40298b02 | 33 | this.timeout(60000) |
fdbda9e3 | 34 | |
fdbda9e3 C |
35 | const overrideConfig = { |
36 | webserver: { | |
37 | port: 9256 | |
38 | } | |
39 | } | |
40298b02 | 40 | // Run server 2 to have transcoding enabled |
210feb6c | 41 | server = await flushAndRunServer(2, overrideConfig) |
fdbda9e3 C |
42 | await setAccessTokensToServers([ server ]) |
43 | ||
44 | // Upload two videos for our needs | |
45 | const videoAttributes = {} | |
23687332 C |
46 | const resVideo1 = await uploadVideo(server.url, server.accessToken, videoAttributes) |
47 | const video1UUID = resVideo1.body.video.uuid | |
fdbda9e3 | 48 | await uploadVideo(server.url, server.accessToken, videoAttributes) |
23687332 C |
49 | |
50 | // Create a user | |
1eddc9a7 | 51 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'toto', password: 'coucou' }) |
23687332 C |
52 | |
53 | // Create channel | |
54 | const videoChannel = { | |
8a19bee1 | 55 | name: 'second_channel', |
23687332 C |
56 | displayName: 'second video channel', |
57 | description: 'super video channel description' | |
58 | } | |
59 | await addVideoChannel(server.url, server.accessToken, videoChannel) | |
60 | ||
61 | // Create comments | |
62 | const text = 'my super first comment' | |
63 | await addVideoCommentThread(server.url, server.accessToken, video1UUID, text) | |
3cd0734f C |
64 | |
65 | await waitJobs(server) | |
fdbda9e3 C |
66 | }) |
67 | ||
23687332 | 68 | it('Should run update host', async function () { |
e95561cd | 69 | this.timeout(30000) |
fdbda9e3 C |
70 | |
71 | killallServers([ server ]) | |
40298b02 | 72 | // Run server with standard configuration |
7c3b7976 | 73 | await reRunServer(server) |
fdbda9e3 C |
74 | |
75 | const env = getEnvCli(server) | |
76 | await execCLI(`${env} npm run update-host`) | |
23687332 C |
77 | }) |
78 | ||
79 | it('Should have updated videos url', async function () { | |
80 | const res = await getVideosList(server.url) | |
81 | expect(res.body.total).to.equal(2) | |
82 | ||
83 | for (const video of res.body.data) { | |
84 | const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid) | |
85 | ||
86 | expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) | |
09209296 C |
87 | |
88 | const res = await getVideo(server.url, video.uuid) | |
89 | const videoDetails: VideoDetails = res.body | |
90 | ||
91 | expect(videoDetails.trackerUrls[0]).to.include(server.host) | |
92 | expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host) | |
93 | expect(videoDetails.streamingPlaylists[0].segmentsSha256Url).to.include(server.host) | |
23687332 C |
94 | } |
95 | }) | |
96 | ||
97 | it('Should have updated video channels url', async function () { | |
98 | const res = await getVideoChannelsList(server.url, 0, 5, '-name') | |
99 | expect(res.body.total).to.equal(3) | |
100 | ||
101 | for (const channel of res.body.data) { | |
240085d0 | 102 | const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) |
23687332 | 103 | |
240085d0 | 104 | expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) |
23687332 C |
105 | } |
106 | }) | |
107 | ||
09209296 | 108 | it('Should have updated accounts url', async function () { |
23687332 C |
109 | const res = await getAccountsList(server.url) |
110 | expect(res.body.total).to.equal(3) | |
111 | ||
112 | for (const account of res.body.data) { | |
113 | const usernameWithDomain = account.name | |
114 | const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain) | |
115 | ||
116 | expect(body.id).to.equal('http://localhost:9002/accounts/' + usernameWithDomain) | |
117 | } | |
118 | }) | |
119 | ||
09209296 | 120 | it('Should have updated torrent hosts', async function () { |
23687332 | 121 | this.timeout(30000) |
fdbda9e3 C |
122 | |
123 | const res = await getVideosList(server.url) | |
124 | const videos = res.body.data | |
40298b02 | 125 | expect(videos).to.have.lengthOf(2) |
fdbda9e3 | 126 | |
40298b02 | 127 | for (const video of videos) { |
5f04dd2f | 128 | const res2 = await getVideo(server.url, video.id) |
5d00a3d7 | 129 | const videoDetails: VideoDetails = res2.body |
fdbda9e3 | 130 | |
5f04dd2f C |
131 | expect(videoDetails.files).to.have.lengthOf(4) |
132 | ||
133 | for (const file of videoDetails.files) { | |
40298b02 C |
134 | expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') |
135 | expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') | |
fdbda9e3 | 136 | |
5d00a3d7 | 137 | const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id) |
adcaf1a8 C |
138 | const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') |
139 | expect(announceWS).to.not.be.undefined | |
140 | ||
141 | const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce') | |
142 | expect(announceHttp).to.not.be.undefined | |
143 | ||
40298b02 C |
144 | expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') |
145 | } | |
146 | } | |
fdbda9e3 C |
147 | }) |
148 | ||
7c3b7976 C |
149 | after(async function () { |
150 | await cleanupTests([ server ]) | |
fdbda9e3 C |
151 | }) |
152 | }) |