]>
Commit | Line | Data |
---|---|---|
0305db28 JB |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
86347717 | 3 | import { expect } from 'chai' |
c55e3d72 | 4 | import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared' |
9ab330b9 | 5 | import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' |
c55e3d72 | 6 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
0305db28 | 7 | import { |
0305db28 | 8 | createSingleServer, |
0305db28 JB |
9 | killallServers, |
10 | makeRawRequest, | |
11 | ObjectStorageCommand, | |
12 | PeerTubeServer, | |
13 | setAccessTokensToServers, | |
14 | setDefaultVideoChannel, | |
15 | waitJobs | |
bf54587a | 16 | } from '@shared/server-commands' |
0305db28 | 17 | |
0305db28 JB |
18 | async function importVideo (server: PeerTubeServer) { |
19 | const attributes = { | |
20 | name: 'import 2', | |
21 | privacy: VideoPrivacy.PUBLIC, | |
22 | channelId: server.store.channel.id, | |
23 | targetUrl: FIXTURE_URLS.goodVideo720 | |
24 | } | |
25 | ||
26 | const { video: { uuid } } = await server.imports.importVideo({ attributes }) | |
27 | ||
28 | return uuid | |
29 | } | |
30 | ||
31 | describe('Object storage for video import', function () { | |
9ab330b9 | 32 | if (areMockObjectStorageTestsDisabled()) return |
0305db28 JB |
33 | |
34 | let server: PeerTubeServer | |
35 | ||
36 | before(async function () { | |
37 | this.timeout(120000) | |
38 | ||
9ab330b9 | 39 | await ObjectStorageCommand.prepareDefaultMockBuckets() |
0305db28 | 40 | |
9ab330b9 | 41 | server = await createSingleServer(1, ObjectStorageCommand.getDefaultMockConfig()) |
0305db28 JB |
42 | |
43 | await setAccessTokensToServers([ server ]) | |
44 | await setDefaultVideoChannel([ server ]) | |
45 | ||
46 | await server.config.enableImports() | |
47 | }) | |
48 | ||
49 | describe('Without transcoding', async function () { | |
50 | ||
51 | before(async function () { | |
52 | await server.config.disableTranscoding() | |
53 | }) | |
54 | ||
55 | it('Should import a video and have sent it to object storage', async function () { | |
56 | this.timeout(120000) | |
57 | ||
58 | const uuid = await importVideo(server) | |
59 | await waitJobs(server) | |
60 | ||
61 | const video = await server.videos.get({ id: uuid }) | |
62 | ||
63 | expect(video.files).to.have.lengthOf(1) | |
64 | expect(video.streamingPlaylists).to.have.lengthOf(0) | |
65 | ||
66 | const fileUrl = video.files[0].fileUrl | |
9ab330b9 | 67 | expectStartWith(fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) |
0305db28 | 68 | |
3545e72c | 69 | await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
0305db28 JB |
70 | }) |
71 | }) | |
72 | ||
73 | describe('With transcoding', async function () { | |
74 | ||
75 | before(async function () { | |
76 | await server.config.enableTranscoding() | |
77 | }) | |
78 | ||
79 | it('Should import a video and have sent it to object storage', async function () { | |
80 | this.timeout(120000) | |
81 | ||
82 | const uuid = await importVideo(server) | |
83 | await waitJobs(server) | |
84 | ||
85 | const video = await server.videos.get({ id: uuid }) | |
86 | ||
8dd754c7 | 87 | expect(video.files).to.have.lengthOf(5) |
0305db28 | 88 | expect(video.streamingPlaylists).to.have.lengthOf(1) |
8dd754c7 | 89 | expect(video.streamingPlaylists[0].files).to.have.lengthOf(5) |
0305db28 JB |
90 | |
91 | for (const file of video.files) { | |
9ab330b9 | 92 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) |
0305db28 | 93 | |
3545e72c | 94 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
0305db28 JB |
95 | } |
96 | ||
97 | for (const file of video.streamingPlaylists[0].files) { | |
9ab330b9 | 98 | expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl()) |
0305db28 | 99 | |
3545e72c | 100 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) |
0305db28 JB |
101 | } |
102 | }) | |
103 | }) | |
104 | ||
105 | after(async function () { | |
106 | await killallServers([ server ]) | |
107 | }) | |
108 | }) |