aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
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
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')
-rw-r--r--server/tests/cli/optimize-old-videos.ts3
-rw-r--r--server/tests/cli/prune-storage.ts41
-rw-r--r--server/tests/cli/update-host.ts11
3 files changed, 44 insertions, 11 deletions
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 685b3b7b8..579b2e7d8 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -2,7 +2,6 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
8 createMultipleServers, 7 createMultipleServers,
@@ -86,7 +85,7 @@ describe('Test optimize old videos', function () {
86 85
87 expect(file.size).to.be.below(8000000) 86 expect(file.size).to.be.below(8000000)
88 87
89 const path = servers[0].servers.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) 88 const path = servers[0].servers.buildWebTorrentFilePath(file.fileUrl)
90 const bitrate = await getVideoFileBitrate(path) 89 const bitrate = await getVideoFileBitrate(path)
91 const fps = await getVideoFileFPS(path) 90 const fps = await getVideoFileFPS(path)
92 const resolution = await getVideoFileResolution(path) 91 const resolution = await getVideoFileResolution(path)
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]) {
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index fcbcb55ba..43fbaec30 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -108,21 +108,22 @@ describe('Test update host scripts', function () {
108 108
109 for (const video of data) { 109 for (const video of data) {
110 const videoDetails = await server.videos.get({ id: video.id }) 110 const videoDetails = await server.videos.get({ id: video.id })
111 const files = videoDetails.files.concat(videoDetails.streamingPlaylists[0].files)
111 112
112 expect(videoDetails.files).to.have.lengthOf(4) 113 expect(files).to.have.lengthOf(8)
113 114
114 for (const file of videoDetails.files) { 115 for (const file of files) {
115 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket') 116 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
116 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F') 117 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2F')
117 118
118 const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution.id) 119 const torrent = await parseTorrentVideo(server, file)
119 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket') 120 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
120 expect(announceWS).to.not.be.undefined 121 expect(announceWS).to.not.be.undefined
121 122
122 const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce') 123 const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce')
123 expect(announceHttp).to.not.be.undefined 124 expect(announceHttp).to.not.be.undefined
124 125
125 expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed') 126 expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/')
126 } 127 }
127 } 128 }
128 }) 129 })