aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live-save-replay.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-22 09:50:20 +0200
committerChocobozzz <me@florianbigard.com>2022-05-03 08:32:20 +0200
commit98ebfa39500ce9dfbb782e43c4d269f9a2989698 (patch)
tree8ef016f780601ddfca8f907d2a18efb2d91d3ec9 /server/tests/api/live/live-save-replay.ts
parentc74cd9feaba583fc40c61d1c3a7c036267a56ea1 (diff)
downloadPeerTube-98ebfa39500ce9dfbb782e43c4d269f9a2989698.tar.gz
PeerTube-98ebfa39500ce9dfbb782e43c4d269f9a2989698.tar.zst
PeerTube-98ebfa39500ce9dfbb782e43c4d269f9a2989698.zip
Fix getting live by anonymous user
Diffstat (limited to 'server/tests/api/live/live-save-replay.ts')
-rw-r--r--server/tests/api/live/live-save-replay.ts150
1 files changed, 50 insertions, 100 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index ba68a4287..fc6acc624 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -50,6 +50,50 @@ describe('Save replay setting', function () {
50 return uuid 50 return uuid
51 } 51 }
52 52
53 async function publishLive (options: { permanent: boolean, replay: boolean }) {
54 liveVideoUUID = await createLiveWrapper(options)
55
56 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
57 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
58
59 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
60
61 await waitJobs(servers)
62 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
63
64 return { ffmpegCommand, liveDetails }
65 }
66
67 async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean }) {
68 const { ffmpegCommand, liveDetails } = await publishLive(options)
69
70 await Promise.all([
71 servers[0].videos.remove({ id: liveVideoUUID }),
72 testFfmpegStreamError(ffmpegCommand, true)
73 ])
74
75 await waitJobs(servers)
76 await wait(5000)
77 await waitJobs(servers)
78
79 return { liveDetails }
80 }
81
82 async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean }) {
83 const { ffmpegCommand, liveDetails } = await publishLive(options)
84
85 await Promise.all([
86 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
87 testFfmpegStreamError(ffmpegCommand, true)
88 ])
89
90 await waitJobs(servers)
91 await wait(5000)
92 await waitJobs(servers)
93
94 return { liveDetails }
95 }
96
53 async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) { 97 async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) {
54 for (const server of servers) { 98 for (const server of servers) {
55 const length = existsInList ? 1 : 0 99 const length = existsInList ? 1 : 0
@@ -100,10 +144,6 @@ describe('Save replay setting', function () {
100 144
101 describe('With save replay disabled', function () { 145 describe('With save replay disabled', function () {
102 146
103 before(async function () {
104 this.timeout(10000)
105 })
106
107 it('Should correctly create and federate the "waiting for stream" live', async function () { 147 it('Should correctly create and federate the "waiting for stream" live', async function () {
108 this.timeout(20000) 148 this.timeout(20000)
109 149
@@ -149,21 +189,7 @@ describe('Save replay setting', function () {
149 it('Should correctly terminate the stream on blacklist and delete the live', async function () { 189 it('Should correctly terminate the stream on blacklist and delete the live', async function () {
150 this.timeout(40000) 190 this.timeout(40000)
151 191
152 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) 192 await publishLiveAndBlacklist({ permanent: false, replay: false })
153
154 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
155
156 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
157
158 await waitJobs(servers)
159 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
160
161 await Promise.all([
162 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
163 testFfmpegStreamError(ffmpegCommand, true)
164 ])
165
166 await waitJobs(servers)
167 193
168 await checkVideosExist(liveVideoUUID, false) 194 await checkVideosExist(liveVideoUUID, false)
169 195
@@ -178,22 +204,7 @@ describe('Save replay setting', function () {
178 it('Should correctly terminate the stream on delete and delete the video', async function () { 204 it('Should correctly terminate the stream on delete and delete the video', async function () {
179 this.timeout(40000) 205 this.timeout(40000)
180 206
181 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false }) 207 await publishLiveAndDelete({ permanent: false, replay: false })
182
183 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
184
185 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
186
187 await waitJobs(servers)
188 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
189
190 await Promise.all([
191 testFfmpegStreamError(ffmpegCommand, true),
192 servers[0].videos.remove({ id: liveVideoUUID })
193 ])
194
195 await wait(5000)
196 await waitJobs(servers)
197 208
198 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) 209 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
199 await checkLiveCleanup(servers[0], liveVideoUUID, []) 210 await checkLiveCleanup(servers[0], liveVideoUUID, [])
@@ -258,20 +269,7 @@ describe('Save replay setting', function () {
258 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { 269 it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
259 this.timeout(40000) 270 this.timeout(40000)
260 271
261 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) 272 await publishLiveAndBlacklist({ permanent: false, replay: true })
262
263 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
264 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
265
266 await waitJobs(servers)
267 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
268
269 await Promise.all([
270 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
271 testFfmpegStreamError(ffmpegCommand, true)
272 ])
273
274 await waitJobs(servers)
275 273
276 await checkVideosExist(liveVideoUUID, false) 274 await checkVideosExist(liveVideoUUID, false)
277 275
@@ -286,21 +284,7 @@ describe('Save replay setting', function () {
286 it('Should correctly terminate the stream on delete and delete the video', async function () { 284 it('Should correctly terminate the stream on delete and delete the video', async function () {
287 this.timeout(40000) 285 this.timeout(40000)
288 286
289 liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true }) 287 await publishLiveAndDelete({ permanent: false, replay: true })
290
291 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
292 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
293
294 await waitJobs(servers)
295 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
296
297 await Promise.all([
298 servers[0].videos.remove({ id: liveVideoUUID }),
299 testFfmpegStreamError(ffmpegCommand, true)
300 ])
301
302 await wait(5000)
303 await waitJobs(servers)
304 288
305 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) 289 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
306 await checkLiveCleanup(servers[0], liveVideoUUID, []) 290 await checkLiveCleanup(servers[0], liveVideoUUID, [])
@@ -361,25 +345,7 @@ describe('Save replay setting', function () {
361 this.timeout(60000) 345 this.timeout(60000)
362 346
363 await servers[0].videos.remove({ id: lastReplayUUID }) 347 await servers[0].videos.remove({ id: lastReplayUUID })
364 348 const { liveDetails } = await publishLiveAndBlacklist({ permanent: true, replay: true })
365 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true })
366
367 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
368 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
369
370 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
371
372 await waitJobs(servers)
373 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
374
375 await Promise.all([
376 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
377 testFfmpegStreamError(ffmpegCommand, true)
378 ])
379
380 await waitJobs(servers)
381 await wait(5000)
382 await waitJobs(servers)
383 349
384 const replay = await findExternalSavedVideo(servers[0], liveDetails) 350 const replay = await findExternalSavedVideo(servers[0], liveDetails)
385 expect(replay).to.exist 351 expect(replay).to.exist
@@ -397,23 +363,7 @@ describe('Save replay setting', function () {
397 it('Should correctly terminate the stream on delete and not save the video', async function () { 363 it('Should correctly terminate the stream on delete and not save the video', async function () {
398 this.timeout(40000) 364 this.timeout(40000)
399 365
400 liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) 366 const { liveDetails } = await publishLiveAndDelete({ permanent: true, replay: true })
401
402 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
403 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
404
405 const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
406
407 await waitJobs(servers)
408 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
409
410 await Promise.all([
411 servers[0].videos.remove({ id: liveVideoUUID }),
412 testFfmpegStreamError(ffmpegCommand, true)
413 ])
414
415 await wait(5000)
416 await waitJobs(servers)
417 367
418 const replay = await findExternalSavedVideo(servers[0], liveDetails) 368 const replay = await findExternalSavedVideo(servers[0], liveDetails)
419 expect(replay).to.not.exist 369 expect(replay).to.not.exist