aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-10 10:28:46 +0100
committerChocobozzz <me@florianbigard.com>2021-12-10 10:28:46 +0100
commit90701ec1d8d27d0072d6b0d2b19362d471484f9a (patch)
treea03dedc7b6119d9f6d2ea35cae9b2dde20275519 /server/tests/cli
parent0fbc0dec59684527fad8772080a8e1f928c07ea1 (diff)
downloadPeerTube-90701ec1d8d27d0072d6b0d2b19362d471484f9a.tar.gz
PeerTube-90701ec1d8d27d0072d6b0d2b19362d471484f9a.tar.zst
PeerTube-90701ec1d8d27d0072d6b0d2b19362d471484f9a.zip
Add hls to prune storage script
Diffstat (limited to 'server/tests/cli')
-rw-r--r--server/tests/cli/prune-storage.ts49
1 files changed, 14 insertions, 35 deletions
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
36 } 36 }
37} 37}
38 38
39async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: string) { 39async function assertCountAreOkay (servers: PeerTubeServer[]) {
40 for (const server of servers) { 40 for (const server of servers) {
41 const videosCount = await countFiles(server, 'videos') 41 const videosCount = await countFiles(server, 'videos')
42 expect(videosCount).to.equal(8) 42 expect(videosCount).to.equal(8)
@@ -52,22 +52,16 @@ async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID:
52 52
53 const avatarsCount = await countFiles(server, 'avatars') 53 const avatarsCount = await countFiles(server, 'avatars')
54 expect(avatarsCount).to.equal(2) 54 expect(avatarsCount).to.equal(2)
55 }
56
57 // When we'll prune HLS directories too
58 // const hlsRootCount = await countFiles(servers[1], 'streaming-playlists/hls/')
59 // expect(hlsRootCount).to.equal(2)
60 55
61 // const hlsCount = await countFiles(servers[1], 'streaming-playlists/hls/' + videoServer2UUID) 56 const hlsRootCount = await countFiles(server, 'streaming-playlists/hls')
62 // expect(hlsCount).to.equal(10) 57 expect(hlsRootCount).to.equal(2)
58 }
63} 59}
64 60
65describe('Test prune storage scripts', function () { 61describe('Test prune storage scripts', function () {
66 let servers: PeerTubeServer[] 62 let servers: PeerTubeServer[]
67 const badNames: { [directory: string]: string[] } = {} 63 const badNames: { [directory: string]: string[] } = {}
68 64
69 let videoServer2UUID: string
70
71 before(async function () { 65 before(async function () {
72 this.timeout(120000) 66 this.timeout(120000)
73 67
@@ -77,9 +71,7 @@ describe('Test prune storage scripts', function () {
77 71
78 for (const server of servers) { 72 for (const server of servers) {
79 await server.videos.upload({ attributes: { name: 'video 1' } }) 73 await server.videos.upload({ attributes: { name: 'video 1' } })
80 74 await server.videos.upload({ attributes: { name: 'video 2' } })
81 const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } })
82 if (server.serverNumber === 2) videoServer2UUID = uuid
83 75
84 await server.users.updateMyAvatar({ fixture: 'avatar.png' }) 76 await server.users.updateMyAvatar({ fixture: 'avatar.png' })
85 77
@@ -123,7 +115,7 @@ describe('Test prune storage scripts', function () {
123 }) 115 })
124 116
125 it('Should have the files on the disk', async function () { 117 it('Should have the files on the disk', async function () {
126 await assertCountAreOkay(servers, videoServer2UUID) 118 await assertCountAreOkay(servers)
127 }) 119 })
128 120
129 it('Should create some dirty files', async function () { 121 it('Should create some dirty files', async function () {
@@ -188,27 +180,14 @@ describe('Test prune storage scripts', function () {
188 badNames['avatars'] = [ n1, n2 ] 180 badNames['avatars'] = [ n1, n2 ]
189 } 181 }
190 182
191 // When we'll prune HLS directories too 183 {
192 // { 184 const directory = join('streaming-playlists', 'hls')
193 // const directory = join('streaming-playlists', 'hls') 185 const base = servers[0].servers.buildDirectory(directory)
194 // const base = servers[1].servers.buildDirectory(directory)
195
196 // const n1 = buildUUID()
197 // await createFile(join(base, n1))
198 // badNames[directory] = [ n1 ]
199 // }
200
201 // {
202 // const directory = join('streaming-playlists', 'hls', videoServer2UUID)
203 // const base = servers[1].servers.buildDirectory(directory)
204 // const n1 = buildUUID() + '-240-fragmented-.mp4'
205 // const n2 = buildUUID() + '-master.m3u8'
206
207 // await createFile(join(base, n1))
208 // await createFile(join(base, n2))
209 186
210 // badNames[directory] = [ n1, n2 ] 187 const n1 = buildUUID()
211 // } 188 await createFile(join(base, n1))
189 badNames[directory] = [ n1 ]
190 }
212 } 191 }
213 }) 192 })
214 193
@@ -220,7 +199,7 @@ describe('Test prune storage scripts', function () {
220 }) 199 })
221 200
222 it('Should have removed files', async function () { 201 it('Should have removed files', async function () {
223 await assertCountAreOkay(servers, videoServer2UUID) 202 await assertCountAreOkay(servers)
224 203
225 for (const directory of Object.keys(badNames)) { 204 for (const directory of Object.keys(badNames)) {
226 for (const name of badNames[directory]) { 205 for (const name of badNames[directory]) {