From edb4ffc7e0b13659d7c73b120f2c87b27e4c26a1 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 8 Oct 2018 09:26:04 -0500 Subject: Set bitrate limits for transcoding (fixes #638) (#1135) * Set bitrate limits for transcoding (fixes #638) * added optimization script and test, changed stuff * fix test, improve docs * re-add optimize-old-videos script * added documentation * Don't optimize videos without valid UUID, or redundancy videos * move getUUIDFromFilename * fix tests? * update torrent and file size, some more fixes/improvements * use higher bitrate for high fps video, adjust bitrates * add test video * don't throw error if resolution is undefined * generate test fixture on the fly * use random noise video for bitrate test, add promise * shorten test video to avoid timeout * use existing function to optimize video * various fixes * increase test timeout * limit test fixture size, add link * test fixes * add await * more test fixes, add -b:v parameter * replace ffmpeg wiki link * fix ffmpeg params * fix unit test * add test fixture to .gitgnore * add video transcoding fps model * add missing file --- server/tests/api/videos/video-transcoder.ts | 62 +++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 0f83d4d57..ec554ed19 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -4,8 +4,8 @@ import * as chai from 'chai' import 'mocha' import { omit } from 'lodash' import * as ffmpeg from 'fluent-ffmpeg' -import { VideoDetails, VideoState } from '../../../../shared/models/videos' -import { getVideoFileFPS, audio } from '../../../helpers/ffmpeg-utils' +import { VideoDetails, VideoState, getMaxBitrate, VideoResolution } from '../../../../shared/models/videos' +import { getVideoFileFPS, audio, getVideoFileBitrate, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { buildAbsoluteFixturePath, doubleFollow, @@ -20,8 +20,10 @@ import { uploadVideo, webtorrentAdd } from '../../utils' -import { join } from 'path' +import { join, basename } from 'path' import { waitJobs } from '../../utils/server/jobs' +import { remove } from 'fs-extra' +import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' const expect = chai.expect @@ -228,7 +230,7 @@ describe('Test video transcoding', function () { } }) - it('Should wait transcoding before publishing the video', async function () { + it('Should wait for transcoding before publishing the video', async function () { this.timeout(80000) { @@ -281,7 +283,59 @@ describe('Test video transcoding', function () { } }) + const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4') + it('Should respect maximum bitrate values', async function () { + this.timeout(160000) + + { + // Generate a random, high bitrate video on the fly, so we don't have to include + // a large file in the repo. The video needs to have a certain minimum length so + // that FFmpeg properly applies bitrate limits. + // https://stackoverflow.com/a/15795112 + await new Promise(async (res, rej) => { + ffmpeg() + .outputOptions(['-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom']) + .outputOptions(['-ac 2', '-f s16le', '-i /dev/urandom', '-t 10']) + .outputOptions(['-maxrate 10M', '-bufsize 10M']) + .output(tempFixturePath) + .on('error', rej) + .on('end', res) + .run() + }) + + const bitrate = await getVideoFileBitrate(tempFixturePath) + expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS)) + + const videoAttributes = { + name: 'high bitrate video', + description: 'high bitrate video', + fixture: basename(tempFixturePath) + } + + await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + + const video = res.body.data.find(v => v.name === videoAttributes.name) + + for (const resolution of ['240', '360', '480', '720', '1080']) { + const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') + const bitrate = await getVideoFileBitrate(path) + const fps = await getVideoFileFPS(path) + const resolution2 = await getVideoFileResolution(path) + + expect(resolution2.videoFileResolution.toString()).to.equal(resolution) + expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) + } + } + } + }) + after(async function () { + remove(tempFixturePath) killallServers(servers) }) }) -- cgit v1.2.3 From c1c86c1599acf8aad71fb7d7f312c43d6d1fa5ac Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Oct 2018 17:47:19 +0200 Subject: Try to cache video_high_bitrate_1080p in travis --- server/tests/api/videos/video-transcoder.ts | 79 +++++++++++++++-------------- 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index ec554ed19..0ce5197ea 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -4,8 +4,8 @@ import * as chai from 'chai' import 'mocha' import { omit } from 'lodash' import * as ffmpeg from 'fluent-ffmpeg' -import { VideoDetails, VideoState, getMaxBitrate, VideoResolution } from '../../../../shared/models/videos' -import { getVideoFileFPS, audio, getVideoFileBitrate, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' +import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' +import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { buildAbsoluteFixturePath, doubleFollow, @@ -20,9 +20,9 @@ import { uploadVideo, webtorrentAdd } from '../../utils' -import { join, basename } from 'path' +import { join } from 'path' import { waitJobs } from '../../utils/server/jobs' -import { remove } from 'fs-extra' +import { pathExists } from 'fs-extra' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' const expect = chai.expect @@ -283,59 +283,62 @@ describe('Test video transcoding', function () { } }) - const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4') + const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) it('Should respect maximum bitrate values', async function () { this.timeout(160000) { - // Generate a random, high bitrate video on the fly, so we don't have to include - // a large file in the repo. The video needs to have a certain minimum length so - // that FFmpeg properly applies bitrate limits. - // https://stackoverflow.com/a/15795112 - await new Promise(async (res, rej) => { - ffmpeg() - .outputOptions(['-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom']) - .outputOptions(['-ac 2', '-f s16le', '-i /dev/urandom', '-t 10']) - .outputOptions(['-maxrate 10M', '-bufsize 10M']) - .output(tempFixturePath) - .on('error', rej) - .on('end', res) - .run() - }) + const exists = await pathExists(tempFixturePath) + if (!exists) { + + // Generate a random, high bitrate video on the fly, so we don't have to include + // a large file in the repo. The video needs to have a certain minimum length so + // that FFmpeg properly applies bitrate limits. + // https://stackoverflow.com/a/15795112 + await new Promise(async (res, rej) => { + ffmpeg() + .outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ]) + .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) + .outputOptions([ '-maxrate 10M', '-bufsize 10M' ]) + .output(tempFixturePath) + .on('error', rej) + .on('end', res) + .run() + }) + } const bitrate = await getVideoFileBitrate(tempFixturePath) expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS)) + } - const videoAttributes = { - name: 'high bitrate video', - description: 'high bitrate video', - fixture: basename(tempFixturePath) - } + const videoAttributes = { + name: 'high bitrate video', + description: 'high bitrate video', + fixture: tempFixturePath + } - await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) + await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) - await waitJobs(servers) + await waitJobs(servers) - for (const server of servers) { - const res = await getVideosList(server.url) + for (const server of servers) { + const res = await getVideosList(server.url) - const video = res.body.data.find(v => v.name === videoAttributes.name) + const video = res.body.data.find(v => v.name === videoAttributes.name) - for (const resolution of ['240', '360', '480', '720', '1080']) { - const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') - const bitrate = await getVideoFileBitrate(path) - const fps = await getVideoFileFPS(path) - const resolution2 = await getVideoFileResolution(path) + for (const resolution of ['240', '360', '480', '720', '1080']) { + const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') + const bitrate = await getVideoFileBitrate(path) + const fps = await getVideoFileFPS(path) + const resolution2 = await getVideoFileResolution(path) - expect(resolution2.videoFileResolution.toString()).to.equal(resolution) - expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) - } + expect(resolution2.videoFileResolution.toString()).to.equal(resolution) + expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) } } }) after(async function () { - remove(tempFixturePath) killallServers(servers) }) }) -- cgit v1.2.3 From 1cd3facc3de899ac864e979cd6d6a704b712cce3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Oct 2018 11:46:50 +0200 Subject: Add ability to list all local videos Including private/unlisted for moderators/admins --- server/tests/api/videos/index.ts | 1 + server/tests/api/videos/videos-filter.ts | 130 +++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 server/tests/api/videos/videos-filter.ts (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 09bb62a8d..9bdb78491 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts @@ -14,5 +14,6 @@ import './video-nsfw' import './video-privacy' import './video-schedule-update' import './video-transcoder' +import './videos-filter' import './videos-history' import './videos-overview' diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts new file mode 100644 index 000000000..a7588129f --- /dev/null +++ b/server/tests/api/videos/videos-filter.ts @@ -0,0 +1,130 @@ +/* tslint:disable:no-unused-expression */ + +import * as chai from 'chai' +import 'mocha' +import { + createUser, + doubleFollow, + flushAndRunMultipleServers, + flushTests, + killallServers, + makeGetRequest, + ServerInfo, + setAccessTokensToServers, + uploadVideo, + userLogin +} from '../../utils' +import { Video, VideoPrivacy } from '../../../../shared/models/videos' +import { UserRole } from '../../../../shared/models/users' + +const expect = chai.expect + +async function getVideosNames (server: ServerInfo, token: string, filter: string, statusCodeExpected = 200) { + const paths = [ + '/api/v1/video-channels/root_channel/videos', + '/api/v1/accounts/root/videos', + '/api/v1/videos', + '/api/v1/search/videos' + ] + + const videosResults: Video[][] = [] + + for (const path of paths) { + const res = await makeGetRequest({ + url: server.url, + path, + token, + query: { + sort: 'createdAt', + filter + }, + statusCodeExpected + }) + + videosResults.push(res.body.data.map(v => v.name)) + } + + return videosResults +} + +describe('Test videos filter validator', function () { + let servers: ServerInfo[] + + // --------------------------------------------------------------- + + before(async function () { + this.timeout(120000) + + await flushTests() + + servers = await flushAndRunMultipleServers(2) + + await setAccessTokensToServers(servers) + + for (const server of servers) { + const moderator = { username: 'moderator', password: 'my super password' } + await createUser( + server.url, + server.accessToken, + moderator.username, + moderator.password, + undefined, + undefined, + UserRole.MODERATOR + ) + server['moderatorAccessToken'] = await userLogin(server, moderator) + + await uploadVideo(server.url, server.accessToken, { name: 'public ' + server.serverNumber }) + + { + const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } + await uploadVideo(server.url, server.accessToken, attributes) + } + + { + const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } + await uploadVideo(server.url, server.accessToken, attributes) + } + } + + await doubleFollow(servers[0], servers[1]) + }) + + describe('Check videos filter', function () { + + it('Should display local videos', async function () { + for (const server of servers) { + const namesResults = await getVideosNames(server, server.accessToken, 'local') + for (const names of namesResults) { + expect(names).to.have.lengthOf(1) + expect(names[ 0 ]).to.equal('public ' + server.serverNumber) + } + } + }) + + it('Should display all local videos by the admin or the moderator', async function () { + for (const server of servers) { + for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { + + const namesResults = await getVideosNames(server, token, 'all-local') + for (const names of namesResults) { + expect(names).to.have.lengthOf(3) + + expect(names[ 0 ]).to.equal('public ' + server.serverNumber) + expect(names[ 1 ]).to.equal('unlisted ' + server.serverNumber) + expect(names[ 2 ]).to.equal('private ' + server.serverNumber) + } + } + } + }) + }) + + after(async function () { + killallServers(servers) + + // Keep the logs if the test failed + if (this['ok']) { + await flushTests() + } + }) +}) -- cgit v1.2.3 From 6f2ae7a1aa1b4a8b5605fc4c57c0c1d1fbe2a16e Mon Sep 17 00:00:00 2001 From: Adnane Belmadiaf Date: Sun, 14 Oct 2018 19:43:17 +0200 Subject: rename News category into News & Politics (#1261) --- server/tests/api/videos/single-server.ts | 2 +- server/tests/api/videos/video-imports.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index e3d62b7a0..089c3df25 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -118,7 +118,7 @@ describe('Test a single server', function () { const categories = res.body expect(Object.keys(categories)).to.have.length.above(10) - expect(categories[11]).to.equal('News') + expect(categories[11]).to.equal('News & Politics') }) it('Should list video licences', async function () { diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index b7866d529..aaee79a4a 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -30,7 +30,7 @@ describe('Test video imports', function () { const videoHttp: VideoDetails = resHttp.body expect(videoHttp.name).to.equal('small video - youtube') - expect(videoHttp.category.label).to.equal('News') + expect(videoHttp.category.label).to.equal('News & Politics') expect(videoHttp.licence.label).to.equal('Attribution') expect(videoHttp.language.label).to.equal('Unknown') expect(videoHttp.nsfw).to.be.false -- cgit v1.2.3 From cdf4cb9eaf5f6bc71f7c1e1963c07575f1d2593d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 09:44:43 +0200 Subject: Fix transcoding --- server/tests/api/videos/multiple-servers.ts | 8 ++++---- server/tests/api/videos/video-transcoder.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 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 4553ee855..b9ace2885 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -987,19 +987,19 @@ describe('Test multiple servers', function () { files: [ { resolution: 720, - size: 36000 + size: 72000 }, { resolution: 480, - size: 21000 + size: 45000 }, { resolution: 360, - size: 17000 + size: 34600 }, { resolution: 240, - size: 13000 + size: 24770 } ] } diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 0ce5197ea..0a567873c 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -123,7 +123,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') - const probe = await audio.get(ffmpeg, path) + const probe = await audio.get(path) if (probe.audioStream) { expect(probe.audioStream[ 'codec_name' ]).to.be.equal('aac') @@ -154,7 +154,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') - const probe = await audio.get(ffmpeg, path) + const probe = await audio.get(path) expect(probe).to.not.have.property('audioStream') } }) @@ -179,9 +179,9 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) - const fixtureVideoProbe = await audio.get(ffmpeg, fixturePath) + const fixtureVideoProbe = await audio.get(fixturePath) const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') - const videoProbe = await audio.get(ffmpeg, path) + const videoProbe = await audio.get(path) if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) -- cgit v1.2.3 From 74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Oct 2018 16:53:52 +0200 Subject: Fix optimize old videos script --- server/tests/api/videos/video-transcoder.ts | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 0a567873c..85795d2ed 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -18,7 +18,8 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo, - webtorrentAdd + webtorrentAdd, + generateHighBitrateVideo } from '../../utils' import { join } from 'path' import { waitJobs } from '../../utils/server/jobs' @@ -283,29 +284,13 @@ describe('Test video transcoding', function () { } }) - const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) it('Should respect maximum bitrate values', async function () { this.timeout(160000) + let tempFixturePath: string + { - const exists = await pathExists(tempFixturePath) - if (!exists) { - - // Generate a random, high bitrate video on the fly, so we don't have to include - // a large file in the repo. The video needs to have a certain minimum length so - // that FFmpeg properly applies bitrate limits. - // https://stackoverflow.com/a/15795112 - await new Promise(async (res, rej) => { - ffmpeg() - .outputOptions([ '-f rawvideo', '-video_size 1920x1080', '-i /dev/urandom' ]) - .outputOptions([ '-ac 2', '-f s16le', '-i /dev/urandom', '-t 10' ]) - .outputOptions([ '-maxrate 10M', '-bufsize 10M' ]) - .output(tempFixturePath) - .on('error', rej) - .on('end', res) - .run() - }) - } + tempFixturePath = await generateHighBitrateVideo() const bitrate = await getVideoFileBitrate(tempFixturePath) expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS)) -- cgit v1.2.3 From 9639bd175726b73f8fe664b5ced12a72407b1f0b Mon Sep 17 00:00:00 2001 From: buoyantair Date: Mon, 29 Oct 2018 22:18:31 +0530 Subject: Move utils to /shared Move utils used by /server/tools/* & /server/tests/**/* into /shared folder. Issue: #1336 --- server/tests/api/videos/multiple-servers.ts | 6 +++--- server/tests/api/videos/services.ts | 12 ++++++++++-- server/tests/api/videos/single-server.ts | 2 +- server/tests/api/videos/video-abuse.ts | 6 +++--- server/tests/api/videos/video-blacklist-management.ts | 6 +++--- server/tests/api/videos/video-blacklist.ts | 6 +++--- server/tests/api/videos/video-captions.ts | 15 +++++++++++---- server/tests/api/videos/video-change-ownership.ts | 4 ++-- server/tests/api/videos/video-channels.ts | 6 +++--- server/tests/api/videos/video-comments.ts | 6 +++--- server/tests/api/videos/video-description.ts | 6 +++--- server/tests/api/videos/video-imports.ts | 6 +++--- server/tests/api/videos/video-nsfw.ts | 17 ++++++++++++----- server/tests/api/videos/video-privacy.ts | 12 ++++++------ server/tests/api/videos/video-schedule-update.ts | 4 ++-- server/tests/api/videos/video-transcoder.ts | 4 ++-- server/tests/api/videos/videos-filter.ts | 2 +- server/tests/api/videos/videos-history.ts | 4 ++-- server/tests/api/videos/videos-overview.ts | 4 ++-- 19 files changed, 75 insertions(+), 53 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 b9ace2885..aa38b6b33 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -31,15 +31,15 @@ import { viewVideo, wait, webtorrentAdd -} from '../../utils' +} from '../../../../shared/utils' import { addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index 2f1424292..2da86964f 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts @@ -2,8 +2,16 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, getOEmbed, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' -import { runServer } from '../../utils/server/servers' +import { + flushTests, + getOEmbed, + getVideosList, + killallServers, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils/index' +import { runServer } from '../../../../shared/utils/server/servers' const expect = chai.expect diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 089c3df25..069dec67c 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -28,7 +28,7 @@ import { uploadVideo, viewVideo, wait -} from '../../utils' +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index a17f3c8de..3a7b623da 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts @@ -14,9 +14,9 @@ import { setAccessTokensToServers, updateVideoAbuse, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts index 7bf39dc99..06d80a270 100644 --- a/server/tests/api/videos/video-blacklist-management.ts +++ b/server/tests/api/videos/video-blacklist-management.ts @@ -16,9 +16,9 @@ import { setAccessTokensToServers, updateVideoBlacklist, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { VideoAbuse } from '../../../../shared/models/videos' const expect = chai.expect diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index de4c68f1d..1cce82d2a 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts @@ -11,9 +11,9 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 6e441410d..57bee713f 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts @@ -2,10 +2,17 @@ import * as chai from 'chai' import 'mocha' -import { checkVideoFilesWereRemoved, doubleFollow, flushAndRunMultipleServers, removeVideo, uploadVideo, wait } from '../../utils' -import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' -import { waitJobs } from '../../utils/server/jobs' -import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' +import { + checkVideoFilesWereRemoved, + doubleFollow, + flushAndRunMultipleServers, + removeVideo, + uploadVideo, + wait +} from '../../../../shared/utils' +import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/utils/index' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../../../shared/utils/videos/video-captions' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' const expect = chai.expect diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 1578a471d..25675a966 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts @@ -18,8 +18,8 @@ import { uploadVideo, userLogin, getVideo -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { User } from '../../../../shared/models/users' import { VideoDetails } from '../../../../shared/models/videos' diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 8138c65d6..5bffffc66 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -11,7 +11,7 @@ import { updateVideo, updateVideoChannelAvatar, uploadVideo, wait, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { addVideoChannel, deleteVideoChannel, @@ -24,8 +24,8 @@ import { ServerInfo, setAccessTokensToServers, updateVideoChannel -} from '../../utils/index' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index d6e07c5b3..ce1b17e35 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -3,7 +3,7 @@ import * as chai from 'chai' import 'mocha' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' -import { testImage } from '../../utils' +import { testImage } from '../../../../shared/utils' import { dateIsValid, flushTests, @@ -13,14 +13,14 @@ import { setAccessTokensToServers, updateMyAvatar, uploadVideo -} from '../../utils/index' +} from '../../../../shared/utils/index' import { addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' +} from '../../../../shared/utils/videos/video-comments' const expect = chai.expect diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index dd5cd78c0..cbda0b9a6 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts @@ -12,9 +12,9 @@ import { setAccessTokensToServers, updateVideo, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index aaee79a4a..cd4988553 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -14,9 +14,9 @@ import { killallServers, ServerInfo, setAccessTokensToServers -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' -import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../utils/videos/video-imports' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../../../shared/utils/videos/video-imports' const expect = chai.expect diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index eab7a6991..df1ee2eb9 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -2,10 +2,17 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' -import { getMyVideos } from '../../utils/videos/videos' +import { + flushTests, + getVideosList, + killallServers, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils/index' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' +import { getMyVideos } from '../../../../shared/utils/videos/videos' import { getAccountVideos, getConfig, @@ -18,7 +25,7 @@ import { searchVideoWithToken, updateCustomConfig, updateMyUser -} from '../../utils' +} from '../../../../shared/utils' import { ServerConfig } from '../../../../shared/models' import { CustomConfig } from '../../../../shared/models/server/custom-config.model' import { User } from '../../../../shared/models/users' diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 9fefca7e3..0b4e66369 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -10,12 +10,12 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' -import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' +import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/utils/videos/videos' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index a260fa4da..ecfc5e034 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts @@ -15,9 +15,9 @@ import { updateVideo, uploadVideo, wait -} from '../../utils' +} from '../../../../shared/utils' import { join } from 'path' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 85795d2ed..f9458f0ec 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -20,9 +20,9 @@ import { uploadVideo, webtorrentAdd, generateHighBitrateVideo -} from '../../utils' +} from '../../../../shared/utils' import { join } from 'path' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { pathExists } from 'fs-extra' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts index a7588129f..59e37ad86 100644 --- a/server/tests/api/videos/videos-filter.ts +++ b/server/tests/api/videos/videos-filter.ts @@ -13,7 +13,7 @@ import { setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { Video, VideoPrivacy } from '../../../../shared/models/videos' import { UserRole } from '../../../../shared/models/users' diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 6d289b288..40ae94f79 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -11,9 +11,9 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils' +} from '../../../../shared/utils' import { Video, VideoDetails } from '../../../../shared/models/videos' -import { userWatchVideo } from '../../utils/videos/video-history' +import { userWatchVideo } from '../../../../shared/utils/videos/video-history' const expect = chai.expect diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 7d1f29c92..7221bcae6 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -2,8 +2,8 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils' -import { getVideosOverview } from '../../utils/overviews/overviews' +import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/utils' +import { getVideosOverview } from '../../../../shared/utils/overviews/overviews' import { VideosOverview } from '../../../../shared/models/overviews' const expect = chai.expect -- cgit v1.2.3 From d175a6f7ab9dd53e36f9f52769ac02dbfdc57e3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Nov 2018 17:08:18 +0100 Subject: Cleanup tests imports --- server/tests/api/videos/video-blacklist-management.ts | 3 +-- server/tests/api/videos/video-channels.ts | 6 ++++-- server/tests/api/videos/video-schedule-update.ts | 1 - server/tests/api/videos/video-transcoder.ts | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts index 7bf39dc99..fab577b30 100644 --- a/server/tests/api/videos/video-blacklist-management.ts +++ b/server/tests/api/videos/video-blacklist-management.ts @@ -1,7 +1,7 @@ /* tslint:disable:no-unused-expression */ import * as chai from 'chai' -import * as lodash from 'lodash' +import { orderBy } from 'lodash' import 'mocha' import { addVideoToBlacklist, @@ -22,7 +22,6 @@ import { waitJobs } from '../../utils/server/jobs' import { VideoAbuse } from '../../../../shared/models/videos' const expect = chai.expect -const orderBy = lodash.orderBy describe('Test video blacklist management', function () { let servers: ServerInfo[] = [] diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 8138c65d6..41429a3d8 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -7,10 +7,12 @@ import { createUser, doubleFollow, flushAndRunMultipleServers, - getVideoChannelVideos, serverLogin, testImage, + getVideoChannelVideos, + testImage, updateVideo, updateVideoChannelAvatar, - uploadVideo, wait, userLogin + uploadVideo, + userLogin } from '../../utils' import { addVideoChannel, diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index a260fa4da..b226a9d50 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts @@ -16,7 +16,6 @@ import { uploadVideo, wait } from '../../utils' -import { join } from 'path' import { waitJobs } from '../../utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 85795d2ed..23920d452 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -3,13 +3,13 @@ import * as chai from 'chai' import 'mocha' import { omit } from 'lodash' -import * as ffmpeg from 'fluent-ffmpeg' import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { buildAbsoluteFixturePath, doubleFollow, flushAndRunMultipleServers, + generateHighBitrateVideo, getMyVideos, getVideo, getVideosList, @@ -18,12 +18,10 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo, - webtorrentAdd, - generateHighBitrateVideo + webtorrentAdd } from '../../utils' import { join } from 'path' import { waitJobs } from '../../utils/server/jobs' -import { pathExists } from 'fs-extra' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' const expect = chai.expect -- cgit v1.2.3 From 8923187455c5aa7167d813c5c745d3857f183fd7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Dec 2018 09:16:41 +0100 Subject: Add test regarding tmp directory --- server/tests/api/videos/multiple-servers.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (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 aa38b6b33..6c281e49e 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -8,6 +8,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { addVideoChannel, + checkTmpIsEmpty, checkVideoFilesWereRemoved, completeVideoCheck, createUser, @@ -1008,6 +1009,14 @@ describe('Test multiple servers', function () { }) }) + describe('TMP directory', function () { + it('Should have an empty tmp directory', async function () { + for (const server of servers) { + await checkTmpIsEmpty(server) + } + }) + }) + after(async function () { killallServers(servers) -- cgit v1.2.3 From 14e2014acc1362cfbb770c051a7254b156cd8efb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Dec 2018 14:52:50 +0100 Subject: Support additional video extensions --- server/tests/api/videos/video-transcoder.ts | 31 +++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 68cf00194..eefd32ef8 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -20,9 +20,8 @@ import { uploadVideo, webtorrentAdd } from '../../../../shared/utils' -import { join } from 'path' +import { extname, join } from 'path' import { waitJobs } from '../../../../shared/utils/server/jobs' -import { pathExists } from 'fs-extra' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' const expect = chai.expect @@ -322,6 +321,34 @@ describe('Test video transcoding', function () { } }) + it('Should accept and transcode additional extensions', async function () { + this.timeout(300000) + + for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { + const videoAttributes = { + name: fixture, + fixture + } + + await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + + const video = res.body.data.find(v => v.name === videoAttributes.name) + const res2 = await getVideo(server.url, video.id) + const videoDetails = res2.body + + expect(videoDetails.files).to.have.lengthOf(4) + + const magnetUri = videoDetails.files[ 0 ].magnetUri + expect(magnetUri).to.contain('.mp4') + } + } + }) + after(async function () { killallServers(servers) }) -- cgit v1.2.3 From 8b9a525a180cc9f3a98c334cc052dcfc8f36dcd4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Dec 2018 15:52:38 +0100 Subject: Add history on server side Add ability to disable, clear and list user videos history --- server/tests/api/videos/videos-history.ts | 85 +++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 40ae94f79..f654a422b 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -3,17 +3,21 @@ import * as chai from 'chai' import 'mocha' import { + createUser, flushTests, getVideosListWithToken, getVideoWithToken, - killallServers, makePutBodyRequest, - runServer, searchVideoWithToken, + killallServers, + runServer, + searchVideoWithToken, ServerInfo, setAccessTokensToServers, - uploadVideo + updateMyUser, + uploadVideo, + userLogin } from '../../../../shared/utils' import { Video, VideoDetails } from '../../../../shared/models/videos' -import { userWatchVideo } from '../../../../shared/utils/videos/video-history' +import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/utils/videos/video-history' const expect = chai.expect @@ -22,6 +26,8 @@ describe('Test videos history', function () { let video1UUID: string let video2UUID: string let video3UUID: string + let video3WatchedDate: Date + let userAccessToken: string before(async function () { this.timeout(30000) @@ -46,6 +52,13 @@ describe('Test videos history', function () { const res = await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) video3UUID = res.body.video.uuid } + + const user = { + username: 'user_1', + password: 'super password' + } + await createUser(server.url, server.accessToken, user.username, user.password) + userAccessToken = await userLogin(server, user) }) it('Should get videos, without watching history', async function () { @@ -62,8 +75,8 @@ describe('Test videos history', function () { }) it('Should watch the first and second video', async function () { - await userWatchVideo(server.url, server.accessToken, video1UUID, 3) await userWatchVideo(server.url, server.accessToken, video2UUID, 8) + await userWatchVideo(server.url, server.accessToken, video1UUID, 3) }) it('Should return the correct history when listing, searching and getting videos', async function () { @@ -117,6 +130,68 @@ describe('Test videos history', function () { } }) + it('Should have these videos when listing my history', async function () { + video3WatchedDate = new Date() + await userWatchVideo(server.url, server.accessToken, video3UUID, 2) + + const res = await listMyVideosHistory(server.url, server.accessToken) + + expect(res.body.total).to.equal(3) + + const videos: Video[] = res.body.data + expect(videos[0].name).to.equal('video 3') + expect(videos[1].name).to.equal('video 1') + expect(videos[2].name).to.equal('video 2') + }) + + it('Should not have videos history on another user', async function () { + const res = await listMyVideosHistory(server.url, userAccessToken) + + expect(res.body.total).to.equal(0) + expect(res.body.data).to.have.lengthOf(0) + }) + + it('Should clear my history', async function () { + await removeMyVideosHistory(server.url, server.accessToken, video3WatchedDate.toISOString()) + }) + + it('Should have my history cleared', async function () { + const res = await listMyVideosHistory(server.url, server.accessToken) + + expect(res.body.total).to.equal(1) + + const videos: Video[] = res.body.data + expect(videos[0].name).to.equal('video 3') + }) + + it('Should disable videos history', async function () { + await updateMyUser({ + url: server.url, + accessToken: server.accessToken, + videosHistoryEnabled: false + }) + + await userWatchVideo(server.url, server.accessToken, video2UUID, 8, 409) + }) + + it('Should re-enable videos history', async function () { + await updateMyUser({ + url: server.url, + accessToken: server.accessToken, + videosHistoryEnabled: true + }) + + await userWatchVideo(server.url, server.accessToken, video1UUID, 8) + + const res = await listMyVideosHistory(server.url, server.accessToken) + + expect(res.body.total).to.equal(2) + + const videos: Video[] = res.body.data + expect(videos[0].name).to.equal('video 1') + expect(videos[1].name).to.equal('video 3') + }) + after(async function () { killallServers([ server ]) -- cgit v1.2.3 From 5abb9fbbd12e7097e348d6a38622d364b1fa47ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 10 Jan 2019 15:39:51 +0100 Subject: Add ability to unfederate a local video (on blacklist) --- server/tests/api/videos/index.ts | 1 - .../tests/api/videos/video-blacklist-management.ts | 192 ------------- server/tests/api/videos/video-blacklist.ts | 299 ++++++++++++++++++--- 3 files changed, 265 insertions(+), 227 deletions(-) delete mode 100644 server/tests/api/videos/video-blacklist-management.ts (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 9bdb78491..97f467aae 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts @@ -3,7 +3,6 @@ import './services' import './single-server' import './video-abuse' import './video-blacklist' -import './video-blacklist-management' import './video-captions' import './video-change-ownership' import './video-channels' diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts deleted file mode 100644 index 61411e30d..000000000 --- a/server/tests/api/videos/video-blacklist-management.ts +++ /dev/null @@ -1,192 +0,0 @@ -/* tslint:disable:no-unused-expression */ - -import * as chai from 'chai' -import { orderBy } from 'lodash' -import 'mocha' -import { - addVideoToBlacklist, - flushAndRunMultipleServers, - getBlacklistedVideosList, - getMyVideos, - getSortedBlacklistedVideosList, - getVideosList, - killallServers, - removeVideoFromBlacklist, - ServerInfo, - setAccessTokensToServers, - updateVideoBlacklist, - uploadVideo -} from '../../../../shared/utils/index' -import { doubleFollow } from '../../../../shared/utils/server/follows' -import { waitJobs } from '../../../../shared/utils/server/jobs' -import { VideoAbuse } from '../../../../shared/models/videos' - -const expect = chai.expect - -describe('Test video blacklist management', function () { - let servers: ServerInfo[] = [] - let videoId: number - - async function blacklistVideosOnServer (server: ServerInfo) { - const res = await getVideosList(server.url) - - const videos = res.body.data - for (let video of videos) { - await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') - } - } - - before(async function () { - this.timeout(50000) - - // Run servers - servers = await flushAndRunMultipleServers(2) - - // Get the access tokens - await setAccessTokensToServers(servers) - - // Server 1 and server 2 follow each other - await doubleFollow(servers[0], servers[1]) - - // Upload 2 videos on server 2 - await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 1st video', description: 'A video on server 2' }) - await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' }) - - // Wait videos propagation, server 2 has transcoding enabled - await waitJobs(servers) - - // Blacklist the two videos on server 1 - await blacklistVideosOnServer(servers[0]) - }) - - describe('When listing blacklisted videos', function () { - it('Should display all the blacklisted videos', async function () { - const res = await getBlacklistedVideosList(servers[0].url, servers[0].accessToken) - - expect(res.body.total).to.equal(2) - - const blacklistedVideos = res.body.data - expect(blacklistedVideos).to.be.an('array') - expect(blacklistedVideos.length).to.equal(2) - - for (const blacklistedVideo of blacklistedVideos) { - expect(blacklistedVideo.reason).to.equal('super reason') - videoId = blacklistedVideo.video.id - } - }) - - it('Should get the correct sort when sorting by descending id', async function () { - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-id') - expect(res.body.total).to.equal(2) - - const blacklistedVideos = res.body.data - expect(blacklistedVideos).to.be.an('array') - expect(blacklistedVideos.length).to.equal(2) - - const result = orderBy(res.body.data, [ 'id' ], [ 'desc' ]) - - expect(blacklistedVideos).to.deep.equal(result) - }) - - it('Should get the correct sort when sorting by descending video name', async function () { - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') - expect(res.body.total).to.equal(2) - - const blacklistedVideos = res.body.data - expect(blacklistedVideos).to.be.an('array') - expect(blacklistedVideos.length).to.equal(2) - - const result = orderBy(res.body.data, [ 'name' ], [ 'desc' ]) - - expect(blacklistedVideos).to.deep.equal(result) - }) - - it('Should get the correct sort when sorting by ascending creation date', async function () { - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') - expect(res.body.total).to.equal(2) - - const blacklistedVideos = res.body.data - expect(blacklistedVideos).to.be.an('array') - expect(blacklistedVideos.length).to.equal(2) - - const result = orderBy(res.body.data, [ 'createdAt' ]) - - expect(blacklistedVideos).to.deep.equal(result) - }) - }) - - describe('When updating blacklisted videos', function () { - it('Should change the reason', async function () { - await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') - - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') - const video = res.body.data.find(b => b.video.id === videoId) - - expect(video.reason).to.equal('my super reason updated') - }) - }) - - describe('When listing my videos', function () { - it('Should display blacklisted videos', async function () { - await blacklistVideosOnServer(servers[1]) - - const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 5) - - expect(res.body.total).to.equal(2) - expect(res.body.data).to.have.lengthOf(2) - - for (const video of res.body.data) { - expect(video.blacklisted).to.be.true - expect(video.blacklistedReason).to.equal('super reason') - } - }) - }) - - describe('When removing a blacklisted video', function () { - let videoToRemove: VideoAbuse - let blacklist = [] - - it('Should not have any video in videos list on server 1', async function () { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data.length).to.equal(0) - }) - - it('Should remove a video from the blacklist on server 1', async function () { - // Get one video in the blacklist - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') - videoToRemove = res.body.data[0] - blacklist = res.body.data.slice(1) - - // Remove it - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.video.id) - }) - - it('Should have the ex-blacklisted video in videos list on server 1', async function () { - const res = await getVideosList(servers[0].url) - expect(res.body.total).to.equal(1) - - const videos = res.body.data - expect(videos).to.be.an('array') - expect(videos.length).to.equal(1) - - expect(videos[0].name).to.equal(videoToRemove.video.name) - expect(videos[0].id).to.equal(videoToRemove.video.id) - }) - - it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { - const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') - expect(res.body.total).to.equal(1) - - const videos = res.body.data - expect(videos).to.be.an('array') - expect(videos.length).to.equal(1) - expect(videos).to.deep.equal(blacklist) - }) - }) - - after(async function () { - killallServers(servers) - }) -}) diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index 1cce82d2a..d39ad63b4 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts @@ -1,24 +1,43 @@ /* tslint:disable:no-unused-expression */ import * as chai from 'chai' +import { orderBy } from 'lodash' import 'mocha' import { addVideoToBlacklist, flushAndRunMultipleServers, + getBlacklistedVideosList, + getMyVideos, + getSortedBlacklistedVideosList, getVideosList, killallServers, + removeVideoFromBlacklist, searchVideo, ServerInfo, setAccessTokensToServers, - uploadVideo + updateVideo, + updateVideoBlacklist, + uploadVideo, + viewVideo } from '../../../../shared/utils/index' import { doubleFollow } from '../../../../shared/utils/server/follows' import { waitJobs } from '../../../../shared/utils/server/jobs' +import { VideoBlacklist } from '../../../../shared/models/videos' const expect = chai.expect -describe('Test video blacklists', function () { +describe('Test video blacklist management', function () { let servers: ServerInfo[] = [] + let videoId: number + + async function blacklistVideosOnServer (server: ServerInfo) { + const res = await getVideosList(server.url) + + const videos = res.body.data + for (let video of videos) { + await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') + } + } before(async function () { this.timeout(50000) @@ -32,58 +51,270 @@ describe('Test video blacklists', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - // Upload a video on server 2 - const videoAttributes = { - name: 'my super name for server 2', - description: 'my super description for server 2' - } - await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes) + // Upload 2 videos on server 2 + await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 1st video', description: 'A video on server 2' }) + await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' }) // Wait videos propagation, server 2 has transcoding enabled await waitJobs(servers) - const res = await getVideosList(servers[0].url) - const videos = res.body.data + // Blacklist the two videos on server 1 + await blacklistVideosOnServer(servers[0]) + }) + + describe('When listing/searching videos', function () { - expect(videos.length).to.equal(1) + it('Should not have the video blacklisted in videos list/search on server 1', async function () { + { + const res = await getVideosList(servers[ 0 ].url) - servers[0].remoteVideo = videos.find(video => video.name === 'my super name for server 2') + expect(res.body.total).to.equal(0) + expect(res.body.data).to.be.an('array') + expect(res.body.data.length).to.equal(0) + } + + { + const res = await searchVideo(servers[ 0 ].url, 'name') + + expect(res.body.total).to.equal(0) + expect(res.body.data).to.be.an('array') + expect(res.body.data.length).to.equal(0) + } + }) + + it('Should have the blacklisted video in videos list/search on server 2', async function () { + { + const res = await getVideosList(servers[ 1 ].url) + + expect(res.body.total).to.equal(2) + expect(res.body.data).to.be.an('array') + expect(res.body.data.length).to.equal(2) + } + + { + const res = await searchVideo(servers[ 1 ].url, 'video') + + expect(res.body.total).to.equal(2) + expect(res.body.data).to.be.an('array') + expect(res.body.data.length).to.equal(2) + } + }) }) - it('Should blacklist a remote video on server 1', async function () { - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, servers[0].remoteVideo.id) + describe('When listing blacklisted videos', function () { + it('Should display all the blacklisted videos', async function () { + const res = await getBlacklistedVideosList(servers[0].url, servers[0].accessToken) + + expect(res.body.total).to.equal(2) + + const blacklistedVideos = res.body.data + expect(blacklistedVideos).to.be.an('array') + expect(blacklistedVideos.length).to.equal(2) + + for (const blacklistedVideo of blacklistedVideos) { + expect(blacklistedVideo.reason).to.equal('super reason') + videoId = blacklistedVideo.video.id + } + }) + + it('Should get the correct sort when sorting by descending id', async function () { + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-id') + expect(res.body.total).to.equal(2) + + const blacklistedVideos = res.body.data + expect(blacklistedVideos).to.be.an('array') + expect(blacklistedVideos.length).to.equal(2) + + const result = orderBy(res.body.data, [ 'id' ], [ 'desc' ]) + + expect(blacklistedVideos).to.deep.equal(result) + }) + + it('Should get the correct sort when sorting by descending video name', async function () { + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') + expect(res.body.total).to.equal(2) + + const blacklistedVideos = res.body.data + expect(blacklistedVideos).to.be.an('array') + expect(blacklistedVideos.length).to.equal(2) + + const result = orderBy(res.body.data, [ 'name' ], [ 'desc' ]) + + expect(blacklistedVideos).to.deep.equal(result) + }) + + it('Should get the correct sort when sorting by ascending creation date', async function () { + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') + expect(res.body.total).to.equal(2) + + const blacklistedVideos = res.body.data + expect(blacklistedVideos).to.be.an('array') + expect(blacklistedVideos.length).to.equal(2) + + const result = orderBy(res.body.data, [ 'createdAt' ]) + + expect(blacklistedVideos).to.deep.equal(result) + }) }) - it('Should not have the video blacklisted in videos list on server 1', async function () { - const res = await getVideosList(servers[0].url) + describe('When updating blacklisted videos', function () { + it('Should change the reason', async function () { + await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') + + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') + const video = res.body.data.find(b => b.video.id === videoId) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data.length).to.equal(0) + expect(video.reason).to.equal('my super reason updated') + }) }) - it('Should not have the video blacklisted in videos search on server 1', async function () { - const res = await searchVideo(servers[0].url, 'name') + describe('When listing my videos', function () { + it('Should display blacklisted videos', async function () { + await blacklistVideosOnServer(servers[1]) + + const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 5) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.be.an('array') - expect(res.body.data.length).to.equal(0) + expect(res.body.total).to.equal(2) + expect(res.body.data).to.have.lengthOf(2) + + for (const video of res.body.data) { + expect(video.blacklisted).to.be.true + expect(video.blacklistedReason).to.equal('super reason') + } + }) }) - it('Should have the blacklisted video in videos list on server 2', async function () { - const res = await getVideosList(servers[1].url) + describe('When removing a blacklisted video', function () { + let videoToRemove: VideoBlacklist + let blacklist = [] + + it('Should not have any video in videos list on server 1', async function () { + const res = await getVideosList(servers[0].url) + expect(res.body.total).to.equal(0) + expect(res.body.data).to.be.an('array') + expect(res.body.data.length).to.equal(0) + }) + + it('Should remove a video from the blacklist on server 1', async function () { + // Get one video in the blacklist + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') + videoToRemove = res.body.data[0] + blacklist = res.body.data.slice(1) + + // Remove it + await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.video.id) + }) + + it('Should have the ex-blacklisted video in videos list on server 1', async function () { + const res = await getVideosList(servers[0].url) + expect(res.body.total).to.equal(1) + + const videos = res.body.data + expect(videos).to.be.an('array') + expect(videos.length).to.equal(1) + + expect(videos[0].name).to.equal(videoToRemove.video.name) + expect(videos[0].id).to.equal(videoToRemove.video.id) + }) + + it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') + expect(res.body.total).to.equal(1) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data.length).to.equal(1) + const videos = res.body.data + expect(videos).to.be.an('array') + expect(videos.length).to.equal(1) + expect(videos).to.deep.equal(blacklist) + }) }) - it('Should have the video blacklisted in videos search on server 2', async function () { - const res = await searchVideo(servers[1].url, 'name') + describe('When blacklisting local videos', function () { + let video3UUID: string + let video4UUID: string + + before(async function () { + this.timeout(10000) + + { + const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'Video 3' }) + video3UUID = res.body.video.uuid + } + { + const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'Video 4' }) + video4UUID = res.body.video.uuid + } + + await waitJobs(servers) + }) + + it('Should blacklist video 3 and keep it federated', async function () { + this.timeout(10000) + + await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video3UUID, 'super reason', false) + + await waitJobs(servers) + + { + const res = await getVideosList(servers[ 0 ].url) + expect(res.body.data.find(v => v.uuid === video3UUID)).to.be.undefined + } + + { + const res = await getVideosList(servers[ 1 ].url) + expect(res.body.data.find(v => v.uuid === video3UUID)).to.not.be.undefined + } + }) + + it('Should unfederate the video', async function () { + this.timeout(10000) + + await addVideoToBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, 'super reason', true) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + expect(res.body.data.find(v => v.uuid === video4UUID)).to.be.undefined + } + }) + + it('Should have the video unfederated even after an Update AP message', async function () { + this.timeout(10000) + + await updateVideo(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID, { description: 'super description' }) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + expect(res.body.data.find(v => v.uuid === video4UUID)).to.be.undefined + } + }) + + it('Should have the correct video blacklist unfederate attribute', async function () { + const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') + + const blacklistedVideos: VideoBlacklist[] = res.body.data + const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) + const video4Blacklisted = blacklistedVideos.find(b => b.video.uuid === video4UUID) + + expect(video3Blacklisted.unfederated).to.be.false + expect(video4Blacklisted.unfederated).to.be.true + }) + + it('Should remove the video from blacklist and refederate the video', async function () { + this.timeout(10000) + + await removeVideoFromBlacklist(servers[ 0 ].url, servers[ 0 ].accessToken, video4UUID) + + await waitJobs(servers) + + for (const server of servers) { + const res = await getVideosList(server.url) + expect(res.body.data.find(v => v.uuid === video4UUID)).to.not.be.undefined + } + }) - expect(res.body.total).to.equal(1) - expect(res.body.data).to.be.an('array') - expect(res.body.data.length).to.equal(1) }) after(async function () { -- cgit v1.2.3 From 092092969633bbcf6d4891a083ea497a7d5c3154 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 29 Jan 2019 08:37:25 +0100 Subject: Add hls support on server --- server/tests/api/videos/index.ts | 1 + server/tests/api/videos/video-hls.ts | 145 +++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 server/tests/api/videos/video-hls.ts (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 97f467aae..a501a80b2 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts @@ -8,6 +8,7 @@ import './video-change-ownership' import './video-channels' import './video-comments' import './video-description' +import './video-hls' import './video-imports' import './video-nsfw' import './video-privacy' diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts new file mode 100644 index 000000000..71d863b12 --- /dev/null +++ b/server/tests/api/videos/video-hls.ts @@ -0,0 +1,145 @@ +/* tslint:disable:no-unused-expression */ + +import * as chai from 'chai' +import 'mocha' +import { + checkDirectoryIsEmpty, + checkTmpIsEmpty, + doubleFollow, + flushAndRunMultipleServers, + flushTests, + getPlaylist, + getSegment, + getSegmentSha256, + getVideo, + killallServers, + removeVideo, + ServerInfo, + setAccessTokensToServers, + updateVideo, + uploadVideo, + waitJobs +} from '../../../../shared/utils' +import { VideoDetails } from '../../../../shared/models/videos' +import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' +import { sha256 } from '../../../helpers/core-utils' +import { join } from 'path' + +const expect = chai.expect + +async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { + const resolutions = [ 240, 360, 480, 720 ] + + for (const server of servers) { + const res = await getVideo(server.url, videoUUID) + const videoDetails: VideoDetails = res.body + + expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) + + const hlsPlaylist = videoDetails.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS) + expect(hlsPlaylist).to.not.be.undefined + + { + const res2 = await getPlaylist(hlsPlaylist.playlistUrl) + + const masterPlaylist = res2.text + + expect(masterPlaylist).to.contain('#EXT-X-STREAM-INF:BANDWIDTH=55472,RESOLUTION=640x360,FRAME-RATE=25') + + for (const resolution of resolutions) { + expect(masterPlaylist).to.contain(`${resolution}.m3u8`) + } + } + + { + for (const resolution of resolutions) { + const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) + + const subPlaylist = res2.text + expect(subPlaylist).to.contain(resolution + '_000.ts') + } + } + + { + for (const resolution of resolutions) { + + const res2 = await getSegment(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}_000.ts`) + + const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) + + const sha256Server = resSha.body[ resolution + '_000.ts' ] + expect(sha256(res2.body)).to.equal(sha256Server) + } + } + } +} + +describe('Test HLS videos', function () { + let servers: ServerInfo[] = [] + let videoUUID = '' + + before(async function () { + this.timeout(120000) + + servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: true, hls: { enabled: true } } }) + + // Get the access tokens + await setAccessTokensToServers(servers) + + // Server 1 and server 2 follow each other + await doubleFollow(servers[0], servers[1]) + }) + + it('Should upload a video and transcode it to HLS', async function () { + this.timeout(120000) + + { + const res = await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) + videoUUID = res.body.video.uuid + } + + await waitJobs(servers) + + await checkHlsPlaylist(servers, videoUUID) + }) + + it('Should update the video', async function () { + await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) + + await waitJobs(servers) + + await checkHlsPlaylist(servers, videoUUID) + }) + + it('Should delete the video', async function () { + await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) + + await waitJobs(servers) + + for (const server of servers) { + await getVideo(server.url, videoUUID, 404) + } + }) + + it('Should have the playlists/segment deleted from the disk', async function () { + for (const server of servers) { + await checkDirectoryIsEmpty(server, 'videos') + await checkDirectoryIsEmpty(server, join('playlists', 'hls')) + } + }) + + it('Should have an empty tmp directory', async function () { + for (const server of servers) { + await checkTmpIsEmpty(server) + } + }) + + after(async function () { + killallServers(servers) + + // Keep the logs if the test failed + if (this['ok']) { + await flushTests() + } + }) +}) -- cgit v1.2.3 From 4c280004ce62bf11ddb091854c28f1e1d54a54d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Feb 2019 15:08:19 +0100 Subject: Use a single file instead of segments for HLS --- server/tests/api/videos/video-hls.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 71d863b12..a1214bad1 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -4,13 +4,12 @@ import * as chai from 'chai' import 'mocha' import { checkDirectoryIsEmpty, + checkSegmentHash, checkTmpIsEmpty, doubleFollow, flushAndRunMultipleServers, flushTests, getPlaylist, - getSegment, - getSegmentSha256, getVideo, killallServers, removeVideo, @@ -22,7 +21,6 @@ import { } from '../../../../shared/utils' import { VideoDetails } from '../../../../shared/models/videos' import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' -import { sha256 } from '../../../helpers/core-utils' import { join } from 'path' const expect = chai.expect @@ -56,19 +54,15 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { const res2 = await getPlaylist(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}.m3u8`) const subPlaylist = res2.text - expect(subPlaylist).to.contain(resolution + '_000.ts') + expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) } } { - for (const resolution of resolutions) { - - const res2 = await getSegment(`http://localhost:9001/static/playlists/hls/${videoUUID}/${resolution}_000.ts`) + const baseUrl = 'http://localhost:9001/static/playlists/hls' - const resSha = await getSegmentSha256(hlsPlaylist.segmentsSha256Url) - - const sha256Server = resSha.body[ resolution + '_000.ts' ] - expect(sha256(res2.body)).to.equal(sha256Server) + for (const resolution of resolutions) { + await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) } } } -- cgit v1.2.3