]>
Commit | Line | Data |
---|---|---|
0138af92 FF |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { VideoDetails, VideoFile } from '../../../shared/models/videos' | |
0138af92 | 6 | import { |
28be8916 | 7 | doubleFollow, |
0138af92 | 8 | execCLI, |
28be8916 | 9 | flushAndRunMultipleServers, |
0138af92 FF |
10 | flushTests, |
11 | getEnvCli, | |
28be8916 | 12 | getVideo, |
0138af92 FF |
13 | getVideosList, |
14 | killallServers, | |
0138af92 FF |
15 | ServerInfo, |
16 | setAccessTokensToServers, | |
17 | uploadVideo, | |
28be8916 | 18 | wait |
0138af92 FF |
19 | } from '../utils' |
20 | ||
28be8916 C |
21 | const expect = chai.expect |
22 | ||
23 | function assertVideoProperties (video: VideoFile, resolution: number, extname: string, size?: number) { | |
0138af92 FF |
24 | expect(video).to.have.nested.property('resolution.id', resolution) |
25 | expect(video).to.have.property('magnetUri').that.includes(`.${extname}`) | |
26 | expect(video).to.have.property('torrentUrl').that.includes(`-${resolution}.torrent`) | |
27 | expect(video).to.have.property('fileUrl').that.includes(`.${extname}`) | |
28 | expect(video).to.have.property('size').that.is.above(0) | |
28be8916 C |
29 | |
30 | if (size) expect(video.size).to.equal(size) | |
0138af92 FF |
31 | } |
32 | ||
33 | describe('Test create import video jobs', function () { | |
34 | this.timeout(60000) | |
35 | ||
36 | let servers: ServerInfo[] = [] | |
37 | let video1UUID: string | |
38 | let video2UUID: string | |
39 | ||
40 | before(async function () { | |
41 | this.timeout(90000) | |
42 | await flushTests() | |
43 | ||
44 | // Run server 2 to have transcoding enabled | |
45 | servers = await flushAndRunMultipleServers(2) | |
46 | await setAccessTokensToServers(servers) | |
47 | ||
48 | await doubleFollow(servers[0], servers[1]) | |
49 | ||
50 | // Upload two videos for our needs | |
51 | const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) | |
52 | video1UUID = res1.body.video.uuid | |
53 | const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) | |
54 | video2UUID = res2.body.video.uuid | |
55 | ||
28be8916 | 56 | // Transcoding |
0138af92 FF |
57 | await wait(40000) |
58 | }) | |
59 | ||
60 | it('Should run a import job on video 1 with a lower resolution', async function () { | |
61 | const env = getEnvCli(servers[0]) | |
99d10301 | 62 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) |
0138af92 FF |
63 | |
64 | await wait(30000) | |
65 | ||
28be8916 | 66 | let magnetUri: string |
0138af92 FF |
67 | for (const server of servers) { |
68 | const { data: videos } = (await getVideosList(server.url)).body | |
69 | expect(videos).to.have.lengthOf(2) | |
70 | ||
0138af92 FF |
71 | const video = videos.find(({ uuid }) => uuid === video1UUID) |
72 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | |
73 | ||
74 | expect(videoDetail.files).to.have.lengthOf(2) | |
75 | const [originalVideo, transcodedVideo] = videoDetail.files | |
76 | assertVideoProperties(originalVideo, 720, 'webm') | |
77 | assertVideoProperties(transcodedVideo, 480, 'webm') | |
28be8916 C |
78 | |
79 | if (!magnetUri) magnetUri = transcodedVideo.magnetUri | |
80 | else expect(transcodedVideo.magnetUri).to.equal(magnetUri) | |
0138af92 FF |
81 | } |
82 | }) | |
83 | ||
84 | it('Should run a import job on video 2 with the same resolution', async function () { | |
85 | const env = getEnvCli(servers[1]) | |
99d10301 | 86 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) |
0138af92 FF |
87 | |
88 | await wait(30000) | |
89 | ||
28be8916 | 90 | let magnetUri: string |
0138af92 FF |
91 | for (const server of servers.reverse()) { |
92 | const { data: videos } = (await getVideosList(server.url)).body | |
93 | expect(videos).to.have.lengthOf(2) | |
94 | ||
0138af92 FF |
95 | const video = videos.find(({ uuid }) => uuid === video2UUID) |
96 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | |
97 | ||
98 | expect(videoDetail.files).to.have.lengthOf(4) | |
99 | const [originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240] = videoDetail.files | |
28be8916 | 100 | assertVideoProperties(originalVideo, 720, 'ogv', 140849) |
0138af92 FF |
101 | assertVideoProperties(transcodedVideo420, 480, 'mp4') |
102 | assertVideoProperties(transcodedVideo320, 360, 'mp4') | |
103 | assertVideoProperties(transcodedVideo240, 240, 'mp4') | |
28be8916 C |
104 | |
105 | if (!magnetUri) magnetUri = originalVideo.magnetUri | |
106 | else expect(originalVideo.magnetUri).to.equal(magnetUri) | |
0138af92 FF |
107 | } |
108 | }) | |
109 | ||
110 | after(async function () { | |
111 | killallServers(servers) | |
112 | ||
113 | // Keep the logs if the test failed | |
114 | if (this['ok']) { | |
115 | await flushTests() | |
116 | } | |
117 | }) | |
118 | }) |