From 2186386cca113506791583cb07d6ccacba7af4e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 12 Jun 2018 20:04:58 +0200 Subject: Add concept of video state, and add ability to wait transcoding before publishing a video --- server/tests/api/videos/multiple-servers.ts | 8 ++-- server/tests/api/videos/services.ts | 3 +- server/tests/api/videos/video-transcoder.ts | 74 +++++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 9 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 5f9a76621..edc46a644 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -924,7 +924,7 @@ describe('Test multiple servers', function () { describe('With minimum parameters', function () { it('Should upload and propagate the video', async function () { - this.timeout(50000) + this.timeout(60000) const path = '/api/v1/videos/upload' @@ -934,16 +934,14 @@ describe('Test multiple servers', function () { .set('Authorization', 'Bearer ' + servers[1].accessToken) .field('name', 'minimum parameters') .field('privacy', '1') - .field('nsfw', 'false') .field('channelId', '1') - .field('commentsEnabled', 'true') const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') await req.attach('videofile', filePath) .expect(200) - await wait(25000) + await wait(40000) for (const server of servers) { const res = await getVideosList(server.url) @@ -964,7 +962,7 @@ describe('Test multiple servers', function () { }, isLocal, duration: 5, - commentsEnabled: true, + commentsEnabled: false, tags: [ ], privacy: VideoPrivacy.PUBLIC, channel: { diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index 45b4a1a81..51db000a2 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts @@ -32,7 +32,8 @@ describe('Test services', function () { const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid const res = await getOEmbed(server.url, oembedUrl) - const expectedHtml = `' const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index ef929960d..1eace6491 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -2,11 +2,22 @@ import * as chai from 'chai' import 'mocha' -import { VideoDetails } from '../../../../shared/models/videos' +import { VideoDetails, VideoState } from '../../../../shared/models/videos' import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' import { - flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, - wait, webtorrentAdd + doubleFollow, + flushAndRunMultipleServers, + flushTests, + getMyVideos, + getVideo, + getVideosList, + killallServers, + root, + ServerInfo, + setAccessTokensToServers, + uploadVideo, + wait, + webtorrentAdd } from '../../utils' import { join } from 'path' @@ -109,6 +120,63 @@ describe('Test video transcoding', function () { } }) + it('Should wait transcoding before publishing the video', async function () { + this.timeout(80000) + + await doubleFollow(servers[0], servers[1]) + + await wait(15000) + + { + // Upload the video, but wait transcoding + const videoAttributes = { + name: 'waiting video', + fixture: 'video_short1.webm', + waitTranscoding: true + } + const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes) + const videoId = resVideo.body.video.uuid + + // Should be in transcode state + const { body } = await getVideo(servers[ 1 ].url, videoId) + expect(body.name).to.equal('waiting video') + expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) + expect(body.state.label).to.equal('To transcode') + expect(body.waitTranscoding).to.be.true + + // Should have my video + const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10) + const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video') + expect(videoToFindInMine).not.to.be.undefined + expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) + expect(videoToFindInMine.state.label).to.equal('To transcode') + expect(videoToFindInMine.waitTranscoding).to.be.true + + // Should not list this video + const resVideos = await getVideosList(servers[1].url) + const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video') + expect(videoToFindInList).to.be.undefined + + // Server 1 should not have the video yet + await getVideo(servers[0].url, videoId, 404) + } + + await wait(30000) + + for (const server of servers) { + const res = await getVideosList(server.url) + const videoToFind = res.body.data.find(v => v.name === 'waiting video') + expect(videoToFind).not.to.be.undefined + + const res2 = await getVideo(server.url, videoToFind.id) + const videoDetails: VideoDetails = res2.body + + expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) + expect(videoDetails.state.label).to.equal('Published') + expect(videoDetails.waitTranscoding).to.be.true + } + }) + after(async function () { killallServers(servers) -- cgit v1.2.3