Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix tests

Chocobozzz402d472a56a5
diff --git a/apps/peertube-runner/src/peertube-runner.ts b/apps/peertube-runner/src/peertube-runner.ts
index 05662028ad..737fe9807a 100644
--- a/apps/peertube-runner/src/peertube-runner.ts
+++ b/apps/peertube-runner/src/peertube-runner.ts
@@ -31,8 +31,8 @@ program.command('server')
.option(
'--enable-job <type>',
'Enable this job type (multiple --enable-job options can be specified). ' +
- 'By default all supported jobs are enabled). ' +
- 'Supported job types: ' + getSupportedJobsList().join(', '),
+ 'By default all supported jobs are enabled). ' +
+ 'Supported job types: ' + getSupportedJobsList().join(', '),
(value: RunnerJobType, previous: RunnerJobType[]) => [ ...previous, value ],
[]
)
@@ -124,6 +124,12 @@ program.command('graceful-shutdown')
}
})
+program.command('get-config-file-path')
+ .description('Get the path to the configuration file')
+ .action(() => {
+ console.log(ConfigManager.Instance.getConfigDirectory())
+ })
+
program.parse()
// ---------------------------------------------------------------------------
diff --git a/apps/peertube-runner/src/server/server.ts b/apps/peertube-runner/src/server/server.ts
index 02e0a00077..404853b9e7 100644
--- a/apps/peertube-runner/src/server/server.ts
+++ b/apps/peertube-runner/src/server/server.ts
@@ -82,6 +82,8 @@ export class RunnerServer {
logger.info(`Using ${ConfigManager.Instance.getTranscodingDirectory()} for transcoding directory`)
logger.info(`Using ${ConfigManager.Instance.getStoryboardDirectory()} for storyboard directory`)
+ logger.info(`Server is ready to process jobs`)
+
this.initialized = true
await this.checkAvailableJobs()
}
diff --git a/apps/peertube-runner/src/shared/config-manager.ts b/apps/peertube-runner/src/shared/config-manager.ts
index a4d01a2026..dd0c3d1a2f 100644
--- a/apps/peertube-runner/src/shared/config-manager.ts
+++ b/apps/peertube-runner/src/shared/config-manager.ts
@@ -1,7 +1,7 @@
import { parse, stringify } from '@iarna/toml'
import { TranscriptionEngineName, WhisperBuiltinModelName } from '@peertube/peertube-transcription'
import envPaths from 'env-paths'
-import { ensureDir, pathExists, remove } from 'fs-extra/esm'
+import { ensureDir, pathExists } from 'fs-extra/esm'
import { readFile, writeFile } from 'fs/promises'
import merge from 'lodash-es/merge.js'
import { dirname, join } from 'path'
@@ -64,14 +64,13 @@ export class ConfigManager {
this.configFilePath = join(this.getConfigDir(), 'config.toml')
}
+ getConfigDirectory () {
+ return this.configFilePath
+ }
+
async load () {
logger.info(`Using ${this.configFilePath} as configuration file`)
- if (this.isTestInstance()) {
- logger.info('Removing configuration file as we are using the "test" id')
- await remove(this.configFilePath)
- }
-
await ensureDir(dirname(this.configFilePath))
if (!await pathExists(this.configFilePath)) {
@@ -132,8 +131,6 @@ export class ConfigManager {
return join(paths.config, this.id)
}
- // ---------------------------------------------------------------------------
-
isTestInstance () {
return typeof this.id === 'string' && this.id.match(/^test-\d$/)
}
diff --git a/packages/tests/src/api/server/stun.ts b/packages/tests/src/api/server/stun.ts
index 863cddcd0a..381bb5670e 100644
--- a/packages/tests/src/api/server/stun.ts
+++ b/packages/tests/src/api/server/stun.ts
@@ -69,7 +69,7 @@ async function testStun (url: string) {
socket.once('message', msg => {
try {
const { ip, port } = parseAddress(msg, txid)
- expect(+port).to.be.below(65000).and.above(1024)
+ expect(+port).to.be.below(65535).and.above(1024)
expect(ip.split('.')).to.have.lengthOf(4)
clearTimeout(timeout)
socket.close()
diff --git a/packages/tests/src/peertube-runner/video-state.ts b/packages/tests/src/peertube-runner/video-state.ts
index a972980cd9..4db4b3f5ad 100644
--- a/packages/tests/src/peertube-runner/video-state.ts
+++ b/packages/tests/src/peertube-runner/video-state.ts
@@ -39,6 +39,8 @@ describe('Test video state on peertube runners', function () {
peertubeRunner = new PeerTubeRunnerProcess(servers[0])
await peertubeRunner.runServer()
+ await peertubeRunner.setConcurrency(1)
+
await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' })
await servers[0].config.setTranscodingConcurrency(1)
@@ -148,8 +150,8 @@ describe('Test video state on peertube runners', function () {
{ type: 'vod-web-video-transcoding', resolution: 720 },
{ type: 'vod-hls-transcoding', resolution: 720 },
{ type: 'vod-web-video-transcoding', resolution: 240 },
- { type: 'vod-web-video-transcoding', resolution: 144 },
{ type: 'vod-hls-transcoding', resolution: 240 },
+ { type: 'vod-web-video-transcoding', resolution: 144 },
{ type: 'vod-hls-transcoding', resolution: 144 }
]
})
diff --git a/packages/tests/src/plugins/filter-hooks.ts b/packages/tests/src/plugins/filter-hooks.ts
index 6872687fcb..c5f15a42a9 100644
--- a/packages/tests/src/plugins/filter-hooks.ts
+++ b/packages/tests/src/plugins/filter-hooks.ts
@@ -25,9 +25,9 @@ import {
waitJobs
} from '@peertube/peertube-server-commands'
import { expectEndWith } from '@tests/shared/checks.js'
+import { MockSmtpServer } from '@tests/shared/mock-servers/index.js'
import { expect } from 'chai'
import { FIXTURE_URLS } from '../shared/fixture-urls.js'
-import { MockSmtpServer } from '@tests/shared/mock-servers/index.js'
describe('Test plugin filter hooks', function () {
let servers: PeerTubeServer[]
@@ -209,9 +209,9 @@ describe('Test plugin filter hooks', function () {
describe('Video/live/import accept', function () {
it('Should run filter:api.video.upload.accept.result', async function () {
- const options = { attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
- await servers[0].videos.upload({ mode: 'legacy', ...options })
- await servers[0].videos.upload({ mode: 'resumable', ...options })
+ const options = { attributes: { name: 'video with bad word' } }
+ await servers[0].videos.upload({ mode: 'legacy', ...options, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].videos.upload({ mode: 'resumable', ...options, completedExpectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.update-file.accept.result', async function () {
diff --git a/packages/tests/src/shared/peertube-runner-process.ts b/packages/tests/src/shared/peertube-runner-process.ts
index 8b1f95711b..cac51e9ec6 100644
--- a/packages/tests/src/shared/peertube-runner-process.ts
+++ b/packages/tests/src/shared/peertube-runner-process.ts
@@ -3,21 +3,32 @@ import { root } from '@peertube/peertube-node-utils'
import { PeerTubeServer } from '@peertube/peertube-server-commands'
import { ChildProcess, fork, ForkOptions } from 'child_process'
import { execaNode } from 'execa'
+import { remove } from 'fs-extra'
+import { readFile, writeFile } from 'fs/promises'
import { join } from 'path'
+type RunOptions = {
+ jobType?: RunnerJobType
+ hideLogs?: boolean // default true
+ autoDeleteConfig?: boolean // default true
+}
export class PeerTubeRunnerProcess {
private app?: ChildProcess
+ private runOptions: RunOptions
constructor (private readonly server: PeerTubeServer) {
}
- runServer (options: {
- jobType?: RunnerJobType
- hideLogs?: boolean // default true
- } = {}) {
- const { jobType, hideLogs = true } = options
+ runServer (options: RunOptions = {}) {
+ this.runOptions = options
+
+ const { jobType, hideLogs = true, autoDeleteConfig = true } = options
+
+ return new Promise<void>(async (res, rej) => {
+ if (autoDeleteConfig) {
+ await remove(await this.getConfigFilePath())
+ }
- return new Promise<void>((res, rej) => {
const args = [ 'server', '--verbose', ...this.buildIdArg() ]
if (jobType) {
@@ -43,9 +54,11 @@ export class PeerTubeRunnerProcess {
if (!hideLogs) {
console.log(str)
}
- })
- res()
+ if (data.toString().includes('Server is ready to process jobs')) {
+ res()
+ }
+ })
})
}
@@ -120,6 +133,20 @@ export class PeerTubeRunnerProcess {
// ---------------------------------------------------------------------------
+ async setConcurrency (concurrency: number) {
+ this.kill()
+
+ const configFilePath = await this.getConfigFilePath()
+
+ const content = await readFile(configFilePath, 'utf-8')
+
+ await writeFile(configFilePath, content.replace(/concurrency = \d+/, `concurrency = ${concurrency}`))
+
+ await this.runServer({ ...this.runOptions, autoDeleteConfig: false })
+ }
+
+ // ---------------------------------------------------------------------------
+
getId () {
return 'test-' + this.server.internalServerNumber
}
@@ -135,4 +162,12 @@ export class PeerTubeRunnerProcess {
private runCommand (path: string, args: string[]) {
return execaNode(path, args, { env: { ...process.env, NODE_OPTIONS: '' } })
}
+
+ private async getConfigFilePath () {
+ const args = [ 'get-config-file-path', ...this.buildIdArg() ]
+
+ const { stdout } = await this.runCommand(this.getRunnerPath(), args)
+
+ return stdout.trim()
+ }
}
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index 3e9278177b..e1e00f62af 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -9106,6 +9106,7 @@ components:
deprecated: true
type: string
thumbnails:
+ description: "**PeerTube >= 8.1** Array of thumbnails for the video"
type: array
items:
$ref: '#/components/schemas/Thumbnail'
@@ -9443,6 +9444,7 @@ components:
deprecated: true
type: string
thumbnails:
+ description: "**PeerTube >= 8.1** Array of thumbnails for the video"
type: array
items:
$ref: '#/components/schemas/Thumbnail'
@@ -9531,6 +9533,7 @@ components:
deprecated: true
type: string
thumbnails:
+ description: "**PeerTube >= 8.1** Array of thumbnails for the video"
type: array
items:
$ref: '#/components/schemas/Thumbnail'