aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-06 16:43:43 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitc655c9ef6f7ddb47a153adc04d5c10c6de3d5ed7 (patch)
tree7ccb6a7c97345747dde6c53fcd10c488140c7998
parente4bf78561763cd84d22ebceb6f371cccf9a356d8 (diff)
downloadPeerTube-c655c9ef6f7ddb47a153adc04d5c10c6de3d5ed7.tar.gz
PeerTube-c655c9ef6f7ddb47a153adc04d5c10c6de3d5ed7.tar.zst
PeerTube-c655c9ef6f7ddb47a153adc04d5c10c6de3d5ed7.zip
Update ffmpeg static version for tests
-rw-r--r--.github/workflows/test.yml4
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/activitypub/process/process-view.ts6
-rw-r--r--server/lib/live-manager.ts3
-rw-r--r--server/tests/api/live/live.ts6
-rw-r--r--server/tests/api/server/config.ts6
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts4
-rw-r--r--server/tests/plugins/plugin-helpers.ts2
-rw-r--r--shared/extra-utils/server/servers.ts24
9 files changed, 38 insertions, 19 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f0bd3ba37..8b605847e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -55,8 +55,8 @@ jobs:
55 - name: Setup system dependencies 55 - name: Setup system dependencies
56 run: | 56 run: |
57 sudo apt-get install postgresql-client-common redis-tools parallel 57 sudo apt-get install postgresql-client-common redis-tools parallel
58 wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.0.3-64bit-static.tar.xz" 58 wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz"
59 tar xf ffmpeg-release-4.0.3-64bit-static.tar.xz 59 tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz
60 mkdir -p $HOME/bin 60 mkdir -p $HOME/bin
61 cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin 61 cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin
62 echo "::add-path::$HOME/bin" 62 echo "::add-path::$HOME/bin"
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index a93fe3c51..2e45ab256 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -316,7 +316,7 @@ const CONSTRAINTS_FIELDS = {
316 } 316 }
317} 317}
318 318
319let VIEW_LIFETIME = { 319const VIEW_LIFETIME = {
320 VIDEO: 60000 * 60, // 1 hour 320 VIDEO: 60000 * 60, // 1 hour
321 LIVE: 60000 * 5 // 5 minutes 321 LIVE: 60000 * 5 // 5 minutes
322} 322}
diff --git a/server/lib/activitypub/process/process-view.ts b/server/lib/activitypub/process/process-view.ts
index efceb21a2..84697673b 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
31 } 31 }
32 const { video } = await getOrCreateVideoAndAccountAndChannel(options) 32 const { video } = await getOrCreateVideoAndAccountAndChannel(options)
33 33
34 if (!video.isLive) {
35 await Redis.Instance.addVideoView(video.id)
36 }
37
34 if (video.isOwned()) { 38 if (video.isOwned()) {
35 // Our live manager will increment the counter and send the view to followers 39 // Our live manager will increment the counter and send the view to followers
36 if (video.isLive) { 40 if (video.isLive) {
@@ -38,8 +42,6 @@ async function processCreateView (activity: ActivityView | ActivityCreate, byAct
38 return 42 return
39 } 43 }
40 44
41 await Redis.Instance.addVideoView(video.id)
42
43 // Forward the view but don't resend the activity to the sender 45 // Forward the view but don't resend the activity to the sender
44 const exceptions = [ byActor ] 46 const exceptions = [ byActor ]
45 await forwardVideoRelatedActivity(activity, undefined, exceptions, video) 47 await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts
index 4a1081a4f..e85998686 100644
--- a/server/lib/live-manager.ts
+++ b/server/lib/live-manager.ts
@@ -4,6 +4,7 @@ import * as chokidar from 'chokidar'
4import { FfmpegCommand } from 'fluent-ffmpeg' 4import { FfmpegCommand } from 'fluent-ffmpeg'
5import { ensureDir, stat } from 'fs-extra' 5import { ensureDir, stat } from 'fs-extra'
6import { basename } from 'path' 6import { basename } from 'path'
7import { isTestInstance } from '@server/helpers/core-utils'
7import { 8import {
8 computeResolutionsToTranscode, 9 computeResolutionsToTranscode,
9 getVideoFileFPS, 10 getVideoFileFPS,
@@ -451,7 +452,7 @@ class LiveManager {
451 private async updateLiveViews () { 452 private async updateLiveViews () {
452 if (!this.isRunning()) return 453 if (!this.isRunning()) return
453 454
454 logger.info('Updating live video views.') 455 if (!isTestInstance()) logger.info('Updating live video views.')
455 456
456 for (const videoId of this.watchersPerVideo.keys()) { 457 for (const videoId of this.watchersPerVideo.keys()) {
457 const notBefore = new Date().getTime() - VIEW_LIFETIME.LIVE 458 const notBefore = new Date().getTime() - VIEW_LIFETIME.LIVE
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 2198114b4..de3181928 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -121,7 +121,7 @@ describe('Test live', function () {
121 const live: LiveVideo = resLive.body 121 const live: LiveVideo = resLive.body
122 122
123 if (server.url === servers[0].url) { 123 if (server.url === servers[0].url) {
124 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':1936/live') 124 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
125 expect(live.streamKey).to.not.be.empty 125 expect(live.streamKey).to.not.be.empty
126 } else { 126 } else {
127 expect(live.rtmpUrl).to.be.null 127 expect(live.rtmpUrl).to.be.null
@@ -185,7 +185,7 @@ describe('Test live', function () {
185 const live: LiveVideo = res.body 185 const live: LiveVideo = res.body
186 186
187 if (server.url === servers[0].url) { 187 if (server.url === servers[0].url) {
188 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':1936/live') 188 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
189 expect(live.streamKey).to.not.be.empty 189 expect(live.streamKey).to.not.be.empty
190 } else { 190 } else {
191 expect(live.rtmpUrl).to.be.null 191 expect(live.rtmpUrl).to.be.null
@@ -216,7 +216,7 @@ describe('Test live', function () {
216 let rtmpUrl: string 216 let rtmpUrl: string
217 217
218 before(function () { 218 before(function () {
219 rtmpUrl = 'rtmp://' + servers[0].hostname + ':1936' 219 rtmpUrl = 'rtmp://' + servers[0].hostname + ':' + servers[0].rtmpPort + ''
220 }) 220 })
221 221
222 async function createLiveWrapper () { 222 async function createLiveWrapper () {
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 6c37be113..c4dcfd96c 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -79,7 +79,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
79 expect(data.transcoding.hls.enabled).to.be.true 79 expect(data.transcoding.hls.enabled).to.be.true
80 80
81 expect(data.live.enabled).to.be.false 81 expect(data.live.enabled).to.be.false
82 expect(data.live.allowReplay).to.be.true 82 expect(data.live.allowReplay).to.be.false
83 expect(data.live.maxDuration).to.equal(1000 * 3600 * 5) 83 expect(data.live.maxDuration).to.equal(1000 * 3600 * 5)
84 expect(data.live.maxInstanceLives).to.equal(20) 84 expect(data.live.maxInstanceLives).to.equal(20)
85 expect(data.live.maxUserLives).to.equal(3) 85 expect(data.live.maxUserLives).to.equal(3)
@@ -166,7 +166,7 @@ function checkUpdatedConfig (data: CustomConfig) {
166 expect(data.transcoding.webtorrent.enabled).to.be.true 166 expect(data.transcoding.webtorrent.enabled).to.be.true
167 167
168 expect(data.live.enabled).to.be.true 168 expect(data.live.enabled).to.be.true
169 expect(data.live.allowReplay).to.be.false 169 expect(data.live.allowReplay).to.be.true
170 expect(data.live.maxDuration).to.equal(5000) 170 expect(data.live.maxDuration).to.equal(5000)
171 expect(data.live.maxInstanceLives).to.equal(-1) 171 expect(data.live.maxInstanceLives).to.equal(-1)
172 expect(data.live.maxUserLives).to.equal(10) 172 expect(data.live.maxUserLives).to.equal(10)
@@ -332,7 +332,7 @@ describe('Test config', function () {
332 }, 332 },
333 live: { 333 live: {
334 enabled: true, 334 enabled: true,
335 allowReplay: false, 335 allowReplay: true,
336 maxDuration: 5000, 336 maxDuration: 5000,
337 maxInstanceLives: -1, 337 maxInstanceLives: -1,
338 maxUserLives: 10, 338 maxUserLives: 10,
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index d063d7973..c5b28540c 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 () {
61 { 61 {
62 for (const server of servers) { 62 for (const server of servers) {
63 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) 63 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)
64 expect(total).to.equal(2) 64 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
65 } 65 }
66 } 66 }
67 67
68 { 68 {
69 for (const server of servers) { 69 for (const server of servers) {
70 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) 70 const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)
71 expect(total).to.equal(2) 71 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
72 } 72 }
73 } 73 }
74 }) 74 })
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 0915603d0..e76d7917a 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -80,7 +80,7 @@ describe('Test plugin helpers', function () {
80 let videoUUIDServer1: string 80 let videoUUIDServer1: string
81 81
82 before(async function () { 82 before(async function () {
83 this.timeout(15000) 83 this.timeout(30000)
84 84
85 { 85 {
86 const res = await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' }) 86 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 b4bd55968..e26a6937c 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -1,12 +1,12 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
2 2
3import { expect } from 'chai'
3import { ChildProcess, exec, fork } from 'child_process' 4import { ChildProcess, exec, fork } from 'child_process'
4import { join } from 'path'
5import { root, wait } from '../miscs/miscs'
6import { copy, pathExists, readdir, readFile, remove } from 'fs-extra' 5import { copy, pathExists, readdir, readFile, remove } from 'fs-extra'
7import { expect } from 'chai' 6import { join } from 'path'
8import { VideoChannel } from '../../models/videos'
9import { randomInt } from '../../core-utils/miscs/miscs' 7import { randomInt } from '../../core-utils/miscs/miscs'
8import { VideoChannel } from '../../models/videos'
9import { root, wait } from '../miscs/miscs'
10 10
11interface ServerInfo { 11interface ServerInfo {
12 app: ChildProcess 12 app: ChildProcess
@@ -16,6 +16,8 @@ interface ServerInfo {
16 hostname: string 16 hostname: string
17 port: number 17 port: number
18 18
19 rtmpPort: number
20
19 parallel: boolean 21 parallel: boolean
20 internalServerNumber: number 22 internalServerNumber: number
21 serverNumber: number 23 serverNumber: number
@@ -95,10 +97,18 @@ function randomServer () {
95 return randomInt(low, high) 97 return randomInt(low, high)
96} 98}
97 99
100function randomRTMP () {
101 const low = 1900
102 const high = 2100
103
104 return randomInt(low, high)
105}
106
98async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) { 107async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) {
99 const parallel = parallelTests() 108 const parallel = parallelTests()
100 109
101 const internalServerNumber = parallel ? randomServer() : serverNumber 110 const internalServerNumber = parallel ? randomServer() : serverNumber
111 const rtmpPort = parallel ? randomRTMP() : null
102 const port = 9000 + internalServerNumber 112 const port = 9000 + internalServerNumber
103 113
104 await flushTests(internalServerNumber) 114 await flushTests(internalServerNumber)
@@ -107,6 +117,7 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object,
107 app: null, 117 app: null,
108 port, 118 port,
109 internalServerNumber, 119 internalServerNumber,
120 rtmpPort,
110 parallel, 121 parallel,
111 serverNumber, 122 serverNumber,
112 url: `http://localhost:${port}`, 123 url: `http://localhost:${port}`,
@@ -178,6 +189,11 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
178 }, 189 },
179 admin: { 190 admin: {
180 email: `admin${server.internalServerNumber}@example.com` 191 email: `admin${server.internalServerNumber}@example.com`
192 },
193 live: {
194 rtmp: {
195 port: server.rtmpPort
196 }
181 } 197 }
182 }) 198 })
183 } 199 }