aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-27 08:34:16 +0100
committerChocobozzz <me@florianbigard.com>2023-01-27 08:34:16 +0100
commita2be43f5700460d3afdc194abc788690b79e66cd (patch)
tree005de26e549da0b20e1ec7bc5e293a6603cc958d /server/tests/shared
parent647c2b7d0448e68d8c8ade52d9568e9b33f8638d (diff)
parent8059e050ef4e800c95851ac97abbb2330fe17882 (diff)
downloadPeerTube-a2be43f5700460d3afdc194abc788690b79e66cd.tar.gz
PeerTube-a2be43f5700460d3afdc194abc788690b79e66cd.tar.zst
PeerTube-a2be43f5700460d3afdc194abc788690b79e66cd.zip
Merge branch 'release/5.0.0' into develop
Diffstat (limited to 'server/tests/shared')
-rw-r--r--server/tests/shared/live.ts23
-rw-r--r--server/tests/shared/mock-servers/mock-object-storage.ts2
2 files changed, 18 insertions, 7 deletions
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
index 1c868eb5b..ff0b2f226 100644
--- a/server/tests/shared/live.ts
+++ b/server/tests/shared/live.ts
@@ -3,10 +3,10 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path' 5import { join } from 'path'
6import { sha1 } from '@shared/extra-utils'
6import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' 7import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models'
7import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' 8import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands'
8import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' 9import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists'
9import { sha1 } from '@shared/extra-utils'
10 10
11async function checkLiveCleanup (options: { 11async function checkLiveCleanup (options: {
12 server: PeerTubeServer 12 server: PeerTubeServer
@@ -42,9 +42,19 @@ async function testVideoResolutions (options: {
42 liveVideoId: string 42 liveVideoId: string
43 resolutions: number[] 43 resolutions: number[]
44 transcoded: boolean 44 transcoded: boolean
45
45 objectStorage: boolean 46 objectStorage: boolean
47 objectStorageBaseUrl?: string
46}) { 48}) {
47 const { originServer, servers, liveVideoId, resolutions, transcoded, objectStorage } = options 49 const {
50 originServer,
51 servers,
52 liveVideoId,
53 resolutions,
54 transcoded,
55 objectStorage,
56 objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl()
57 } = options
48 58
49 for (const server of servers) { 59 for (const server of servers) {
50 const { data } = await server.videos.list() 60 const { data } = await server.videos.list()
@@ -66,7 +76,7 @@ async function testVideoResolutions (options: {
66 }) 76 })
67 77
68 if (objectStorage) { 78 if (objectStorage) {
69 expect(hlsPlaylist.playlistUrl).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) 79 expect(hlsPlaylist.playlistUrl).to.contain(objectStorageBaseUrl)
70 } 80 }
71 81
72 for (let i = 0; i < resolutions.length; i++) { 82 for (let i = 0; i < resolutions.length; i++) {
@@ -77,15 +87,16 @@ async function testVideoResolutions (options: {
77 videoUUID: video.uuid, 87 videoUUID: video.uuid,
78 playlistNumber: i, 88 playlistNumber: i,
79 segment: segmentNum, 89 segment: segmentNum,
80 objectStorage 90 objectStorage,
91 objectStorageBaseUrl
81 }) 92 })
82 93
83 const baseUrl = objectStorage 94 const baseUrl = objectStorage
84 ? ObjectStorageCommand.getMockPlaylistBaseUrl() + 'hls' 95 ? join(objectStorageBaseUrl, 'hls')
85 : originServer.url + '/static/streaming-playlists/hls' 96 : originServer.url + '/static/streaming-playlists/hls'
86 97
87 if (objectStorage) { 98 if (objectStorage) {
88 expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) 99 expect(hlsPlaylist.segmentsSha256Url).to.contain(objectStorageBaseUrl)
89 } 100 }
90 101
91 const subPlaylist = await originServer.streamingPlaylists.get({ 102 const subPlaylist = await originServer.streamingPlaylists.get({
diff --git a/server/tests/shared/mock-servers/mock-object-storage.ts b/server/tests/shared/mock-servers/mock-object-storage.ts
index 8c325bf11..ae76c4f3f 100644
--- a/server/tests/shared/mock-servers/mock-object-storage.ts
+++ b/server/tests/shared/mock-servers/mock-object-storage.ts
@@ -5,7 +5,7 @@ import { pipeline } from 'stream'
5import { ObjectStorageCommand } from '@shared/server-commands' 5import { ObjectStorageCommand } from '@shared/server-commands'
6import { getPort, randomListen, terminateServer } from './shared' 6import { getPort, randomListen, terminateServer } from './shared'
7 7
8export class MockObjectStorage { 8export class MockObjectStorageProxy {
9 private server: Server 9 private server: Server
10 10
11 async initialize () { 11 async initialize () {