diff options
Diffstat (limited to 'shared/server-commands/server')
-rw-r--r-- | shared/server-commands/server/config-command.ts | 5 | ||||
-rw-r--r-- | shared/server-commands/server/directories.ts | 34 | ||||
-rw-r--r-- | shared/server-commands/server/index.ts | 3 | ||||
-rw-r--r-- | shared/server-commands/server/jobs-command.ts | 3 | ||||
-rw-r--r-- | shared/server-commands/server/jobs.ts | 2 | ||||
-rw-r--r-- | shared/server-commands/server/plugins.ts | 18 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 8 | ||||
-rw-r--r-- | shared/server-commands/server/servers-command.ts | 4 | ||||
-rw-r--r-- | shared/server-commands/server/servers.ts | 2 | ||||
-rw-r--r-- | shared/server-commands/server/tracker.ts | 27 |
10 files changed, 11 insertions, 95 deletions
diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index 89ae8eb4f..797231b1d 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { merge } from 'lodash' | 1 | import { merge } from 'lodash' |
2 | import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@shared/models' | ||
2 | import { DeepPartial } from '@shared/typescript-utils' | 3 | import { DeepPartial } from '@shared/typescript-utils' |
3 | import { About, HttpStatusCode, ServerConfig } from '@shared/models' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command' |
4 | import { CustomConfig } from '../../models/server/custom-config.model' | ||
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
6 | 5 | ||
7 | export class ConfigCommand extends AbstractCommand { | 6 | export class ConfigCommand extends AbstractCommand { |
8 | 7 | ||
diff --git a/shared/server-commands/server/directories.ts b/shared/server-commands/server/directories.ts deleted file mode 100644 index e6f72d6fc..000000000 --- a/shared/server-commands/server/directories.ts +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { pathExists, readdir } from 'fs-extra' | ||
5 | import { join } from 'path' | ||
6 | import { root } from '@shared/core-utils' | ||
7 | import { PeerTubeServer } from './server' | ||
8 | |||
9 | async function checkTmpIsEmpty (server: PeerTubeServer) { | ||
10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) | ||
11 | |||
12 | if (await pathExists(join('test' + server.internalServerNumber, 'tmp', 'hls'))) { | ||
13 | await checkDirectoryIsEmpty(server, 'tmp/hls') | ||
14 | } | ||
15 | } | ||
16 | |||
17 | async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { | ||
18 | const testDirectory = 'test' + server.internalServerNumber | ||
19 | |||
20 | const directoryPath = join(root(), testDirectory, directory) | ||
21 | |||
22 | const directoryExists = await pathExists(directoryPath) | ||
23 | expect(directoryExists).to.be.true | ||
24 | |||
25 | const files = await readdir(directoryPath) | ||
26 | const filtered = files.filter(f => exceptions.includes(f) === false) | ||
27 | |||
28 | expect(filtered).to.have.lengthOf(0) | ||
29 | } | ||
30 | |||
31 | export { | ||
32 | checkTmpIsEmpty, | ||
33 | checkDirectoryIsEmpty | ||
34 | } | ||
diff --git a/shared/server-commands/server/index.ts b/shared/server-commands/server/index.ts index 76a2099da..0a4b21fc4 100644 --- a/shared/server-commands/server/index.ts +++ b/shared/server-commands/server/index.ts | |||
@@ -1,17 +1,14 @@ | |||
1 | export * from './config-command' | 1 | export * from './config-command' |
2 | export * from './contact-form-command' | 2 | export * from './contact-form-command' |
3 | export * from './debug-command' | 3 | export * from './debug-command' |
4 | export * from './directories' | ||
5 | export * from './follows-command' | 4 | export * from './follows-command' |
6 | export * from './follows' | 5 | export * from './follows' |
7 | export * from './jobs' | 6 | export * from './jobs' |
8 | export * from './jobs-command' | 7 | export * from './jobs-command' |
9 | export * from './object-storage-command' | 8 | export * from './object-storage-command' |
10 | export * from './plugins-command' | 9 | export * from './plugins-command' |
11 | export * from './plugins' | ||
12 | export * from './redundancy-command' | 10 | export * from './redundancy-command' |
13 | export * from './server' | 11 | export * from './server' |
14 | export * from './servers-command' | 12 | export * from './servers-command' |
15 | export * from './servers' | 13 | export * from './servers' |
16 | export * from './stats-command' | 14 | export * from './stats-command' |
17 | export * from './tracker' | ||
diff --git a/shared/server-commands/server/jobs-command.ts b/shared/server-commands/server/jobs-command.ts index 6636e7e4d..ac62157d1 100644 --- a/shared/server-commands/server/jobs-command.ts +++ b/shared/server-commands/server/jobs-command.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { pick } from '@shared/core-utils' | 1 | import { pick } from '@shared/core-utils' |
2 | import { HttpStatusCode } from '@shared/models' | 2 | import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@shared/models' |
3 | import { Job, JobState, JobType, ResultList } from '../../models' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 4 | ||
6 | export class JobsCommand extends AbstractCommand { | 5 | export class JobsCommand extends AbstractCommand { |
diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.ts index 34fefd444..fc65a873b 100644 --- a/shared/server-commands/server/jobs.ts +++ b/shared/server-commands/server/jobs.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | 1 | ||
2 | import { expect } from 'chai' | 2 | import { expect } from 'chai' |
3 | import { wait } from '@shared/core-utils' | ||
3 | import { JobState, JobType } from '../../models' | 4 | import { JobState, JobType } from '../../models' |
4 | import { wait } from '../miscs' | ||
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
7 | async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) { | 7 | async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) { |
diff --git a/shared/server-commands/server/plugins.ts b/shared/server-commands/server/plugins.ts deleted file mode 100644 index c6316898d..000000000 --- a/shared/server-commands/server/plugins.ts +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { PeerTubeServer } from './server' | ||
5 | |||
6 | async function testHelloWorldRegisteredSettings (server: PeerTubeServer) { | ||
7 | const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) | ||
8 | |||
9 | const registeredSettings = body.registeredSettings | ||
10 | expect(registeredSettings).to.have.length.at.least(1) | ||
11 | |||
12 | const adminNameSettings = registeredSettings.find(s => s.name === 'admin-name') | ||
13 | expect(adminNameSettings).to.not.be.undefined | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | testHelloWorldRegisteredSettings | ||
18 | } | ||
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index 339b9cabb..617069b11 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -1,14 +1,14 @@ | |||
1 | import { ChildProcess, fork } from 'child_process' | 1 | import { ChildProcess, fork } from 'child_process' |
2 | import { copy } from 'fs-extra' | 2 | import { copy } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root, randomInt } from '@shared/core-utils' | 4 | import { parallelTests, randomInt, root } from '@shared/core-utils' |
5 | import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '../../models/videos' | 5 | import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '@shared/models' |
6 | import { BulkCommand } from '../bulk' | 6 | import { BulkCommand } from '../bulk' |
7 | import { CLICommand } from '../cli' | 7 | import { CLICommand } from '../cli' |
8 | import { CustomPagesCommand } from '../custom-pages' | 8 | import { CustomPagesCommand } from '../custom-pages' |
9 | import { FeedCommand } from '../feeds' | 9 | import { FeedCommand } from '../feeds' |
10 | import { LogsCommand } from '../logs' | 10 | import { LogsCommand } from '../logs' |
11 | import { parallelTests, SQLCommand } from '../miscs' | 11 | import { SQLCommand } from '../miscs' |
12 | import { AbusesCommand } from '../moderation' | 12 | import { AbusesCommand } from '../moderation' |
13 | import { OverviewsCommand } from '../overviews' | 13 | import { OverviewsCommand } from '../overviews' |
14 | import { SearchCommand } from '../search' | 14 | import { SearchCommand } from '../search' |
@@ -33,11 +33,11 @@ import { ContactFormCommand } from './contact-form-command' | |||
33 | import { DebugCommand } from './debug-command' | 33 | import { DebugCommand } from './debug-command' |
34 | import { FollowsCommand } from './follows-command' | 34 | import { FollowsCommand } from './follows-command' |
35 | import { JobsCommand } from './jobs-command' | 35 | import { JobsCommand } from './jobs-command' |
36 | import { ObjectStorageCommand } from './object-storage-command' | ||
36 | import { PluginsCommand } from './plugins-command' | 37 | import { PluginsCommand } from './plugins-command' |
37 | import { RedundancyCommand } from './redundancy-command' | 38 | import { RedundancyCommand } from './redundancy-command' |
38 | import { ServersCommand } from './servers-command' | 39 | import { ServersCommand } from './servers-command' |
39 | import { StatsCommand } from './stats-command' | 40 | import { StatsCommand } from './stats-command' |
40 | import { ObjectStorageCommand } from './object-storage-command' | ||
41 | 41 | ||
42 | export type RunServerOptions = { | 42 | export type RunServerOptions = { |
43 | hideLogs?: boolean | 43 | hideLogs?: boolean |
diff --git a/shared/server-commands/server/servers-command.ts b/shared/server-commands/server/servers-command.ts index 47420c95f..c5d8d18dc 100644 --- a/shared/server-commands/server/servers-command.ts +++ b/shared/server-commands/server/servers-command.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { exec } from 'child_process' | 1 | import { exec } from 'child_process' |
2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' | 2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' |
3 | import { basename, join } from 'path' | 3 | import { basename, join } from 'path' |
4 | import { root } from '@shared/core-utils' | 4 | import { isGithubCI, root, wait } from '@shared/core-utils' |
5 | import { getFileSize } from '@shared/extra-utils' | ||
5 | import { HttpStatusCode } from '@shared/models' | 6 | import { HttpStatusCode } from '@shared/models' |
6 | import { getFileSize, isGithubCI, wait } from '../miscs' | ||
7 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 7 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
8 | 8 | ||
9 | export class ServersCommand extends AbstractCommand { | 9 | export class ServersCommand extends AbstractCommand { |
diff --git a/shared/server-commands/server/servers.ts b/shared/server-commands/server/servers.ts index 21ab9405b..0faee3a8d 100644 --- a/shared/server-commands/server/servers.ts +++ b/shared/server-commands/server/servers.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ensureDir } from 'fs-extra' | 1 | import { ensureDir } from 'fs-extra' |
2 | import { isGithubCI } from '../miscs' | 2 | import { isGithubCI } from '@shared/core-utils' |
3 | import { PeerTubeServer, RunServerOptions } from './server' | 3 | import { PeerTubeServer, RunServerOptions } from './server' |
4 | 4 | ||
5 | async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) { | 5 | async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) { |
diff --git a/shared/server-commands/server/tracker.ts b/shared/server-commands/server/tracker.ts deleted file mode 100644 index ed43a5924..000000000 --- a/shared/server-commands/server/tracker.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import { expect } from 'chai' | ||
2 | import { sha1 } from '@shared/core-utils/crypto' | ||
3 | import { makeGetRequest } from '../requests' | ||
4 | |||
5 | async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { | ||
6 | const path = '/tracker/announce' | ||
7 | |||
8 | const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`) | ||
9 | |||
10 | // From bittorrent-tracker | ||
11 | const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) { | ||
12 | return '%' + char.charCodeAt(0).toString(16).toUpperCase() | ||
13 | }) | ||
14 | |||
15 | const res = await makeGetRequest({ | ||
16 | url: serverUrl, | ||
17 | path, | ||
18 | rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`, | ||
19 | expectedStatus: 200 | ||
20 | }) | ||
21 | |||
22 | expect(res.text).to.not.contain('failure') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | hlsInfohashExist | ||
27 | } | ||