X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fcreate-move-video-storage-job.ts;h=33a8cb9f9929df9fb4a34ae9547bc67168cbd122;hb=52798aa5f277492d4dd2482bca9396d2e982fa19;hp=c357f501b4e622facc7fbdc63dc004ed99117a0b;hpb=9ab330b90decf4edf152ff8e1d2948c065766b2c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.ts index c357f501b..33a8cb9f9 100644 --- a/server/tests/cli/create-move-video-storage-job.ts +++ b/server/tests/cli/create-move-video-storage-job.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ +import { join } from 'path' import { areMockObjectStorageTestsDisabled } from '@shared/core-utils' import { HttpStatusCode, VideoDetails } from '@shared/models' import { @@ -12,12 +13,12 @@ import { setAccessTokensToServers, waitJobs } from '@shared/server-commands' -import { expectStartWith } from '../shared' +import { checkDirectoryIsEmpty, expectStartWith } from '../shared' -async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { +async function checkFiles (origin: PeerTubeServer, video: VideoDetails, objectStorage?: ObjectStorageCommand) { for (const file of video.files) { - const start = inObjectStorage - ? ObjectStorageCommand.getMockWebTorrentBaseUrl() + const start = objectStorage + ? objectStorage.getMockWebVideosBaseUrl() : origin.url expectStartWith(file.fileUrl, start) @@ -25,8 +26,8 @@ async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObject await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) } - const start = inObjectStorage - ? ObjectStorageCommand.getMockPlaylistBaseUrl() + const start = objectStorage + ? objectStorage.getMockPlaylistBaseUrl() : origin.url const hls = video.streamingPlaylists[0] @@ -45,6 +46,7 @@ describe('Test create move video storage job', function () { let servers: PeerTubeServer[] = [] const uuids: string[] = [] + const objectStorage = new ObjectStorageCommand() before(async function () { this.timeout(360000) @@ -55,7 +57,7 @@ describe('Test create move video storage job', function () { await doubleFollow(servers[0], servers[1]) - await ObjectStorageCommand.prepareDefaultMockBuckets() + await objectStorage.prepareDefaultMockBuckets() await servers[0].config.enableTranscoding() @@ -67,25 +69,25 @@ describe('Test create move video storage job', function () { await waitJobs(servers) await servers[0].kill() - await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) + await servers[0].run(objectStorage.getDefaultMockConfig()) }) it('Should move only one file', async function () { this.timeout(120000) const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}` - await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) + await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig()) await waitJobs(servers) for (const server of servers) { const video = await server.videos.get({ id: uuids[1] }) - await checkFiles(servers[0], video, true) + await checkFiles(servers[0], video, objectStorage) for (const id of [ uuids[0], uuids[2] ]) { const video = await server.videos.get({ id }) - await checkFiles(servers[0], video, false) + await checkFiles(servers[0], video) } } }) @@ -94,18 +96,26 @@ describe('Test create move video storage job', function () { this.timeout(120000) const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos` - await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) + await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig()) await waitJobs(servers) for (const server of servers) { for (const id of [ uuids[0], uuids[2] ]) { const video = await server.videos.get({ id }) - await checkFiles(servers[0], video, true) + await checkFiles(servers[0], video, objectStorage) } } }) + it('Should not have files on disk anymore', async function () { + await checkDirectoryIsEmpty(servers[0], 'videos', [ 'private' ]) + await checkDirectoryIsEmpty(servers[0], join('videos', 'private')) + + await checkDirectoryIsEmpty(servers[0], join('streaming-playlists', 'hls'), [ 'private' ]) + await checkDirectoryIsEmpty(servers[0], join('streaming-playlists', 'hls', 'private')) + }) + after(async function () { await cleanupTests(servers) })