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