Fix tests
This commit is contained in:
parent
71bdad9f5e
commit
8e644dedb2
|
@ -42,8 +42,8 @@ async function checkStoryboard (options: {
|
||||||
expect(storyboard.storyboardPath).to.exist
|
expect(storyboard.storyboardPath).to.exist
|
||||||
|
|
||||||
if (tilesCount) {
|
if (tilesCount) {
|
||||||
expect(storyboard.totalWidth).to.equal(spriteWidth * Math.min(tilesCount, 10))
|
expect(storyboard.totalWidth).to.equal(spriteWidth * Math.min(tilesCount, 11))
|
||||||
expect(storyboard.totalHeight).to.equal(spriteHeight * Math.max((tilesCount / 10), 1))
|
expect(storyboard.totalHeight).to.equal(spriteHeight * Math.max((tilesCount / 11), 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
const { body } = await makeGetRequest({ url: server.url, path: storyboard.storyboardPath, expectedStatus: HttpStatusCode.OK_200 })
|
const { body } = await makeGetRequest({ url: server.url, path: storyboard.storyboardPath, expectedStatus: HttpStatusCode.OK_200 })
|
||||||
|
@ -86,7 +86,7 @@ describe('Test video storyboard', function () {
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
await checkStoryboard({ server, uuid, spriteDuration: 2, spriteHeight: 154, tilesCount: 60 })
|
await checkStoryboard({ server, uuid, spriteDuration: 2, spriteHeight: 154, tilesCount: 66 })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
import { pathExists, remove } from 'fs-extra/esm'
|
import { wait } from '@peertube/peertube-core-utils'
|
||||||
import { readdir, rmdir } from 'fs/promises'
|
import { FileStorage, LiveVideoLatencyMode, LiveVideoLatencyModeType, VideoState } from '@peertube/peertube-models'
|
||||||
import { basename, join } from 'path'
|
|
||||||
import { LiveVideoLatencyMode, LiveVideoLatencyModeType, FileStorage, VideoState } from '@peertube/peertube-models'
|
|
||||||
import { logger } from '@server/helpers/logger.js'
|
import { logger } from '@server/helpers/logger.js'
|
||||||
import { VIDEO_LIVE } from '@server/initializers/constants.js'
|
import { VIDEO_LIVE } from '@server/initializers/constants.js'
|
||||||
import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js'
|
import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js'
|
||||||
|
import { pathExists, remove, } from 'fs-extra/esm'
|
||||||
|
import { readdir, rmdir } from 'fs/promises'
|
||||||
|
import { basename, join } from 'path'
|
||||||
import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage/index.js'
|
import { listHLSFileKeysOf, removeHLSFileObjectStorageByFullKey, removeHLSObjectStorage } from '../object-storage/index.js'
|
||||||
import { getLiveDirectory, getLiveReplayBaseDirectory } from '../paths.js'
|
import { getLiveDirectory, getLiveReplayBaseDirectory } from '../paths.js'
|
||||||
|
|
||||||
function buildConcatenatedName (segmentOrPlaylistPath: string) {
|
export function buildConcatenatedName (segmentOrPlaylistPath: string) {
|
||||||
const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/)
|
const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/)
|
||||||
|
|
||||||
return 'concat-' + num[1] + '.ts'
|
return 'concat-' + num[1] + '.ts'
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanupAndDestroyPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
export async function cleanupAndDestroyPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
||||||
await cleanupTMPLiveFiles(video, streamingPlaylist)
|
await cleanupTMPLiveFiles(video, streamingPlaylist)
|
||||||
|
|
||||||
if (video.state === VideoState.WAITING_FOR_LIVE) {
|
if (video.state === VideoState.WAITING_FOR_LIVE) {
|
||||||
|
@ -22,6 +23,7 @@ async function cleanupAndDestroyPermanentLive (video: MVideo, streamingPlaylist:
|
||||||
// Object storage doesn't have the concept of directories so we don't need to duplicate the logic here
|
// Object storage doesn't have the concept of directories so we don't need to duplicate the logic here
|
||||||
try {
|
try {
|
||||||
await rmdir(getLiveReplayBaseDirectory(video))
|
await rmdir(getLiveReplayBaseDirectory(video))
|
||||||
|
await wait(100)
|
||||||
await rmdir(getLiveDirectory(video))
|
await rmdir(getLiveDirectory(video))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.debug('Cannot cleanup permanent local live files', { err })
|
logger.debug('Cannot cleanup permanent local live files', { err })
|
||||||
|
@ -31,7 +33,7 @@ async function cleanupAndDestroyPermanentLive (video: MVideo, streamingPlaylist:
|
||||||
await streamingPlaylist.destroy()
|
await streamingPlaylist.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
export async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
||||||
const hlsDirectory = getLiveDirectory(video)
|
const hlsDirectory = getLiveDirectory(video)
|
||||||
|
|
||||||
// We uploaded files to object storage too, remove them
|
// We uploaded files to object storage too, remove them
|
||||||
|
@ -44,13 +46,13 @@ async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStre
|
||||||
await streamingPlaylist.destroy()
|
await streamingPlaylist.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanupTMPLiveFiles (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
export async function cleanupTMPLiveFiles (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
|
||||||
await cleanupTMPLiveFilesFromObjectStorage(streamingPlaylist.withVideo(video))
|
await cleanupTMPLiveFilesFromObjectStorage(streamingPlaylist.withVideo(video))
|
||||||
|
|
||||||
await cleanupTMPLiveFilesFromFilesystem(video)
|
await cleanupTMPLiveFilesFromFilesystem(video)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLiveSegmentTime (latencyMode: LiveVideoLatencyModeType) {
|
export function getLiveSegmentTime (latencyMode: LiveVideoLatencyModeType) {
|
||||||
if (latencyMode === LiveVideoLatencyMode.SMALL_LATENCY) {
|
if (latencyMode === LiveVideoLatencyMode.SMALL_LATENCY) {
|
||||||
return VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY
|
return VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY
|
||||||
}
|
}
|
||||||
|
@ -58,14 +60,8 @@ function getLiveSegmentTime (latencyMode: LiveVideoLatencyModeType) {
|
||||||
return VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY
|
return VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
// ---------------------------------------------------------------------------
|
||||||
cleanupAndDestroyPermanentLive,
|
// Private
|
||||||
cleanupUnsavedNormalLive,
|
|
||||||
cleanupTMPLiveFiles,
|
|
||||||
getLiveSegmentTime,
|
|
||||||
buildConcatenatedName
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function isTMPLiveFile (name: string) {
|
function isTMPLiveFile (name: string) {
|
||||||
|
|
Loading…
Reference in New Issue