aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/prune-storage.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-23 11:20:00 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-07-26 11:29:31 +0200
commit764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (patch)
tree198ca5f242c63a205a05fa4cfd6d063277c541fd /server/tests/cli/prune-storage.ts
parent83903cb65d531a6b6b91715387493ba8312b264d (diff)
downloadPeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.gz
PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.zst
PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.zip
Use random names for VOD HLS playlists
Diffstat (limited to 'server/tests/cli/prune-storage.ts')
-rw-r--r--server/tests/cli/prune-storage.ts41
1 files changed, 37 insertions, 4 deletions
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index 954a87833..2d4c02da7 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[]) { 39async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: string) {
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)
@@ -53,12 +53,21 @@ async function assertCountAreOkay (servers: PeerTubeServer[]) {
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 } 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
61 // const hlsCount = await countFiles(servers[1], 'streaming-playlists/hls/' + videoServer2UUID)
62 // expect(hlsCount).to.equal(10)
56} 63}
57 64
58describe('Test prune storage scripts', function () { 65describe('Test prune storage scripts', function () {
59 let servers: PeerTubeServer[] 66 let servers: PeerTubeServer[]
60 const badNames: { [directory: string]: string[] } = {} 67 const badNames: { [directory: string]: string[] } = {}
61 68
69 let videoServer2UUID: string
70
62 before(async function () { 71 before(async function () {
63 this.timeout(120000) 72 this.timeout(120000)
64 73
@@ -68,7 +77,9 @@ describe('Test prune storage scripts', function () {
68 77
69 for (const server of servers) { 78 for (const server of servers) {
70 await server.videos.upload({ attributes: { name: 'video 1' } }) 79 await server.videos.upload({ attributes: { name: 'video 1' } })
71 await server.videos.upload({ attributes: { name: 'video 2' } }) 80
81 const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } })
82 if (server.serverNumber === 2) videoServer2UUID = uuid
72 83
73 await server.users.updateMyAvatar({ fixture: 'avatar.png' }) 84 await server.users.updateMyAvatar({ fixture: 'avatar.png' })
74 85
@@ -112,7 +123,7 @@ describe('Test prune storage scripts', function () {
112 }) 123 })
113 124
114 it('Should have the files on the disk', async function () { 125 it('Should have the files on the disk', async function () {
115 await assertCountAreOkay(servers) 126 await assertCountAreOkay(servers, videoServer2UUID)
116 }) 127 })
117 128
118 it('Should create some dirty files', async function () { 129 it('Should create some dirty files', async function () {
@@ -176,6 +187,28 @@ describe('Test prune storage scripts', function () {
176 187
177 badNames['avatars'] = [ n1, n2 ] 188 badNames['avatars'] = [ n1, n2 ]
178 } 189 }
190
191 // When we'll prune HLS directories too
192 // {
193 // const directory = join('streaming-playlists', 'hls')
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
210 // badNames[directory] = [ n1, n2 ]
211 // }
179 } 212 }
180 }) 213 })
181 214
@@ -187,7 +220,7 @@ describe('Test prune storage scripts', function () {
187 }) 220 })
188 221
189 it('Should have removed files', async function () { 222 it('Should have removed files', async function () {
190 await assertCountAreOkay(servers) 223 await assertCountAreOkay(servers, videoServer2UUID)
191 224
192 for (const directory of Object.keys(badNames)) { 225 for (const directory of Object.keys(badNames)) {
193 for (const name of badNames[directory]) { 226 for (const name of badNames[directory]) {