]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
09209296 | 2 | |
3545e72c C |
3 | import { join } from 'path' |
4 | import { checkDirectoryIsEmpty, checkTmpIsEmpty, completeCheckHlsPlaylist } from '@server/tests/shared' | |
9ab330b9 | 5 | import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' |
3545e72c | 6 | import { HttpStatusCode } from '@shared/models' |
c55e3d72 | 7 | import { |
7243f84d | 8 | cleanupTests, |
254d3579 | 9 | createMultipleServers, |
4c7e60bc | 10 | doubleFollow, |
0305db28 | 11 | ObjectStorageCommand, |
254d3579 | 12 | PeerTubeServer, |
a1587156 | 13 | setAccessTokensToServers, |
3545e72c | 14 | waitJobs |
bf54587a | 15 | } from '@shared/server-commands' |
b345a804 | 16 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
09209296 | 17 | |
09209296 | 18 | describe('Test HLS videos', function () { |
254d3579 | 19 | let servers: PeerTubeServer[] = [] |
09209296 | 20 | |
0305db28 | 21 | function runTestSuite (hlsOnly: boolean, objectStorageBaseUrl?: string) { |
3545e72c | 22 | const videoUUIDs: string[] = [] |
dd0ebb71 | 23 | |
d7a25329 C |
24 | it('Should upload a video and transcode it to HLS', async function () { |
25 | this.timeout(120000) | |
09209296 | 26 | |
89d241a7 | 27 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) |
3545e72c | 28 | videoUUIDs.push(uuid) |
09209296 | 29 | |
d7a25329 | 30 | await waitJobs(servers) |
09209296 | 31 | |
3545e72c | 32 | await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl }) |
d7a25329 | 33 | }) |
09209296 | 34 | |
d7a25329 C |
35 | it('Should upload an audio file and transcode it to HLS', async function () { |
36 | this.timeout(120000) | |
09209296 | 37 | |
89d241a7 | 38 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) |
3545e72c | 39 | videoUUIDs.push(uuid) |
09209296 | 40 | |
d7a25329 | 41 | await waitJobs(servers) |
09209296 | 42 | |
3545e72c | 43 | await completeCheckHlsPlaylist({ |
0305db28 | 44 | servers, |
3545e72c | 45 | videoUUID: uuid, |
0305db28 JB |
46 | hlsOnly, |
47 | resolutions: [ DEFAULT_AUDIO_RESOLUTION, 360, 240 ], | |
48 | objectStorageBaseUrl | |
49 | }) | |
d7a25329 | 50 | }) |
09209296 | 51 | |
d7a25329 | 52 | it('Should update the video', async function () { |
cbb1d46b | 53 | this.timeout(30000) |
b345a804 | 54 | |
3545e72c | 55 | await servers[0].videos.update({ id: videoUUIDs[0], attributes: { name: 'video 1 updated' } }) |
b345a804 | 56 | |
d7a25329 | 57 | await waitJobs(servers) |
b345a804 | 58 | |
3545e72c | 59 | await completeCheckHlsPlaylist({ servers, videoUUID: videoUUIDs[0], hlsOnly, objectStorageBaseUrl }) |
d7a25329 | 60 | }) |
b345a804 | 61 | |
d7a25329 | 62 | it('Should delete videos', async function () { |
3545e72c C |
63 | for (const uuid of videoUUIDs) { |
64 | await servers[0].videos.remove({ id: uuid }) | |
65 | } | |
09209296 | 66 | |
d7a25329 | 67 | await waitJobs(servers) |
09209296 | 68 | |
d7a25329 | 69 | for (const server of servers) { |
3545e72c C |
70 | for (const uuid of videoUUIDs) { |
71 | await server.videos.get({ id: uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | |
72 | } | |
d7a25329 C |
73 | } |
74 | }) | |
09209296 | 75 | |
d7a25329 C |
76 | it('Should have the playlists/segment deleted from the disk', async function () { |
77 | for (const server of servers) { | |
3545e72c C |
78 | await checkDirectoryIsEmpty(server, 'videos', [ 'private' ]) |
79 | await checkDirectoryIsEmpty(server, join('videos', 'private')) | |
80 | ||
81 | await checkDirectoryIsEmpty(server, join('streaming-playlists', 'hls'), [ 'private' ]) | |
82 | await checkDirectoryIsEmpty(server, join('streaming-playlists', 'hls', 'private')) | |
d7a25329 C |
83 | } |
84 | }) | |
80b8ad2a | 85 | |
d7a25329 C |
86 | it('Should have an empty tmp directory', async function () { |
87 | for (const server of servers) { | |
88 | await checkTmpIsEmpty(server) | |
89 | } | |
90 | }) | |
91 | } | |
09209296 | 92 | |
d7a25329 C |
93 | before(async function () { |
94 | this.timeout(120000) | |
09209296 | 95 | |
d7a25329 C |
96 | const configOverride = { |
97 | transcoding: { | |
98 | enabled: true, | |
99 | allow_audio_files: true, | |
100 | hls: { | |
101 | enabled: true | |
102 | } | |
103 | } | |
09209296 | 104 | } |
254d3579 | 105 | servers = await createMultipleServers(2, configOverride) |
d7a25329 C |
106 | |
107 | // Get the access tokens | |
108 | await setAccessTokensToServers(servers) | |
109 | ||
110 | // Server 1 and server 2 follow each other | |
111 | await doubleFollow(servers[0], servers[1]) | |
09209296 C |
112 | }) |
113 | ||
d7a25329 C |
114 | describe('With WebTorrent & HLS enabled', function () { |
115 | runTestSuite(false) | |
09209296 C |
116 | }) |
117 | ||
d7a25329 C |
118 | describe('With only HLS enabled', function () { |
119 | ||
120 | before(async function () { | |
89d241a7 | 121 | await servers[0].config.updateCustomSubConfig({ |
65e6e260 C |
122 | newConfig: { |
123 | transcoding: { | |
124 | enabled: true, | |
125 | allowAudioFiles: true, | |
126 | resolutions: { | |
8dd754c7 | 127 | '144p': false, |
65e6e260 C |
128 | '240p': true, |
129 | '360p': true, | |
130 | '480p': true, | |
131 | '720p': true, | |
132 | '1080p': true, | |
133 | '1440p': true, | |
134 | '2160p': true | |
135 | }, | |
136 | hls: { | |
137 | enabled: true | |
138 | }, | |
139 | webtorrent: { | |
140 | enabled: false | |
141 | } | |
d7a25329 C |
142 | } |
143 | } | |
144 | }) | |
145 | }) | |
146 | ||
147 | runTestSuite(true) | |
09209296 C |
148 | }) |
149 | ||
0305db28 | 150 | describe('With object storage enabled', function () { |
9ab330b9 | 151 | if (areMockObjectStorageTestsDisabled()) return |
0305db28 | 152 | |
f8918990 C |
153 | const objectStorage = new ObjectStorageCommand() |
154 | ||
0305db28 JB |
155 | before(async function () { |
156 | this.timeout(120000) | |
157 | ||
f8918990 C |
158 | const configOverride = objectStorage.getDefaultMockConfig() |
159 | await objectStorage.prepareDefaultMockBuckets() | |
0305db28 JB |
160 | |
161 | await servers[0].kill() | |
162 | await servers[0].run(configOverride) | |
163 | }) | |
164 | ||
f8918990 C |
165 | runTestSuite(true, objectStorage.getMockPlaylistBaseUrl()) |
166 | ||
167 | after(async function () { | |
168 | await objectStorage.cleanupMock() | |
169 | }) | |
0305db28 JB |
170 | }) |
171 | ||
7c3b7976 C |
172 | after(async function () { |
173 | await cleanupTests(servers) | |
09209296 C |
174 | }) |
175 | }) |