aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/tests/shared/live.ts9
-rw-r--r--shared/server-commands/videos/live-command.ts11
-rw-r--r--shared/server-commands/videos/streaming-playlists-command.ts36
3 files changed, 45 insertions, 11 deletions
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
index aa79622cb..f165832fe 100644
--- a/server/tests/shared/live.ts
+++ b/server/tests/shared/live.ts
@@ -58,13 +58,16 @@ async function testVideoResolutions (options: {
58 : originServer.url + '/static/streaming-playlists/hls' 58 : originServer.url + '/static/streaming-playlists/hls'
59 59
60 if (objectStorage) { 60 if (objectStorage) {
61 // Playlist file upload 61 await originServer.live.waitUntilSegmentUpload({ playlistNumber: i, segment: segmentNum })
62 await wait(500) 62 await wait(1000)
63 63
64 expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl()) 64 expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl())
65 } 65 }
66 66
67 const subPlaylist = await originServer.streamingPlaylists.get({ url: `${baseUrl}/${video.uuid}/${i}.m3u8` }) 67 const subPlaylist = await originServer.streamingPlaylists.get({
68 url: `${baseUrl}/${video.uuid}/${i}.m3u8`,
69 withRetry: objectStorage // With object storage, the request may fail because of inconsistent data in S3
70 })
68 71
69 expect(subPlaylist).to.contain(segmentName) 72 expect(subPlaylist).to.contain(segmentName)
70 73
diff --git a/shared/server-commands/videos/live-command.ts b/shared/server-commands/videos/live-command.ts
index defae95fb..84d127db2 100644
--- a/shared/server-commands/videos/live-command.ts
+++ b/shared/server-commands/videos/live-command.ts
@@ -172,6 +172,17 @@ export class LiveCommand extends AbstractCommand {
172 return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false) 172 return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
173 } 173 }
174 174
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`
182
183 return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false)
184 }
185
175 async waitUntilReplacedByReplay (options: OverrideCommandOptions & { 186 async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
176 videoId: number | string 187 videoId: number | string
177 }) { 188 }) {
diff --git a/shared/server-commands/videos/streaming-playlists-command.ts b/shared/server-commands/videos/streaming-playlists-command.ts
index 7f923d001..25e446e72 100644
--- a/shared/server-commands/videos/streaming-playlists-command.ts
+++ b/shared/server-commands/videos/streaming-playlists-command.ts
@@ -1,19 +1,39 @@
1import { wait } from '@shared/core-utils'
1import { HttpStatusCode } from '@shared/models' 2import { HttpStatusCode } from '@shared/models'
2import { unwrapBody, unwrapTextOrDecode, unwrapBodyOrDecodeToJSON } from '../requests' 3import { unwrapBody, unwrapBodyOrDecodeToJSON, unwrapTextOrDecode } from '../requests'
3import { AbstractCommand, OverrideCommandOptions } from '../shared' 4import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 5
5export class StreamingPlaylistsCommand extends AbstractCommand { 6export class StreamingPlaylistsCommand extends AbstractCommand {
6 7
7 get (options: OverrideCommandOptions & { 8 async get (options: OverrideCommandOptions & {
8 url: string 9 url: string
10 withRetry?: boolean // default false
11 currentRetry?: number
9 }) { 12 }) {
10 return unwrapTextOrDecode(this.getRawRequest({ 13 const { withRetry, currentRetry = 1 } = options
11 ...options,
12 14
13 url: options.url, 15 try {
14 implicitToken: false, 16 const result = await unwrapTextOrDecode(this.getRawRequest({
15 defaultExpectedStatus: HttpStatusCode.OK_200 17 ...options,
16 })) 18
19 url: options.url,
20 implicitToken: false,
21 defaultExpectedStatus: HttpStatusCode.OK_200
22 }))
23
24 return result
25 } catch (err) {
26 if (!withRetry || currentRetry > 5) throw err
27
28 await wait(100)
29
30 return this.get({
31 ...options,
32
33 withRetry,
34 currentRetry: currentRetry + 1
35 })
36 }
17 } 37 }
18 38
19 getFragmentedSegment (options: OverrideCommandOptions & { 39 getFragmentedSegment (options: OverrideCommandOptions & {