diff options
Diffstat (limited to 'server/tests/api/object-storage/videos.ts')
-rw-r--r-- | server/tests/api/object-storage/videos.ts | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/server/tests/api/object-storage/videos.ts b/server/tests/api/object-storage/videos.ts index 6aaf32c34..e90753d09 100644 --- a/server/tests/api/object-storage/videos.ts +++ b/server/tests/api/object-storage/videos.ts | |||
@@ -6,12 +6,15 @@ import { stat } from 'fs-extra' | |||
6 | import { merge } from 'lodash' | 6 | import { merge } from 'lodash' |
7 | import { | 7 | import { |
8 | checkTmpIsEmpty, | 8 | checkTmpIsEmpty, |
9 | checkWebTorrentWorks, | ||
9 | expectLogDoesNotContain, | 10 | expectLogDoesNotContain, |
10 | expectStartWith, | 11 | expectStartWith, |
11 | generateHighBitrateVideo, | 12 | generateHighBitrateVideo, |
12 | MockObjectStorageProxy | 13 | MockObjectStorageProxy, |
14 | SQLCommand | ||
13 | } from '@server/tests/shared' | 15 | } from '@server/tests/shared' |
14 | import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' | 16 | import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' |
17 | import { sha1 } from '@shared/extra-utils' | ||
15 | import { HttpStatusCode, VideoDetails } from '@shared/models' | 18 | import { HttpStatusCode, VideoDetails } from '@shared/models' |
16 | import { | 19 | import { |
17 | cleanupTests, | 20 | cleanupTests, |
@@ -23,14 +26,13 @@ import { | |||
23 | ObjectStorageCommand, | 26 | ObjectStorageCommand, |
24 | PeerTubeServer, | 27 | PeerTubeServer, |
25 | setAccessTokensToServers, | 28 | setAccessTokensToServers, |
26 | waitJobs, | 29 | waitJobs |
27 | webtorrentAdd | ||
28 | } from '@shared/server-commands' | 30 | } from '@shared/server-commands' |
29 | import { sha1 } from '@shared/extra-utils' | ||
30 | 31 | ||
31 | async function checkFiles (options: { | 32 | async function checkFiles (options: { |
32 | server: PeerTubeServer | 33 | server: PeerTubeServer |
33 | originServer: PeerTubeServer | 34 | originServer: PeerTubeServer |
35 | originSQLCommand: SQLCommand | ||
34 | 36 | ||
35 | video: VideoDetails | 37 | video: VideoDetails |
36 | 38 | ||
@@ -45,6 +47,7 @@ async function checkFiles (options: { | |||
45 | const { | 47 | const { |
46 | server, | 48 | server, |
47 | originServer, | 49 | originServer, |
50 | originSQLCommand, | ||
48 | video, | 51 | video, |
49 | playlistBucket, | 52 | playlistBucket, |
50 | webtorrentBucket, | 53 | webtorrentBucket, |
@@ -104,7 +107,7 @@ async function checkFiles (options: { | |||
104 | 107 | ||
105 | if (originServer.internalServerNumber === server.internalServerNumber) { | 108 | if (originServer.internalServerNumber === server.internalServerNumber) { |
106 | const infohash = sha1(`${2 + hls.playlistUrl}+V${i}`) | 109 | const infohash = sha1(`${2 + hls.playlistUrl}+V${i}`) |
107 | const dbInfohashes = await originServer.sql.getPlaylistInfohash(hls.id) | 110 | const dbInfohashes = await originSQLCommand.getPlaylistInfohash(hls.id) |
108 | 111 | ||
109 | expect(dbInfohashes).to.include(infohash) | 112 | expect(dbInfohashes).to.include(infohash) |
110 | } | 113 | } |
@@ -114,11 +117,7 @@ async function checkFiles (options: { | |||
114 | } | 117 | } |
115 | 118 | ||
116 | for (const file of allFiles) { | 119 | for (const file of allFiles) { |
117 | const torrent = await webtorrentAdd(file.magnetUri, true) | 120 | await checkWebTorrentWorks(file.magnetUri) |
118 | |||
119 | expect(torrent.files).to.be.an('array') | ||
120 | expect(torrent.files.length).to.equal(1) | ||
121 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | ||
122 | 121 | ||
123 | const res = await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | 122 | const res = await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
124 | expect(res.body).to.have.length.above(100) | 123 | expect(res.body).to.have.length.above(100) |
@@ -145,6 +144,7 @@ function runTestSuite (options: { | |||
145 | let baseMockUrl: string | 144 | let baseMockUrl: string |
146 | 145 | ||
147 | let servers: PeerTubeServer[] | 146 | let servers: PeerTubeServer[] |
147 | let sqlCommands: SQLCommand[] | ||
148 | 148 | ||
149 | let keptUrls: string[] = [] | 149 | let keptUrls: string[] = [] |
150 | 150 | ||
@@ -202,6 +202,8 @@ function runTestSuite (options: { | |||
202 | const files = await server.videos.listFiles({ id: uuid }) | 202 | const files = await server.videos.listFiles({ id: uuid }) |
203 | keptUrls = keptUrls.concat(files.map(f => f.fileUrl)) | 203 | keptUrls = keptUrls.concat(files.map(f => f.fileUrl)) |
204 | } | 204 | } |
205 | |||
206 | sqlCommands = servers.map(s => new SQLCommand(s)) | ||
205 | }) | 207 | }) |
206 | 208 | ||
207 | it('Should upload a video and move it to the object storage without transcoding', async function () { | 209 | it('Should upload a video and move it to the object storage without transcoding', async function () { |
@@ -214,7 +216,7 @@ function runTestSuite (options: { | |||
214 | 216 | ||
215 | for (const server of servers) { | 217 | for (const server of servers) { |
216 | const video = await server.videos.get({ id: uuid }) | 218 | const video = await server.videos.get({ id: uuid }) |
217 | const files = await checkFiles({ ...options, server, originServer: servers[0], video, baseMockUrl }) | 219 | const files = await checkFiles({ ...options, server, originServer: servers[0], originSQLCommand: sqlCommands[0], video, baseMockUrl }) |
218 | 220 | ||
219 | deletedUrls = deletedUrls.concat(files) | 221 | deletedUrls = deletedUrls.concat(files) |
220 | } | 222 | } |
@@ -230,7 +232,7 @@ function runTestSuite (options: { | |||
230 | 232 | ||
231 | for (const server of servers) { | 233 | for (const server of servers) { |
232 | const video = await server.videos.get({ id: uuid }) | 234 | const video = await server.videos.get({ id: uuid }) |
233 | const files = await checkFiles({ ...options, server, originServer: servers[0], video, baseMockUrl }) | 235 | const files = await checkFiles({ ...options, server, originServer: servers[0], originSQLCommand: sqlCommands[0], video, baseMockUrl }) |
234 | 236 | ||
235 | deletedUrls = deletedUrls.concat(files) | 237 | deletedUrls = deletedUrls.concat(files) |
236 | } | 238 | } |
@@ -274,6 +276,10 @@ function runTestSuite (options: { | |||
274 | after(async function () { | 276 | after(async function () { |
275 | await mockObjectStorageProxy.terminate() | 277 | await mockObjectStorageProxy.terminate() |
276 | 278 | ||
279 | for (const sqlCommand of sqlCommands) { | ||
280 | await sqlCommand.cleanup() | ||
281 | } | ||
282 | |||
277 | await cleanupTests(servers) | 283 | await cleanupTests(servers) |
278 | }) | 284 | }) |
279 | } | 285 | } |