From 90701ec1d8d27d0072d6b0d2b19362d471484f9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Dec 2021 10:28:46 +0100 Subject: Add hls to prune storage script --- server/tests/cli/prune-storage.ts | 49 +++++++++++---------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) (limited to 'server/tests') diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 2d4c02da7..1c0282da9 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -36,7 +36,7 @@ async function assertNotExists (server: PeerTubeServer, directory: string, subst } } -async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: string) { +async function assertCountAreOkay (servers: PeerTubeServer[]) { for (const server of servers) { const videosCount = await countFiles(server, 'videos') expect(videosCount).to.equal(8) @@ -52,22 +52,16 @@ async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: const avatarsCount = await countFiles(server, 'avatars') expect(avatarsCount).to.equal(2) - } - - // When we'll prune HLS directories too - // const hlsRootCount = await countFiles(servers[1], 'streaming-playlists/hls/') - // expect(hlsRootCount).to.equal(2) - // const hlsCount = await countFiles(servers[1], 'streaming-playlists/hls/' + videoServer2UUID) - // expect(hlsCount).to.equal(10) + const hlsRootCount = await countFiles(server, 'streaming-playlists/hls') + expect(hlsRootCount).to.equal(2) + } } describe('Test prune storage scripts', function () { let servers: PeerTubeServer[] const badNames: { [directory: string]: string[] } = {} - let videoServer2UUID: string - before(async function () { this.timeout(120000) @@ -77,9 +71,7 @@ describe('Test prune storage scripts', function () { for (const server of servers) { await server.videos.upload({ attributes: { name: 'video 1' } }) - - const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } }) - if (server.serverNumber === 2) videoServer2UUID = uuid + await server.videos.upload({ attributes: { name: 'video 2' } }) await server.users.updateMyAvatar({ fixture: 'avatar.png' }) @@ -123,7 +115,7 @@ describe('Test prune storage scripts', function () { }) it('Should have the files on the disk', async function () { - await assertCountAreOkay(servers, videoServer2UUID) + await assertCountAreOkay(servers) }) it('Should create some dirty files', async function () { @@ -188,27 +180,14 @@ describe('Test prune storage scripts', function () { badNames['avatars'] = [ n1, n2 ] } - // When we'll prune HLS directories too - // { - // const directory = join('streaming-playlists', 'hls') - // const base = servers[1].servers.buildDirectory(directory) - - // const n1 = buildUUID() - // await createFile(join(base, n1)) - // badNames[directory] = [ n1 ] - // } - - // { - // const directory = join('streaming-playlists', 'hls', videoServer2UUID) - // const base = servers[1].servers.buildDirectory(directory) - // const n1 = buildUUID() + '-240-fragmented-.mp4' - // const n2 = buildUUID() + '-master.m3u8' - - // await createFile(join(base, n1)) - // await createFile(join(base, n2)) + { + const directory = join('streaming-playlists', 'hls') + const base = servers[0].servers.buildDirectory(directory) - // badNames[directory] = [ n1, n2 ] - // } + const n1 = buildUUID() + await createFile(join(base, n1)) + badNames[directory] = [ n1 ] + } } }) @@ -220,7 +199,7 @@ describe('Test prune storage scripts', function () { }) it('Should have removed files', async function () { - await assertCountAreOkay(servers, videoServer2UUID) + await assertCountAreOkay(servers) for (const directory of Object.keys(badNames)) { for (const name of badNames[directory]) { -- cgit v1.2.3