aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-12 20:04:58 +0200
committerChocobozzz <me@florianbigard.com>2018-06-12 20:37:51 +0200
commit2186386cca113506791583cb07d6ccacba7af4e0 (patch)
tree3c214c0b5fbd64332624267fa6e51fd4a9cf6474 /server/tests/api/videos/video-transcoder.ts
parent6ccdf3a23ecec5ba2eeaf487fd1fafdc7606b4bf (diff)
downloadPeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.gz
PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.tar.zst
PeerTube-2186386cca113506791583cb07d6ccacba7af4e0.zip
Add concept of video state, and add ability to wait transcoding before
publishing a video
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts74
1 files changed, 71 insertions, 3 deletions
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 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoDetails } from '../../../../shared/models/videos' 5import { VideoDetails, VideoState } from '../../../../shared/models/videos'
6import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' 6import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils'
7import { 7import {
8 flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, 8 doubleFollow,
9 wait, webtorrentAdd 9 flushAndRunMultipleServers,
10 flushTests,
11 getMyVideos,
12 getVideo,
13 getVideosList,
14 killallServers,
15 root,
16 ServerInfo,
17 setAccessTokensToServers,
18 uploadVideo,
19 wait,
20 webtorrentAdd
10} from '../../utils' 21} from '../../utils'
11import { join } from 'path' 22import { join } from 'path'
12 23
@@ -109,6 +120,63 @@ describe('Test video transcoding', function () {
109 } 120 }
110 }) 121 })
111 122
123 it('Should wait transcoding before publishing the video', async function () {
124 this.timeout(80000)
125
126 await doubleFollow(servers[0], servers[1])
127
128 await wait(15000)
129
130 {
131 // Upload the video, but wait transcoding
132 const videoAttributes = {
133 name: 'waiting video',
134 fixture: 'video_short1.webm',
135 waitTranscoding: true
136 }
137 const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes)
138 const videoId = resVideo.body.video.uuid
139
140 // Should be in transcode state
141 const { body } = await getVideo(servers[ 1 ].url, videoId)
142 expect(body.name).to.equal('waiting video')
143 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
144 expect(body.state.label).to.equal('To transcode')
145 expect(body.waitTranscoding).to.be.true
146
147 // Should have my video
148 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
149 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video')
150 expect(videoToFindInMine).not.to.be.undefined
151 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
152 expect(videoToFindInMine.state.label).to.equal('To transcode')
153 expect(videoToFindInMine.waitTranscoding).to.be.true
154
155 // Should not list this video
156 const resVideos = await getVideosList(servers[1].url)
157 const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video')
158 expect(videoToFindInList).to.be.undefined
159
160 // Server 1 should not have the video yet
161 await getVideo(servers[0].url, videoId, 404)
162 }
163
164 await wait(30000)
165
166 for (const server of servers) {
167 const res = await getVideosList(server.url)
168 const videoToFind = res.body.data.find(v => v.name === 'waiting video')
169 expect(videoToFind).not.to.be.undefined
170
171 const res2 = await getVideo(server.url, videoToFind.id)
172 const videoDetails: VideoDetails = res2.body
173
174 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
175 expect(videoDetails.state.label).to.equal('Published')
176 expect(videoDetails.waitTranscoding).to.be.true
177 }
178 })
179
112 after(async function () { 180 after(async function () {
113 killallServers(servers) 181 killallServers(servers)
114 182