From 7243f84db0f34c6d5610a54603b0cce7c284a7b3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Apr 2019 17:14:49 +0200 Subject: Redundancy and search tests in parallel too --- server/tests/api/videos/multiple-servers.ts | 41 ++++++++++++++--------------- server/tests/api/videos/services.ts | 10 +++---- server/tests/api/videos/single-server.ts | 4 +-- server/tests/api/videos/video-abuse.ts | 9 +++---- server/tests/api/videos/video-channels.ts | 6 ++--- server/tests/api/videos/video-comments.ts | 6 ++--- server/tests/api/videos/video-hls.ts | 9 +++---- server/tests/api/videos/video-transcoder.ts | 18 ++++++------- 8 files changed, 50 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 68c1e9a8d..89904759a 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -9,18 +9,17 @@ import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/ import { addVideoChannel, checkTmpIsEmpty, - checkVideoFilesWereRemoved, cleanupTests, + checkVideoFilesWereRemoved, + cleanupTests, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers, - flushTests, getLocalVideos, getVideo, getVideoChannelsList, getVideosList, - killallServers, rateVideo, removeVideo, ServerInfo, @@ -110,7 +109,7 @@ describe('Test multiple servers', function () { // All servers should have this video let publishedAt: string = null for (const server of servers) { - const isLocal = server.url === 'http://localhost:9001' + const isLocal = server.url === 'http://localhost:' + servers[0].port const checkAttributes = { name: 'my super name for server 1', category: 5, @@ -122,7 +121,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-10T13:38:14.449Z', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + servers[0].port }, isLocal, publishedAt, @@ -187,7 +186,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:9002' + const isLocal = server.url === 'http://localhost:' + servers[1].port const checkAttributes = { name: 'my super name for server 2', category: 4, @@ -198,7 +197,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 2', account: { name: 'user1', - host: 'localhost:9002' + host: 'localhost:' + servers[1].port }, isLocal, commentsEnabled: true, @@ -278,7 +277,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:9003' + const isLocal = server.url === 'http://localhost:' + servers[2].port const res = await getVideosList(server.url) const videos = res.body.data @@ -306,7 +305,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, isLocal, duration: 5, @@ -340,7 +339,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3-2', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, commentsEnabled: true, downloadEnabled: true, @@ -646,7 +645,7 @@ describe('Test multiple servers', function () { const videoUpdated = videos.find(video => video.name === 'my super video updated') expect(!!videoUpdated).to.be.true - const isLocal = server.url === 'http://localhost:9003' + const isLocal = server.url === 'http://localhost:' + servers[2].port const checkAttributes = { name: 'my super video updated', category: 10, @@ -658,7 +657,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-11T13:38:14.449Z', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, isLocal, duration: 5, @@ -813,7 +812,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') + expect(comment.account.host).to.equal('localhost:' + servers[0].port) expect(comment.totalReplies).to.equal(3) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -824,7 +823,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9003') + expect(comment.account.host).to.equal('localhost:' + servers[2].port) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -842,25 +841,25 @@ describe('Test multiple servers', function () { const tree: VideoCommentThreadTree = res2.body expect(tree.comment.text).equal('my super first comment') expect(tree.comment.account.name).equal('root') - expect(tree.comment.account.host).equal('localhost:9001') + expect(tree.comment.account.host).equal('localhost:' + servers[0].port) expect(tree.children).to.have.lengthOf(2) const firstChild = tree.children[0] expect(firstChild.comment.text).to.equal('my super answer to thread 1') expect(firstChild.comment.account.name).equal('root') - expect(firstChild.comment.account.host).equal('localhost:9002') + expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port) expect(firstChild.children).to.have.lengthOf(1) childOfFirstChild = firstChild.children[0] expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') expect(childOfFirstChild.comment.account.name).equal('root') - expect(childOfFirstChild.comment.account.host).equal('localhost:9003') + expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port) expect(childOfFirstChild.children).to.have.lengthOf(0) const secondChild = tree.children[1] expect(secondChild.comment.text).to.equal('my second answer to thread 1') expect(secondChild.comment.account.name).equal('root') - expect(secondChild.comment.account.host).equal('localhost:9003') + expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port) expect(secondChild.children).to.have.lengthOf(0) } }) @@ -915,7 +914,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9003') + expect(comment.account.host).to.equal('localhost:' + servers[2].port) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -971,7 +970,7 @@ describe('Test multiple servers', function () { const res = await getVideosList(server.url) const video = res.body.data.find(v => v.name === 'minimum parameters') - const isLocal = server.url === 'http://localhost:9002' + const isLocal = server.url === 'http://localhost:' + servers[1].port const checkAttributes = { name: 'minimum parameters', category: null, @@ -982,7 +981,7 @@ describe('Test multiple servers', function () { support: null, account: { name: 'root', - host: 'localhost:9002' + host: 'localhost:' + servers[1].port }, isLocal, duration: 5, diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index e9ad947b2..38e232e5f 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts @@ -27,13 +27,13 @@ describe('Test services', function () { }) it('Should have a valid oEmbed response', async function () { - const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid + const oembedUrl = 'http://localhost:' + server.port + '/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' + const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg' expect(res.body.html).to.equal(expectedHtml) expect(res.body.title).to.equal(server.video.name) @@ -46,14 +46,14 @@ describe('Test services', function () { }) it('Should have a valid oEmbed response with small max height query', async function () { - const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid + const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid const format = 'json' const maxHeight = 50 const maxWidth = 50 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) const expectedHtml = '' expect(res.body.html).to.equal(expectedHtml) diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 1f366b642..b0412f4df 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -47,7 +47,7 @@ describe('Test a single server', function () { support: 'my super support text', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + server.port }, isLocal: true, duration: 5, @@ -80,7 +80,7 @@ describe('Test a single server', function () { support: 'my super support text updated', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + server.port }, isLocal: true, tags: [ 'tagup1', 'tagup2' ], diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index 7318497d5..a2f3ee161 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts @@ -9,7 +9,6 @@ import { flushAndRunMultipleServers, getVideoAbusesList, getVideosList, - killallServers, reportVideoAbuse, ServerInfo, setAccessTokensToServers, @@ -90,7 +89,7 @@ describe('Test video abuses', function () { const abuse: VideoAbuse = res1.body.data[0] expect(abuse.reason).to.equal('my super bad reason') expect(abuse.reporterAccount.name).to.equal('root') - expect(abuse.reporterAccount.host).to.equal('localhost:9001') + expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse.video.id).to.equal(servers[0].video.id) const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) @@ -118,7 +117,7 @@ describe('Test video abuses', function () { const abuse1: VideoAbuse = res1.body.data[0] expect(abuse1.reason).to.equal('my super bad reason') expect(abuse1.reporterAccount.name).to.equal('root') - expect(abuse1.reporterAccount.host).to.equal('localhost:9001') + expect(abuse1.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse1.video.id).to.equal(servers[0].video.id) expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) expect(abuse1.state.label).to.equal('Pending') @@ -127,7 +126,7 @@ describe('Test video abuses', function () { const abuse2: VideoAbuse = res1.body.data[1] expect(abuse2.reason).to.equal('my super bad reason 2') expect(abuse2.reporterAccount.name).to.equal('root') - expect(abuse2.reporterAccount.host).to.equal('localhost:9001') + expect(abuse2.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse2.video.id).to.equal(servers[1].video.id) expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING) expect(abuse2.state.label).to.equal('Pending') @@ -141,7 +140,7 @@ describe('Test video abuses', function () { abuseServer2 = res2.body.data[0] expect(abuseServer2.reason).to.equal('my super bad reason 2') expect(abuseServer2.reporterAccount.name).to.equal('root') - expect(abuseServer2.reporterAccount.host).to.equal('localhost:9001') + expect(abuseServer2.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING) expect(abuseServer2.state.label).to.equal('Pending') expect(abuseServer2.moderationComment).to.be.null diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 345e96f43..f09148404 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -213,7 +213,7 @@ describe('Test video channels', function () { this.timeout(10000) for (const server of servers) { - const channelURI = 'second_video_channel@localhost:9001' + const channelURI = 'second_video_channel@localhost:' + server.port const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) expect(res1.body.total).to.equal(1) expect(res1.body.data).to.be.an('array') @@ -234,11 +234,11 @@ describe('Test video channels', function () { this.timeout(10000) for (const server of servers) { - const secondChannelURI = 'second_video_channel@localhost:9001' + const secondChannelURI = 'second_video_channel@localhost:' + server.port const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) expect(res1.body.total).to.equal(0) - const channelURI = 'root_channel@localhost:9001' + const channelURI = 'root_channel@localhost:' + server.port const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) expect(res2.body.total).to.equal(1) diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 22fd8c058..82182cc7c 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -66,8 +66,8 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') - expect(comment.account.url).to.equal('http://localhost:9001/accounts/root') + expect(comment.account.host).to.equal('localhost:' + server.port) + expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root') expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -86,7 +86,7 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') + expect(comment.account.host).to.equal('localhost:' + server.port) await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 22031c18b..4565d0ebe 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -5,13 +5,12 @@ import 'mocha' import { checkDirectoryIsEmpty, checkSegmentHash, - checkTmpIsEmpty, cleanupTests, + checkTmpIsEmpty, + cleanupTests, doubleFollow, flushAndRunMultipleServers, - flushTests, getPlaylist, getVideo, - killallServers, removeVideo, ServerInfo, setAccessTokensToServers, @@ -51,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { { for (const resolution of resolutions) { - const res2 = await getPlaylist(`http://localhost:9001/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) + const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) const subPlaylist = res2.text expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) @@ -59,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { } { - const baseUrl = 'http://localhost:9001/static/streaming-playlists/hls' + const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls' for (const resolution of resolutions) { await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 3cd43e99b..45a8c09f0 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -6,21 +6,21 @@ import { omit } from 'lodash' import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { - buildAbsoluteFixturePath, cleanupTests, + buildAbsoluteFixturePath, + cleanupTests, doubleFollow, flushAndRunMultipleServers, generateHighBitrateVideo, getMyVideos, getVideo, getVideosList, - killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, webtorrentAdd } from '../../../../shared/extra-utils' -import { extname, join } from 'path' +import { join } from 'path' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' @@ -121,7 +121,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') const probe = await audio.get(path) if (probe.audioStream) { @@ -152,7 +152,7 @@ describe('Test video transcoding', function () { const videoDetails: VideoDetails = res2.body expect(videoDetails.files).to.have.lengthOf(4) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') const probe = await audio.get(path) expect(probe).to.not.have.property('audioStream') } @@ -179,7 +179,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) const fixtureVideoProbe = await audio.get(fixturePath) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') 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' ] @@ -216,13 +216,13 @@ describe('Test video transcoding', function () { expect(videoDetails.files[ 3 ].fps).to.be.below(31) for (const resolution of [ '240', '360', '480' ]) { - const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') const fps = await getVideoFileFPS(path) expect(fps).to.be.below(31) } - const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') const fps = await getVideoFileFPS(path) expect(fps).to.be.above(58).and.below(62) @@ -310,7 +310,7 @@ describe('Test video transcoding', function () { 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 path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) const resolution2 = await getVideoFileResolution(path) -- cgit v1.2.3