import { expect } from 'chai'
-import { expectStartWith, getAllFiles } from '@server/tests/shared'
-import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { checkPersistentTmpIsEmpty, checkVideoDuration, expectStartWith } from '@server/tests/shared'
+import { areMockObjectStorageTestsDisabled, getAllFiles } from '@shared/core-utils'
import { VideoStudioTask } from '@shared/models'
import {
cleanupTests,
let servers: PeerTubeServer[] = []
let videoUUID: string
- async function checkDuration (server: PeerTubeServer, duration: number) {
- const video = await server.videos.get({ id: videoUUID })
-
- expect(video.duration).to.be.approximately(duration, 1)
-
- for (const file of video.files) {
- const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl })
-
- for (const stream of metadata.streams) {
- expect(Math.round(stream.duration)).to.be.approximately(duration, 1)
- }
- }
- }
-
async function renewVideo (fixture = 'video_short.webm') {
const video = await servers[0].videos.quickUpload({ name: 'video', fixture })
videoUUID = video.uuid
])
for (const server of servers) {
- await checkDuration(server, 3)
+ await checkVideoDuration(server, videoUUID, 3)
const video = await server.videos.get({ id: videoUUID })
expect(new Date(video.publishedAt)).to.be.below(beforeTasks)
])
for (const server of servers) {
- await checkDuration(server, 2)
+ await checkVideoDuration(server, videoUUID, 2)
}
})
])
for (const server of servers) {
- await checkDuration(server, 4)
+ await checkVideoDuration(server, videoUUID, 4)
}
})
})
])
for (const server of servers) {
- await checkDuration(server, 10)
+ await checkVideoDuration(server, videoUUID, 10)
}
})
])
for (const server of servers) {
- await checkDuration(server, 7)
+ await checkVideoDuration(server, videoUUID, 7)
}
})
])
for (const server of servers) {
- await checkDuration(server, 12)
+ await checkVideoDuration(server, videoUUID, 12)
}
})
])
for (const server of servers) {
- await checkDuration(server, 7)
+ await checkVideoDuration(server, videoUUID, 7)
}
})
])
for (const server of servers) {
- await checkDuration(server, 10)
+ await checkVideoDuration(server, videoUUID, 10)
}
})
])
for (const server of servers) {
- await checkDuration(server, 10)
+ await checkVideoDuration(server, videoUUID, 10)
}
})
})
await createTasks(VideoStudioCommand.getComplexTask())
for (const server of servers) {
- await checkDuration(server, 9)
+ await checkVideoDuration(server, videoUUID, 9)
}
})
})
- describe('HLS only video edition', function () {
+ describe('HLS only studio edition', function () {
before(async function () {
// Disable webtorrent
const video = await server.videos.get({ id: videoUUID })
expect(video.files).to.have.lengthOf(0)
- await checkDuration(server, 9)
+ await checkVideoDuration(server, videoUUID, 9)
}
})
})
- describe('Object storage video edition', function () {
- if (areObjectStorageTestsDisabled()) return
+ describe('Server restart', function () {
+
+ it('Should still be able to run video edition after a server restart', async function () {
+ this.timeout(240_000)
+
+ await renewVideo()
+ await servers[0].videoStudio.createEditionTasks({ videoId: videoUUID, tasks: VideoStudioCommand.getComplexTask() })
+
+ await servers[0].kill()
+ await servers[0].run()
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ await checkVideoDuration(server, videoUUID, 9)
+ }
+ })
+
+ it('Should have an empty persistent tmp directory', async function () {
+ await checkPersistentTmpIsEmpty(servers[0])
+ })
+ })
+
+ describe('Object storage studio edition', function () {
+ if (areMockObjectStorageTestsDisabled()) return
+
+ const objectStorage = new ObjectStorageCommand()
before(async function () {
- await ObjectStorageCommand.prepareDefaultBuckets()
+ await objectStorage.prepareDefaultMockBuckets()
await servers[0].kill()
- await servers[0].run(ObjectStorageCommand.getDefaultConfig())
+ await servers[0].run(objectStorage.getDefaultMockConfig())
await servers[0].config.enableMinimumTranscoding()
})
}
for (const webtorrentFile of video.files) {
- expectStartWith(webtorrentFile.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
+ expectStartWith(webtorrentFile.fileUrl, objectStorage.getMockWebVideosBaseUrl())
}
for (const hlsFile of video.streamingPlaylists[0].files) {
- expectStartWith(hlsFile.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
+ expectStartWith(hlsFile.fileUrl, objectStorage.getMockPlaylistBaseUrl())
}
- await checkDuration(server, 9)
+ await checkVideoDuration(server, videoUUID, 9)
}
})
+
+ after(async function () {
+ await objectStorage.cleanupMock()
+ })
})
after(async function () {