1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
6 areObjectStorageTestsDisabled,
14 setAccessTokensToServers,
15 setDefaultVideoChannel,
17 } from '@shared/extra-utils'
18 import { HttpStatusCode, VideoPrivacy } from '@shared/models'
20 const expect = chai.expect
22 async function importVideo (server: PeerTubeServer) {
25 privacy: VideoPrivacy.PUBLIC,
26 channelId: server.store.channel.id,
27 targetUrl: FIXTURE_URLS.goodVideo720
30 const { video: { uuid } } = await server.imports.importVideo({ attributes })
35 describe('Object storage for video import', function () {
36 if (areObjectStorageTestsDisabled()) return
38 let server: PeerTubeServer
40 before(async function () {
43 await ObjectStorageCommand.prepareDefaultBuckets()
45 server = await createSingleServer(1, ObjectStorageCommand.getDefaultConfig())
47 await setAccessTokensToServers([ server ])
48 await setDefaultVideoChannel([ server ])
50 await server.config.enableImports()
53 describe('Without transcoding', async function () {
55 before(async function () {
56 await server.config.disableTranscoding()
59 it('Should import a video and have sent it to object storage', async function () {
62 const uuid = await importVideo(server)
63 await waitJobs(server)
65 const video = await server.videos.get({ id: uuid })
67 expect(video.files).to.have.lengthOf(1)
68 expect(video.streamingPlaylists).to.have.lengthOf(0)
70 const fileUrl = video.files[0].fileUrl
71 expectStartWith(fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
73 await makeRawRequest(fileUrl, HttpStatusCode.OK_200)
77 describe('With transcoding', async function () {
79 before(async function () {
80 await server.config.enableTranscoding()
83 it('Should import a video and have sent it to object storage', async function () {
86 const uuid = await importVideo(server)
87 await waitJobs(server)
89 const video = await server.videos.get({ id: uuid })
91 expect(video.files).to.have.lengthOf(4)
92 expect(video.streamingPlaylists).to.have.lengthOf(1)
93 expect(video.streamingPlaylists[0].files).to.have.lengthOf(4)
95 for (const file of video.files) {
96 expectStartWith(file.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
98 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
101 for (const file of video.streamingPlaylists[0].files) {
102 expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
104 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
109 after(async function () {
110 await killallServers([ server ])