diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-22 08:46:55 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-22 08:55:14 +0200 |
commit | 13e13377918b65c30b9334920fef4b43e70b964e (patch) | |
tree | a2e01e845d32663cbf4dbe1fd4be7f3fcf4244db /server | |
parent | 7c94e1e7b61e9d3cff4a98a90bbad8d85bfc145d (diff) | |
download | PeerTube-13e13377918b65c30b9334920fef4b43e70b964e.tar.gz PeerTube-13e13377918b65c30b9334920fef4b43e70b964e.tar.zst PeerTube-13e13377918b65c30b9334920fef4b43e70b964e.zip |
Speed up plugin transcoding tests
Diffstat (limited to 'server')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js | 7 | ||||
-rw-r--r-- | server/tests/fixtures/video_very_short_240p.mp4 | bin | 0 -> 9352 bytes | |||
-rw-r--r-- | server/tests/plugins/plugin-transcoding.ts | 152 |
3 files changed, 82 insertions, 77 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js b/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js index 59b136947..c4ae777f5 100644 --- a/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js +++ b/server/tests/fixtures/peertube-plugin-test-transcoding-one/main.js | |||
@@ -18,12 +18,12 @@ async function register ({ transcodingManager }) { | |||
18 | const builder = (options) => { | 18 | const builder = (options) => { |
19 | return { | 19 | return { |
20 | outputOptions: [ | 20 | outputOptions: [ |
21 | '-r:' + options.streamNum + ' 5' | 21 | '-r:' + options.streamNum + ' 50' |
22 | ] | 22 | ] |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | transcodingManager.addLiveProfile('libx264', 'low-live', builder) | 26 | transcodingManager.addLiveProfile('libx264', 'high-live', builder) |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
@@ -45,7 +45,7 @@ async function register ({ transcodingManager }) { | |||
45 | const builder = () => { | 45 | const builder = () => { |
46 | return { | 46 | return { |
47 | inputOptions: [ | 47 | inputOptions: [ |
48 | '-r 5' | 48 | '-r 50' |
49 | ] | 49 | ] |
50 | } | 50 | } |
51 | } | 51 | } |
@@ -82,7 +82,6 @@ async function register ({ transcodingManager }) { | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | |||
86 | async function unregister () { | 85 | async function unregister () { |
87 | return | 86 | return |
88 | } | 87 | } |
diff --git a/server/tests/fixtures/video_very_short_240p.mp4 b/server/tests/fixtures/video_very_short_240p.mp4 new file mode 100644 index 000000000..95b6be92a --- /dev/null +++ b/server/tests/fixtures/video_very_short_240p.mp4 | |||
Binary files differ | |||
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index 0bf1fab01..c14c34c7e 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts | |||
@@ -110,119 +110,125 @@ describe('Test transcoding plugins', function () { | |||
110 | const config = await server.config.getConfig() | 110 | const config = await server.config.getConfig() |
111 | 111 | ||
112 | expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) | 112 | expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) |
113 | expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ]) | 113 | expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'high-live', 'input-options-live', 'bad-scale-live' ]) |
114 | }) | 114 | }) |
115 | 115 | ||
116 | it('Should not use the plugin profile if not chosen by the admin', async function () { | 116 | describe('VOD', function () { |
117 | this.timeout(240000) | ||
118 | 117 | ||
119 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | 118 | it('Should not use the plugin profile if not chosen by the admin', async function () { |
120 | await waitJobs([ server ]) | 119 | this.timeout(240000) |
121 | 120 | ||
122 | await checkVideoFPS(videoUUID, 'above', 20) | 121 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid |
123 | }) | 122 | await waitJobs([ server ]) |
124 | 123 | ||
125 | it('Should use the vod profile', async function () { | 124 | await checkVideoFPS(videoUUID, 'above', 20) |
126 | this.timeout(240000) | 125 | }) |
127 | 126 | ||
128 | await updateConf(server, 'low-vod', 'default') | 127 | it('Should use the vod profile', async function () { |
128 | this.timeout(240000) | ||
129 | 129 | ||
130 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | 130 | await updateConf(server, 'low-vod', 'default') |
131 | await waitJobs([ server ]) | ||
132 | 131 | ||
133 | await checkVideoFPS(videoUUID, 'below', 12) | 132 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid |
134 | }) | 133 | await waitJobs([ server ]) |
135 | 134 | ||
136 | it('Should apply input options in vod profile', async function () { | 135 | await checkVideoFPS(videoUUID, 'below', 12) |
137 | this.timeout(240000) | 136 | }) |
138 | 137 | ||
139 | await updateConf(server, 'input-options-vod', 'default') | 138 | it('Should apply input options in vod profile', async function () { |
139 | this.timeout(240000) | ||
140 | 140 | ||
141 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | 141 | await updateConf(server, 'input-options-vod', 'default') |
142 | await waitJobs([ server ]) | ||
143 | 142 | ||
144 | await checkVideoFPS(videoUUID, 'below', 6) | 143 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid |
145 | }) | 144 | await waitJobs([ server ]) |
146 | 145 | ||
147 | it('Should apply the scale filter in vod profile', async function () { | 146 | await checkVideoFPS(videoUUID, 'below', 6) |
148 | this.timeout(240000) | 147 | }) |
149 | 148 | ||
150 | await updateConf(server, 'bad-scale-vod', 'default') | 149 | it('Should apply the scale filter in vod profile', async function () { |
150 | this.timeout(240000) | ||
151 | 151 | ||
152 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | 152 | await updateConf(server, 'bad-scale-vod', 'default') |
153 | await waitJobs([ server ]) | 153 | |
154 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | ||
155 | await waitJobs([ server ]) | ||
154 | 156 | ||
155 | // Transcoding failed | 157 | // Transcoding failed |
156 | const video = await server.videos.get({ id: videoUUID }) | 158 | const video = await server.videos.get({ id: videoUUID }) |
157 | expect(video.files).to.have.lengthOf(1) | 159 | expect(video.files).to.have.lengthOf(1) |
158 | expect(video.streamingPlaylists).to.have.lengthOf(0) | 160 | expect(video.streamingPlaylists).to.have.lengthOf(0) |
161 | }) | ||
159 | }) | 162 | }) |
160 | 163 | ||
161 | it('Should not use the plugin profile if not chosen by the admin', async function () { | 164 | describe('Live', function () { |
162 | this.timeout(240000) | ||
163 | 165 | ||
164 | const liveVideoId = await createLiveWrapper(server) | 166 | it('Should not use the plugin profile if not chosen by the admin', async function () { |
167 | this.timeout(240000) | ||
165 | 168 | ||
166 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | 169 | const liveVideoId = await createLiveWrapper(server) |
167 | await server.live.waitUntilPublished({ videoId: liveVideoId }) | ||
168 | await waitJobs([ server ]) | ||
169 | 170 | ||
170 | await checkLiveFPS(liveVideoId, 'above', 20) | 171 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }) |
171 | }) | 172 | await server.live.waitUntilPublished({ videoId: liveVideoId }) |
173 | await waitJobs([ server ]) | ||
172 | 174 | ||
173 | it('Should use the live profile', async function () { | 175 | await checkLiveFPS(liveVideoId, 'above', 20) |
174 | this.timeout(240000) | 176 | }) |
175 | 177 | ||
176 | await updateConf(server, 'low-vod', 'low-live') | 178 | it('Should use the live profile', async function () { |
179 | this.timeout(240000) | ||
177 | 180 | ||
178 | const liveVideoId = await createLiveWrapper(server) | 181 | await updateConf(server, 'low-vod', 'high-live') |
179 | 182 | ||
180 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | 183 | const liveVideoId = await createLiveWrapper(server) |
181 | await server.live.waitUntilPublished({ videoId: liveVideoId }) | ||
182 | await waitJobs([ server ]) | ||
183 | 184 | ||
184 | await checkLiveFPS(liveVideoId, 'below', 12) | 185 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }) |
185 | }) | 186 | await server.live.waitUntilPublished({ videoId: liveVideoId }) |
187 | await waitJobs([ server ]) | ||
186 | 188 | ||
187 | it('Should apply the input options on live profile', async function () { | 189 | await checkLiveFPS(liveVideoId, 'above', 45) |
188 | this.timeout(240000) | 190 | }) |
189 | 191 | ||
190 | await updateConf(server, 'low-vod', 'input-options-live') | 192 | it('Should apply the input options on live profile', async function () { |
193 | this.timeout(240000) | ||
191 | 194 | ||
192 | const liveVideoId = await createLiveWrapper(server) | 195 | await updateConf(server, 'low-vod', 'input-options-live') |
193 | 196 | ||
194 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | 197 | const liveVideoId = await createLiveWrapper(server) |
195 | await server.live.waitUntilPublished({ videoId: liveVideoId }) | ||
196 | await waitJobs([ server ]) | ||
197 | 198 | ||
198 | await checkLiveFPS(liveVideoId, 'below', 6) | 199 | await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }) |
199 | }) | 200 | await server.live.waitUntilPublished({ videoId: liveVideoId }) |
201 | await waitJobs([ server ]) | ||
200 | 202 | ||
201 | it('Should apply the scale filter name on live profile', async function () { | 203 | await checkLiveFPS(liveVideoId, 'above', 45) |
202 | this.timeout(240000) | 204 | }) |
203 | 205 | ||
204 | await updateConf(server, 'low-vod', 'bad-scale-live') | 206 | it('Should apply the scale filter name on live profile', async function () { |
207 | this.timeout(240000) | ||
205 | 208 | ||
206 | const liveVideoId = await createLiveWrapper(server) | 209 | await updateConf(server, 'low-vod', 'bad-scale-live') |
207 | 210 | ||
208 | const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) | 211 | const liveVideoId = await createLiveWrapper(server) |
209 | await testFfmpegStreamError(command, true) | ||
210 | }) | ||
211 | 212 | ||
212 | it('Should default to the default profile if the specified profile does not exist', async function () { | 213 | const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_very_short_240p.mp4' }) |
213 | this.timeout(240000) | 214 | await testFfmpegStreamError(command, true) |
215 | }) | ||
214 | 216 | ||
215 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) | 217 | it('Should default to the default profile if the specified profile does not exist', async function () { |
218 | this.timeout(240000) | ||
216 | 219 | ||
217 | const config = await server.config.getConfig() | 220 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) |
218 | 221 | ||
219 | expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) | 222 | const config = await server.config.getConfig() |
220 | expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) | ||
221 | 223 | ||
222 | const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid | 224 | expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) |
223 | await waitJobs([ server ]) | 225 | expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) |
226 | |||
227 | const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid | ||
228 | await waitJobs([ server ]) | ||
224 | 229 | ||
225 | await checkVideoFPS(videoUUID, 'above', 20) | 230 | await checkVideoFPS(videoUUID, 'above', 20) |
231 | }) | ||
226 | }) | 232 | }) |
227 | 233 | ||
228 | }) | 234 | }) |
@@ -238,7 +244,7 @@ describe('Test transcoding plugins', function () { | |||
238 | it('Should use the new vod encoders', async function () { | 244 | it('Should use the new vod encoders', async function () { |
239 | this.timeout(240000) | 245 | this.timeout(240000) |
240 | 246 | ||
241 | const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid | 247 | const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_very_short_240p.mp4' })).uuid |
242 | await waitJobs([ server ]) | 248 | await waitJobs([ server ]) |
243 | 249 | ||
244 | const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) | 250 | const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) |