aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-11 11:25:33 +0200
committerChocobozzz <me@florianbigard.com>2023-05-11 11:41:43 +0200
commit81f14b911211be065448e92bcc253f470c5ff2a9 (patch)
treebd0ff9fc61ee4fb86ce222e7831747aa6c90752e
parentc106db14136f1701a8b1eab8d7152395225e55e4 (diff)
downloadPeerTube-81f14b911211be065448e92bcc253f470c5ff2a9.tar.gz
PeerTube-81f14b911211be065448e92bcc253f470c5ff2a9.tar.zst
PeerTube-81f14b911211be065448e92bcc253f470c5ff2a9.zip
Correctly wait for live segment generation
-rw-r--r--server/tests/api/live/live-save-replay.ts28
-rw-r--r--server/tests/api/server/bulk.ts2
-rw-r--r--server/tests/api/server/email.ts2
-rw-r--r--server/tests/api/server/handle-down.ts2
-rw-r--r--server/tests/api/server/services.ts2
-rw-r--r--server/tests/api/server/stats.ts2
-rw-r--r--shared/server-commands/videos/live-command.ts7
7 files changed, 26 insertions, 19 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 676d0af69..2a44cb5a0 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -153,7 +153,7 @@ describe('Save replay setting', function () {
153 let sessionEndDateMin: Date 153 let sessionEndDateMin: Date
154 154
155 it('Should correctly create and federate the "waiting for stream" live', async function () { 155 it('Should correctly create and federate the "waiting for stream" live', async function () {
156 this.timeout(20000) 156 this.timeout(40000)
157 157
158 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) 158 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false })
159 159
@@ -164,7 +164,7 @@ describe('Save replay setting', function () {
164 }) 164 })
165 165
166 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 166 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
167 this.timeout(30000) 167 this.timeout(40000)
168 168
169 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 169 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
170 170
@@ -253,7 +253,7 @@ describe('Save replay setting', function () {
253 describe('With save replay enabled on non permanent live', function () { 253 describe('With save replay enabled on non permanent live', function () {
254 254
255 it('Should correctly create and federate the "waiting for stream" live', async function () { 255 it('Should correctly create and federate the "waiting for stream" live', async function () {
256 this.timeout(20000) 256 this.timeout(40000)
257 257
258 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) 258 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } })
259 259
@@ -265,7 +265,7 @@ describe('Save replay setting', function () {
265 }) 265 })
266 266
267 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 267 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
268 this.timeout(20000) 268 this.timeout(40000)
269 269
270 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 270 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
271 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 271 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
@@ -278,7 +278,7 @@ describe('Save replay setting', function () {
278 }) 278 })
279 279
280 it('Should correctly have saved the live and federated it after the streaming', async function () { 280 it('Should correctly have saved the live and federated it after the streaming', async function () {
281 this.timeout(30000) 281 this.timeout(40000)
282 282
283 const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID }) 283 const session = await servers[0].live.findLatestSession({ videoId: liveVideoUUID })
284 expect(session.endDate).to.not.exist 284 expect(session.endDate).to.not.exist
@@ -319,7 +319,7 @@ describe('Save replay setting', function () {
319 }) 319 })
320 320
321 it('Should update the saved live and correctly federate the updated attributes', async function () { 321 it('Should update the saved live and correctly federate the updated attributes', async function () {
322 this.timeout(30000) 322 this.timeout(40000)
323 323
324 await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } }) 324 await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated', privacy: VideoPrivacy.PUBLIC } })
325 await waitJobs(servers) 325 await waitJobs(servers)
@@ -367,7 +367,7 @@ describe('Save replay setting', function () {
367 describe('With a first live and its replay', function () { 367 describe('With a first live and its replay', function () {
368 368
369 it('Should correctly create and federate the "waiting for stream" live', async function () { 369 it('Should correctly create and federate the "waiting for stream" live', async function () {
370 this.timeout(20000) 370 this.timeout(40000)
371 371
372 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } }) 372 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true, replaySettings: { privacy: VideoPrivacy.UNLISTED } })
373 373
@@ -379,7 +379,7 @@ describe('Save replay setting', function () {
379 }) 379 })
380 380
381 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 381 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
382 this.timeout(20000) 382 this.timeout(40000)
383 383
384 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 384 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
385 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 385 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
@@ -392,7 +392,7 @@ describe('Save replay setting', function () {
392 }) 392 })
393 393
394 it('Should correctly have saved the live and federated it after the streaming', async function () { 394 it('Should correctly have saved the live and federated it after the streaming', async function () {
395 this.timeout(30000) 395 this.timeout(40000)
396 396
397 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) 397 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
398 398
@@ -443,10 +443,11 @@ describe('Save replay setting', function () {
443 }) 443 })
444 444
445 describe('With a second live and its replay', function () { 445 describe('With a second live and its replay', function () {
446
446 it('Should update the replay settings', async function () { 447 it('Should update the replay settings', async function () {
447 await servers[0].live.update( 448 await servers[0].live.update({ videoId: liveVideoUUID, fields: { replaySettings: { privacy: VideoPrivacy.PUBLIC } } })
448 { videoId: liveVideoUUID, fields: { replaySettings: { privacy: VideoPrivacy.PUBLIC } } })
449 await waitJobs(servers) 449 await waitJobs(servers)
450
450 const live = await servers[0].live.get({ videoId: liveVideoUUID }) 451 const live = await servers[0].live.get({ videoId: liveVideoUUID })
451 452
452 expect(live.saveReplay).to.be.true 453 expect(live.saveReplay).to.be.true
@@ -456,7 +457,7 @@ describe('Save replay setting', function () {
456 }) 457 })
457 458
458 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 459 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
459 this.timeout(20000) 460 this.timeout(40000)
460 461
461 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 462 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
462 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 463 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
@@ -469,7 +470,8 @@ describe('Save replay setting', function () {
469 }) 470 })
470 471
471 it('Should correctly have saved the live and federated it after the streaming', async function () { 472 it('Should correctly have saved the live and federated it after the streaming', async function () {
472 this.timeout(30000) 473 this.timeout(40000)
474
473 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID }) 475 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
474 476
475 await stopFfmpeg(ffmpegCommand) 477 await stopFfmpeg(ffmpegCommand)
diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts
index 1fe26bb26..66d791a0f 100644
--- a/server/tests/api/server/bulk.ts
+++ b/server/tests/api/server/bulk.ts
@@ -87,7 +87,7 @@ describe('Test bulk actions', function () {
87 } 87 }
88 88
89 before(async function () { 89 before(async function () {
90 this.timeout(120000) 90 this.timeout(240000)
91 91
92 await servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } }) 92 await servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } })
93 await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } }) 93 await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index db7aa65bd..5a0bf360c 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -33,7 +33,7 @@ describe('Test emails', function () {
33 } 33 }
34 34
35 before(async function () { 35 before(async function () {
36 this.timeout(50000) 36 this.timeout(120000)
37 37
38 const emailPort = await MockSmtpServer.Instance.collectEmails(emails) 38 const emailPort = await MockSmtpServer.Instance.collectEmails(emails)
39 server = await createSingleServer(1, ConfigCommand.getEmailOverrideConfig(emailPort)) 39 server = await createSingleServer(1, ConfigCommand.getEmailOverrideConfig(emailPort))
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 3a73ab1d2..1d524aa93 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -282,7 +282,7 @@ describe('Test handle downs', function () {
282 }) 282 })
283 283
284 it('Should upload many videos on server 1', async function () { 284 it('Should upload many videos on server 1', async function () {
285 this.timeout(120000) 285 this.timeout(240000)
286 286
287 for (let i = 0; i < 10; i++) { 287 for (let i = 0; i < 10; i++) {
288 const uuid = (await servers[0].videos.quickUpload({ name: 'video ' + i })).uuid 288 const uuid = (await servers[0].videos.quickUpload({ name: 'video ' + i })).uuid
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index 380308a34..a10e9baed 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -26,7 +26,7 @@ describe('Test services', function () {
26 ] 26 ]
27 27
28 before(async function () { 28 before(async function () {
29 this.timeout(30000) 29 this.timeout(120000)
30 30
31 server = await createSingleServer(1) 31 server = await createSingleServer(1)
32 32
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index 942cbeaa4..aad0d231a 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -232,7 +232,7 @@ describe('Test stats (excluding redundancy)', function () {
232 }) 232 })
233 233
234 it('Should have the correct AP stats', async function () { 234 it('Should have the correct AP stats', async function () {
235 this.timeout(60000) 235 this.timeout(120000)
236 236
237 await servers[0].config.disableTranscoding() 237 await servers[0].config.disableTranscoding()
238 238
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index 2e4bc10b5..73f4eefd3 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -213,6 +213,7 @@ export class LiveCommand extends AbstractCommand {
213 213
214 while (error) { 214 while (error) {
215 try { 215 try {
216 // Check fragment exists
216 await this.getRawRequest({ 217 await this.getRawRequest({
217 ...options, 218 ...options,
218 219
@@ -224,12 +225,16 @@ export class LiveCommand extends AbstractCommand {
224 const video = await server.videos.get({ id: videoUUID }) 225 const video = await server.videos.get({ id: videoUUID })
225 const hlsPlaylist = video.streamingPlaylists[0] 226 const hlsPlaylist = video.streamingPlaylists[0]
226 227
228 // Check SHA generation
227 const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: objectStorage }) 229 const shaBody = await server.streamingPlaylists.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url, withRetry: objectStorage })
228
229 if (!shaBody[segmentName]) { 230 if (!shaBody[segmentName]) {
230 throw new Error('Segment SHA does not exist') 231 throw new Error('Segment SHA does not exist')
231 } 232 }
232 233
234 // Check fragment is in m3u8 playlist
235 const subPlaylist = await server.streamingPlaylists.get({ url: `${baseUrl}/${video.uuid}/${playlistNumber}.m3u8` })
236 if (!subPlaylist.includes(segmentName)) throw new Error('Fragment does not exist in playlist')
237
233 error = false 238 error = false
234 } catch { 239 } catch {
235 error = true 240 error = true