aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-11 16:00:11 +0200
committerChocobozzz <me@florianbigard.com>2022-10-11 16:00:11 +0200
commitbbae45c32ea41ba4926b291fac5f594c94d5aa9d (patch)
tree44f0f15ea972f04a3caa9622e311621936cea7e5
parent8c13fd744fcb1c40f705eeceb4fbf08676d7451a (diff)
downloadPeerTube-bbae45c32ea41ba4926b291fac5f594c94d5aa9d.tar.gz
PeerTube-bbae45c32ea41ba4926b291fac5f594c94d5aa9d.tar.zst
PeerTube-bbae45c32ea41ba4926b291fac5f594c94d5aa9d.zip
Fix live tests
-rw-r--r--server/tests/api/live/live-fast-restream.ts21
-rw-r--r--server/tests/api/live/live.ts12
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts2
-rw-r--r--server/tests/shared/live.ts10
-rw-r--r--shared/server-commands/videos/live-command.ts43
5 files changed, 64 insertions, 24 deletions
diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.ts
index 3ea6be9ff..772ea792d 100644
--- a/server/tests/api/live/live-fast-restream.ts
+++ b/server/tests/api/live/live-fast-restream.ts
@@ -43,12 +43,31 @@ describe('Fast restream in live', function () {
43 // Streaming session #1 43 // Streaming session #1
44 let ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions) 44 let ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
45 await server.live.waitUntilPublished({ videoId: liveVideoUUID }) 45 await server.live.waitUntilPublished({ videoId: liveVideoUUID })
46
47 const video = await server.videos.get({ id: liveVideoUUID })
48 const session1PlaylistId = video.streamingPlaylists[0].id
49
46 await stopFfmpeg(ffmpegCommand) 50 await stopFfmpeg(ffmpegCommand)
47 await server.live.waitUntilWaiting({ videoId: liveVideoUUID }) 51 await server.live.waitUntilWaiting({ videoId: liveVideoUUID })
48 52
49 // Streaming session #2 53 // Streaming session #2
50 ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions) 54 ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
51 await server.live.waitUntilSegmentGeneration({ videoUUID: liveVideoUUID, segment: 0, playlistNumber: 0, totalSessions: 2 }) 55
56 let hasNewPlaylist = false
57 do {
58 const video = await server.videos.get({ id: liveVideoUUID })
59 hasNewPlaylist = video.streamingPlaylists.length === 1 && video.streamingPlaylists[0].id !== session1PlaylistId
60
61 await wait(100)
62 } while (!hasNewPlaylist)
63
64 await server.live.waitUntilSegmentGeneration({
65 server,
66 videoUUID: liveVideoUUID,
67 segment: 1,
68 playlistNumber: 0,
69 objectStorage: false
70 })
52 71
53 return { ffmpegCommand, liveVideoUUID } 72 return { ffmpegCommand, liveVideoUUID }
54 } 73 }
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 5dd2bd9ab..0a7ae8536 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -695,9 +695,15 @@ describe('Test live', function () {
695 commands[0].waitUntilPublished({ videoId: liveVideoReplayId }) 695 commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
696 ]) 696 ])
697 697
698 await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoId, playlistNumber: 0, segment: 2 }) 698 for (const videoUUID of [ liveVideoId, liveVideoReplayId, permanentLiveVideoReplayId ]) {
699 await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, playlistNumber: 0, segment: 2 }) 699 await commands[0].waitUntilSegmentGeneration({
700 await commands[0].waitUntilSegmentGeneration({ videoUUID: permanentLiveVideoReplayId, playlistNumber: 0, segment: 2 }) 700 server: servers[0],
701 videoUUID,
702 playlistNumber: 0,
703 segment: 2,
704 objectStorage: false
705 })
706 }
701 707
702 { 708 {
703 const video = await servers[0].videos.get({ id: permanentLiveVideoReplayId }) 709 const video = await servers[0].videos.get({ id: permanentLiveVideoReplayId })
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index fc953f144..5a632fb22 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -545,7 +545,7 @@ describe('Test moderation notifications', function () {
545 }) 545 })
546 546
547 it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () { 547 it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
548 this.timeout(40000) 548 this.timeout(120000)
549 549
550 const updateAt = new Date(new Date().getTime() + 1000000) 550 const updateAt = new Date(new Date().getTime() + 1000000)
551 551
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
index 63f3ecfd8..da3691711 100644
--- a/server/tests/shared/live.ts
+++ b/server/tests/shared/live.ts
@@ -56,15 +56,19 @@ async function testVideoResolutions (options: {
56 for (let i = 0; i < resolutions.length; i++) { 56 for (let i = 0; i < resolutions.length; i++) {
57 const segmentNum = 3 57 const segmentNum = 3
58 const segmentName = `${i}-00000${segmentNum}.ts` 58 const segmentName = `${i}-00000${segmentNum}.ts`
59 await originServer.live.waitUntilSegmentGeneration({ videoUUID: video.uuid, playlistNumber: i, segment: segmentNum }) 59 await originServer.live.waitUntilSegmentGeneration({
60 server: originServer,
61 videoUUID: video.uuid,
62 playlistNumber: i,
63 segment: segmentNum,
64 objectStorage
65 })
60 66
61 const baseUrl = objectStorage 67 const baseUrl = objectStorage
62 ? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls' 68 ? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls'
63 : originServer.url + '/static/streaming-playlists/hls' 69 : originServer.url + '/static/streaming-playlists/hls'
64 70
65 if (objectStorage) { 71 if (objectStorage) {
66 await originServer.live.waitUntilSegmentUpload({ playlistNumber: i, segment: segmentNum })
67
68 expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl()) 72 expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl())
69 } 73 }
70 74
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index 84d127db2..a0e0c7c8f 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -15,7 +15,7 @@ import {
15 VideoState 15 VideoState
16} from '@shared/models' 16} from '@shared/models'
17import { unwrapBody } from '../requests' 17import { unwrapBody } from '../requests'
18import { ObjectStorageCommand } from '../server' 18import { ObjectStorageCommand, PeerTubeServer } from '../server'
19import { AbstractCommand, OverrideCommandOptions } from '../shared' 19import { AbstractCommand, OverrideCommandOptions } from '../shared'
20import { sendRTMPStream, testFfmpegStreamError } from './live' 20import { sendRTMPStream, testFfmpegStreamError } from './live'
21 21
@@ -160,27 +160,38 @@ export class LiveCommand extends AbstractCommand {
160 return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED }) 160 return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED })
161 } 161 }
162 162
163 waitUntilSegmentGeneration (options: OverrideCommandOptions & { 163 async waitUntilSegmentGeneration (options: OverrideCommandOptions & {
164 server: PeerTubeServer
164 videoUUID: string 165 videoUUID: string
165 playlistNumber: number 166 playlistNumber: number
166 segment: number 167 segment: number
167 totalSessions?: number 168 objectStorage: boolean
168 }) { 169 }) {
169 const { playlistNumber, segment, videoUUID, totalSessions = 1 } = options 170 const { server, objectStorage, playlistNumber, segment, videoUUID } = options
170 const segmentName = `${playlistNumber}-00000${segment}.ts`
171
172 return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
173 }
174 171
175 waitUntilSegmentUpload (options: OverrideCommandOptions & {
176 playlistNumber: number
177 segment: number
178 totalSessions?: number
179 }) {
180 const { playlistNumber, segment, totalSessions = 1 } = options
181 const segmentName = `${playlistNumber}-00000${segment}.ts` 172 const segmentName = `${playlistNumber}-00000${segment}.ts`
182 173 const baseUrl = objectStorage
183 return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false) 174 ? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls'
175 : server.url + '/static/streaming-playlists/hls'
176
177 let error = true
178
179 while (error) {
180 try {
181 await this.getRawRequest({
182 ...options,
183
184 url: `${baseUrl}/${videoUUID}/${segmentName}`,
185 implicitToken: false,
186 defaultExpectedStatus: HttpStatusCode.OK_200
187 })
188
189 error = false
190 } catch {
191 error = true
192 await wait(100)
193 }
194 }
184 } 195 }
185 196
186 async waitUntilReplacedByReplay (options: OverrideCommandOptions & { 197 async waitUntilReplacedByReplay (options: OverrideCommandOptions & {