mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Use random names for VOD HLS playlists
This commit is contained in:
@@ -4,7 +4,7 @@ import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { VideoPrivacy } from '@shared/models'
|
||||
import {
|
||||
checkLiveCleanup,
|
||||
checkLiveCleanupAfterSave,
|
||||
cleanupTests,
|
||||
ConfigCommand,
|
||||
createMultipleServers,
|
||||
@@ -43,7 +43,7 @@ describe('Test live constraints', function () {
|
||||
expect(video.duration).to.be.greaterThan(0)
|
||||
}
|
||||
|
||||
await checkLiveCleanup(servers[0], videoId, resolutions)
|
||||
await checkLiveCleanupAfterSave(servers[0], videoId, resolutions)
|
||||
}
|
||||
|
||||
async function waitUntilLivePublishedOnAllServers (videoId: string) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { FfmpegCommand } from 'fluent-ffmpeg'
|
||||
import {
|
||||
checkLiveCleanup,
|
||||
checkLiveCleanupAfterSave,
|
||||
cleanupTests,
|
||||
ConfigCommand,
|
||||
createMultipleServers,
|
||||
@@ -150,7 +150,7 @@ describe('Save replay setting', function () {
|
||||
await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
|
||||
|
||||
// No resolutions saved since we did not save replay
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
|
||||
})
|
||||
|
||||
it('Should correctly terminate the stream on blacklist and delete the live', async function () {
|
||||
@@ -179,7 +179,7 @@ describe('Save replay setting', function () {
|
||||
|
||||
await wait(5000)
|
||||
await waitJobs(servers)
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
|
||||
})
|
||||
|
||||
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
||||
@@ -203,7 +203,7 @@ describe('Save replay setting', function () {
|
||||
await waitJobs(servers)
|
||||
|
||||
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -259,7 +259,7 @@ describe('Save replay setting', function () {
|
||||
})
|
||||
|
||||
it('Should have cleaned up the live files', async function () {
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ])
|
||||
})
|
||||
|
||||
it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
|
||||
@@ -287,7 +287,7 @@ describe('Save replay setting', function () {
|
||||
|
||||
await wait(5000)
|
||||
await waitJobs(servers)
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ])
|
||||
})
|
||||
|
||||
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
||||
@@ -310,7 +310,7 @@ describe('Save replay setting', function () {
|
||||
await waitJobs(servers)
|
||||
|
||||
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { join } from 'path'
|
||||
import { basename, join } from 'path'
|
||||
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
|
||||
import {
|
||||
checkLiveCleanup,
|
||||
checkLiveCleanupAfterSave,
|
||||
checkLiveSegmentHash,
|
||||
checkResolutionsInMasterPlaylist,
|
||||
cleanupTests,
|
||||
@@ -506,6 +506,10 @@ describe('Test live', function () {
|
||||
await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200)
|
||||
await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200)
|
||||
|
||||
// We should have generated random filenames
|
||||
expect(basename(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8')
|
||||
expect(basename(hlsPlaylist.segmentsSha256Url)).to.not.equal('segments-sha256.json')
|
||||
|
||||
expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length)
|
||||
|
||||
for (const resolution of resolutions) {
|
||||
@@ -520,7 +524,9 @@ describe('Test live', function () {
|
||||
expect(file.fps).to.be.approximately(30, 2)
|
||||
}
|
||||
|
||||
const filename = `${video.uuid}-${resolution}-fragmented.mp4`
|
||||
const filename = basename(file.fileUrl)
|
||||
expect(filename).to.not.contain(video.uuid)
|
||||
|
||||
const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
|
||||
|
||||
const probe = await ffprobePromise(segmentPath)
|
||||
@@ -537,7 +543,7 @@ describe('Test live', function () {
|
||||
it('Should correctly have cleaned up the live files', async function () {
|
||||
this.timeout(30000)
|
||||
|
||||
await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ])
|
||||
await checkLiveCleanupAfterSave(servers[0], liveVideoId, [ 240, 360, 720 ])
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -58,10 +58,10 @@ describe('Test users with multiple servers', function () {
|
||||
const { uuid } = await servers[0].videos.upload({ token: userAccessToken })
|
||||
videoUUID = uuid
|
||||
|
||||
await waitJobs(servers)
|
||||
|
||||
await saveVideoInServers(servers, videoUUID)
|
||||
}
|
||||
|
||||
await waitJobs(servers)
|
||||
})
|
||||
|
||||
it('Should be able to update my display name', async function () {
|
||||
|
||||
@@ -170,8 +170,13 @@ describe('Test resumable upload', function () {
|
||||
|
||||
const size = 1000
|
||||
|
||||
// Content length check seems to have changed in v16
|
||||
const expectedStatus = process.version.startsWith('v16')
|
||||
? HttpStatusCode.CONFLICT_409
|
||||
: HttpStatusCode.BAD_REQUEST_400
|
||||
|
||||
const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}`
|
||||
await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentRangeBuilder, contentLength: size })
|
||||
await sendChunks({ pathUploadId: uploadId, expectedStatus, contentRangeBuilder, contentLength: size })
|
||||
await checkFileSize(uploadId, 0)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { join } from 'path'
|
||||
import { basename, join } from 'path'
|
||||
import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils'
|
||||
import {
|
||||
checkDirectoryIsEmpty,
|
||||
checkResolutionsInMasterPlaylist,
|
||||
@@ -19,8 +20,6 @@ import {
|
||||
} from '@shared/extra-utils'
|
||||
import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models'
|
||||
import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
|
||||
import { uuidRegex } from '@shared/core-utils'
|
||||
import { basename } from 'path/posix'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
@@ -78,11 +77,13 @@ async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, h
|
||||
// Check resolution playlists
|
||||
{
|
||||
for (const resolution of resolutions) {
|
||||
const file = hlsFiles.find(f => f.resolution.id === resolution)
|
||||
const playlistName = removeFragmentedMP4Ext(basename(file.fileUrl)) + '.m3u8'
|
||||
|
||||
const subPlaylist = await server.streamingPlaylists.get({
|
||||
url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`
|
||||
url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${playlistName}`
|
||||
})
|
||||
|
||||
const file = hlsFiles.find(f => f.resolution.id === resolution)
|
||||
expect(subPlaylist).to.match(new RegExp(`${uuidRegex}-${resolution}-fragmented.mp4`))
|
||||
expect(subPlaylist).to.contain(basename(file.fileUrl))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user