2021-08-17 01:26:20 -05:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
|
|
|
|
2022-08-17 08:44:32 -05:00
|
|
|
import { expect } from 'chai'
|
2021-12-17 04:58:15 -06:00
|
|
|
import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared'
|
2022-10-19 03:43:53 -05:00
|
|
|
import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
|
2021-12-17 04:58:15 -06:00
|
|
|
import { HttpStatusCode, VideoPrivacy } from '@shared/models'
|
2021-08-17 01:26:20 -05:00
|
|
|
import {
|
2023-05-10 06:57:06 -05:00
|
|
|
cleanupTests,
|
2021-08-17 01:26:20 -05:00
|
|
|
createSingleServer,
|
|
|
|
makeRawRequest,
|
|
|
|
ObjectStorageCommand,
|
|
|
|
PeerTubeServer,
|
|
|
|
setAccessTokensToServers,
|
|
|
|
setDefaultVideoChannel,
|
|
|
|
waitJobs
|
2021-12-17 02:29:23 -06:00
|
|
|
} from '@shared/server-commands'
|
2021-08-17 01:26:20 -05:00
|
|
|
|
|
|
|
async function importVideo (server: PeerTubeServer) {
|
|
|
|
const attributes = {
|
|
|
|
name: 'import 2',
|
|
|
|
privacy: VideoPrivacy.PUBLIC,
|
|
|
|
channelId: server.store.channel.id,
|
|
|
|
targetUrl: FIXTURE_URLS.goodVideo720
|
|
|
|
}
|
|
|
|
|
|
|
|
const { video: { uuid } } = await server.imports.importVideo({ attributes })
|
|
|
|
|
|
|
|
return uuid
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Object storage for video import', function () {
|
2022-10-19 03:43:53 -05:00
|
|
|
if (areMockObjectStorageTestsDisabled()) return
|
2021-08-17 01:26:20 -05:00
|
|
|
|
|
|
|
let server: PeerTubeServer
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
2022-10-19 03:43:53 -05:00
|
|
|
await ObjectStorageCommand.prepareDefaultMockBuckets()
|
2021-08-17 01:26:20 -05:00
|
|
|
|
2022-10-19 03:43:53 -05:00
|
|
|
server = await createSingleServer(1, ObjectStorageCommand.getDefaultMockConfig())
|
2021-08-17 01:26:20 -05:00
|
|
|
|
|
|
|
await setAccessTokensToServers([ server ])
|
|
|
|
await setDefaultVideoChannel([ server ])
|
|
|
|
|
|
|
|
await server.config.enableImports()
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Without transcoding', async function () {
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
await server.config.disableTranscoding()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should import a video and have sent it to object storage', async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
|
|
|
const uuid = await importVideo(server)
|
|
|
|
await waitJobs(server)
|
|
|
|
|
|
|
|
const video = await server.videos.get({ id: uuid })
|
|
|
|
|
|
|
|
expect(video.files).to.have.lengthOf(1)
|
|
|
|
expect(video.streamingPlaylists).to.have.lengthOf(0)
|
|
|
|
|
|
|
|
const fileUrl = video.files[0].fileUrl
|
2022-10-19 03:43:53 -05:00
|
|
|
expectStartWith(fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl())
|
2021-08-17 01:26:20 -05:00
|
|
|
|
2022-10-12 09:09:02 -05:00
|
|
|
await makeRawRequest({ url: fileUrl, expectedStatus: HttpStatusCode.OK_200 })
|
2021-08-17 01:26:20 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('With transcoding', async function () {
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
await server.config.enableTranscoding()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should import a video and have sent it to object storage', async function () {
|
|
|
|
this.timeout(120000)
|
|
|
|
|
|
|
|
const uuid = await importVideo(server)
|
|
|
|
await waitJobs(server)
|
|
|
|
|
|
|
|
const video = await server.videos.get({ id: uuid })
|
|
|
|
|
2021-11-05 04:23:02 -05:00
|
|
|
expect(video.files).to.have.lengthOf(5)
|
2021-08-17 01:26:20 -05:00
|
|
|
expect(video.streamingPlaylists).to.have.lengthOf(1)
|
2021-11-05 04:23:02 -05:00
|
|
|
expect(video.streamingPlaylists[0].files).to.have.lengthOf(5)
|
2021-08-17 01:26:20 -05:00
|
|
|
|
|
|
|
for (const file of video.files) {
|
2022-10-19 03:43:53 -05:00
|
|
|
expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl())
|
2021-08-17 01:26:20 -05:00
|
|
|
|
2022-10-12 09:09:02 -05:00
|
|
|
await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
|
2021-08-17 01:26:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const file of video.streamingPlaylists[0].files) {
|
2022-10-19 03:43:53 -05:00
|
|
|
expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
|
2021-08-17 01:26:20 -05:00
|
|
|
|
2022-10-12 09:09:02 -05:00
|
|
|
await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
|
2021-08-17 01:26:20 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
after(async function () {
|
2023-05-10 06:57:06 -05:00
|
|
|
await cleanupTests([ server ])
|
2021-08-17 01:26:20 -05:00
|
|
|
})
|
|
|
|
})
|