X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Ftests%2Fshared%2Flive.ts;h=31f92ef19a568b5c5396d58d31eba97784b9924a;hb=d102de1b38f2877463529c3b27bd35ffef4fd8bf;hp=47e0dc481e6f6b35e6cf51db1431eb6af4f0fe90;hpb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 47e0dc481..31f92ef19 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts @@ -3,8 +3,10 @@ import { expect } from 'chai' import { pathExists, readdir } from 'fs-extra' import { join } from 'path' +import { sha1 } from '@shared/extra-utils' import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' +import { SQLCommand } from './sql-command' import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' async function checkLiveCleanup (options: { @@ -35,15 +37,28 @@ async function checkLiveCleanup (options: { // --------------------------------------------------------------------------- -async function testVideoResolutions (options: { +async function testLiveVideoResolutions (options: { + sqlCommand: SQLCommand originServer: PeerTubeServer + servers: PeerTubeServer[] liveVideoId: string resolutions: number[] transcoded: boolean + objectStorage: boolean + objectStorageBaseUrl?: string }) { - const { originServer, servers, liveVideoId, resolutions, transcoded, objectStorage } = options + const { + originServer, + sqlCommand, + servers, + liveVideoId, + resolutions, + transcoded, + objectStorage, + objectStorageBaseUrl = ObjectStorageCommand.getMockPlaylistBaseUrl() + } = options for (const server of servers) { const { data } = await server.videos.list() @@ -65,7 +80,7 @@ async function testVideoResolutions (options: { }) if (objectStorage) { - expect(hlsPlaylist.playlistUrl).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) + expect(hlsPlaylist.playlistUrl).to.contain(objectStorageBaseUrl) } for (let i = 0; i < resolutions.length; i++) { @@ -76,15 +91,16 @@ async function testVideoResolutions (options: { videoUUID: video.uuid, playlistNumber: i, segment: segmentNum, - objectStorage + objectStorage, + objectStorageBaseUrl }) const baseUrl = objectStorage - ? ObjectStorageCommand.getMockPlaylistBaseUrl() + 'hls' + ? join(objectStorageBaseUrl, 'hls') : originServer.url + '/static/streaming-playlists/hls' if (objectStorage) { - expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getMockPlaylistBaseUrl()) + expect(hlsPlaylist.segmentsSha256Url).to.contain(objectStorageBaseUrl) } const subPlaylist = await originServer.streamingPlaylists.get({ @@ -101,6 +117,13 @@ async function testVideoResolutions (options: { segmentName, hlsPlaylist }) + + if (originServer.internalServerNumber === server.internalServerNumber) { + const infohash = sha1(`${2 + hlsPlaylist.playlistUrl}+V${i}`) + const dbInfohashes = await sqlCommand.getPlaylistInfohash(hlsPlaylist.id) + + expect(dbInfohashes).to.include(infohash) + } } } } @@ -109,7 +132,7 @@ async function testVideoResolutions (options: { export { checkLiveCleanup, - testVideoResolutions + testLiveVideoResolutions } // ---------------------------------------------------------------------------