From 1a980208c780cad68f5095810c7f97a492083c03 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Nov 2020 16:43:43 +0100 Subject: [PATCH] Update ffmpeg static version for tests --- .github/workflows/test.yml | 2 +- server/initializers/constants.ts | 2 +- server/lib/activitypub/process/process-view.ts | 6 ++++-- server/tests/api/live/live.ts | 6 +++--- server/tests/api/videos/videos-views-cleaner.ts | 4 ++-- server/tests/plugins/plugin-helpers.ts | 2 +- shared/extra-utils/server/servers.ts | 15 +++++++++++++++ 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0bd3ba3734b..d134ba667610 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: - name: Setup system dependencies run: | sudo apt-get install postgresql-client-common redis-tools parallel - wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.0.3-64bit-static.tar.xz" + wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz" tar xf ffmpeg-release-4.0.3-64bit-static.tar.xz mkdir -p $HOME/bin cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index a93fe3c516fb..2e45ab256b6d 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -316,7 +316,7 @@ const CONSTRAINTS_FIELDS = { } } -let VIEW_LIFETIME = { +const VIEW_LIFETIME = { VIDEO: 60000 * 60, // 1 hour LIVE: 60000 * 5 // 5 minutes } diff --git a/server/lib/activitypub/process/process-view.ts b/server/lib/activitypub/process/process-view.ts index efceb21a207f..84697673b6ee 100644 --- a/server/lib/activitypub/process/process-view.ts +++ b/server/lib/activitypub/process/process-view.ts @@ -31,6 +31,10 @@ async function processCreateView (activity: ActivityView | ActivityCreate, byAct } const { video } = await getOrCreateVideoAndAccountAndChannel(options) + if (!video.isLive) { + await Redis.Instance.addVideoView(video.id) + } + if (video.isOwned()) { // Our live manager will increment the counter and send the view to followers if (video.isLive) { @@ -38,8 +42,6 @@ async function processCreateView (activity: ActivityView | ActivityCreate, byAct return } - await Redis.Instance.addVideoView(video.id) - // Forward the view but don't resend the activity to the sender const exceptions = [ byActor ] await forwardVideoRelatedActivity(activity, undefined, exceptions, video) diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 2198114b4e39..b8d05997c867 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -121,7 +121,7 @@ describe('Test live', function () { const live: LiveVideo = resLive.body if (server.url === servers[0].url) { - expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':1936/live') + expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + server.rtmpPort + '/live') expect(live.streamKey).to.not.be.empty } else { expect(live.rtmpUrl).to.be.null @@ -185,7 +185,7 @@ describe('Test live', function () { const live: LiveVideo = res.body if (server.url === servers[0].url) { - expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':1936/live') + expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + server.rtmpPort + '/live') expect(live.streamKey).to.not.be.empty } else { expect(live.rtmpUrl).to.be.null @@ -216,7 +216,7 @@ describe('Test live', function () { let rtmpUrl: string before(function () { - rtmpUrl = 'rtmp://' + servers[0].hostname + ':1936' + rtmpUrl = 'rtmp://' + servers[0].hostname + ':' + server.rtmpPort + '' }) async function createLiveWrapper () { diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index d063d7973628..c5b28540cc04 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts @@ -61,14 +61,14 @@ describe('Test video views cleaner', function () { { for (const server of servers) { const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) - expect(total).to.equal(2) + expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') } } { for (const server of servers) { const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) - expect(total).to.equal(2) + expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') } } }) diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 0915603d046b..e76d7917a1a8 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -80,7 +80,7 @@ describe('Test plugin helpers', function () { let videoUUIDServer1: string before(async function () { - this.timeout(15000) + this.timeout(30000) { const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index b4bd55968b98..4111bd1eae39 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -7,6 +7,7 @@ import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' import { expect } from 'chai' import { VideoChannel } from '../../models/videos' import { randomInt } from '../../core-utils/miscs/miscs' +import { isNpmPluginNameValid } from '@server/helpers/custom-validators/plugins' interface ServerInfo { app: ChildProcess @@ -16,6 +17,8 @@ interface ServerInfo { hostname: string port: number + rtmpPort: number + parallel: boolean internalServerNumber: number serverNumber: number @@ -95,10 +98,18 @@ function randomServer () { return randomInt(low, high) } +function randomRTMP () { + const low = 1900 + const high = 2100 + + return randomInt(low, high) +} + async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) { const parallel = parallelTests() const internalServerNumber = parallel ? randomServer() : serverNumber + const rtmpPort = parallel ? randomRTMP() : null const port = 9000 + internalServerNumber await flushTests(internalServerNumber) @@ -107,6 +118,7 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object, app: null, port, internalServerNumber, + rtmpPort, parallel, serverNumber, url: `http://localhost:${port}`, @@ -178,6 +190,9 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] }, admin: { email: `admin${server.internalServerNumber}@example.com` + }, + live: { + port: server.rtmpPort } }) }