From bbae45c32ea41ba4926b291fac5f594c94d5aa9d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Oct 2022 16:00:11 +0200 Subject: Fix live tests --- shared/server-commands/videos/live-command.ts | 43 +++++++++++++++++---------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'shared/server-commands/videos/live-command.ts') 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 { VideoState } from '@shared/models' import { unwrapBody } from '../requests' -import { ObjectStorageCommand } from '../server' +import { ObjectStorageCommand, PeerTubeServer } from '../server' import { AbstractCommand, OverrideCommandOptions } from '../shared' import { sendRTMPStream, testFfmpegStreamError } from './live' @@ -160,27 +160,38 @@ export class LiveCommand extends AbstractCommand { return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED }) } - waitUntilSegmentGeneration (options: OverrideCommandOptions & { + async waitUntilSegmentGeneration (options: OverrideCommandOptions & { + server: PeerTubeServer videoUUID: string playlistNumber: number segment: number - totalSessions?: number + objectStorage: boolean }) { - const { playlistNumber, segment, videoUUID, totalSessions = 1 } = options - const segmentName = `${playlistNumber}-00000${segment}.ts` - - return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false) - } + const { server, objectStorage, playlistNumber, segment, videoUUID } = options - waitUntilSegmentUpload (options: OverrideCommandOptions & { - playlistNumber: number - segment: number - totalSessions?: number - }) { - const { playlistNumber, segment, totalSessions = 1 } = options const segmentName = `${playlistNumber}-00000${segment}.ts` - - return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false) + const baseUrl = objectStorage + ? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls' + : server.url + '/static/streaming-playlists/hls' + + let error = true + + while (error) { + try { + await this.getRawRequest({ + ...options, + + url: `${baseUrl}/${videoUUID}/${segmentName}`, + implicitToken: false, + defaultExpectedStatus: HttpStatusCode.OK_200 + }) + + error = false + } catch { + error = true + await wait(100) + } + } } async waitUntilReplacedByReplay (options: OverrideCommandOptions & { -- cgit v1.2.3