aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 09:04:35 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit89d241a79c262b9775c233b73cff080043ebb5e6 (patch)
treecb3b6cb431d25d891ef4e02f66c61d252d17048f /shared/extra-utils/server
parentd23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff)
downloadPeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst
PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip
Shorter server command names
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r--shared/extra-utils/server/follows.ts4
-rw-r--r--shared/extra-utils/server/jobs.ts4
-rw-r--r--shared/extra-utils/server/plugins-command.ts2
-rw-r--r--shared/extra-utils/server/plugins.ts2
-rw-r--r--shared/extra-utils/server/servers-command.ts6
-rw-r--r--shared/extra-utils/server/servers.ts230
6 files changed, 124 insertions, 124 deletions
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts
index c23cebd81..50ae898cc 100644
--- a/shared/extra-utils/server/follows.ts
+++ b/shared/extra-utils/server/follows.ts
@@ -3,8 +3,8 @@ import { ServerInfo } from './servers'
3 3
4async function doubleFollow (server1: ServerInfo, server2: ServerInfo) { 4async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
5 await Promise.all([ 5 await Promise.all([
6 server1.followsCommand.follow({ targets: [ server2.url ] }), 6 server1.follows.follow({ targets: [ server2.url ] }),
7 server2.followsCommand.follow({ targets: [ server1.url ] }) 7 server2.follows.follow({ targets: [ server1.url ] })
8 ]) 8 ])
9 9
10 // Wait request propagation 10 // Wait request propagation
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index 36ef882b3..754530977 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -23,7 +23,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
23 // Check if each server has pending request 23 // Check if each server has pending request
24 for (const server of servers) { 24 for (const server of servers) {
25 for (const state of states) { 25 for (const state of states) {
26 const p = server.jobsCommand.getJobsList({ 26 const p = server.jobs.getJobsList({
27 state, 27 state,
28 start: 0, 28 start: 0,
29 count: 10, 29 count: 10,
@@ -39,7 +39,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
39 tasks.push(p) 39 tasks.push(p)
40 } 40 }
41 41
42 const p = server.debugCommand.getDebug() 42 const p = server.debug.getDebug()
43 .then(obj => { 43 .then(obj => {
44 if (obj.activityPubMessagesWaiting !== 0) { 44 if (obj.activityPubMessagesWaiting !== 0) {
45 pendingRequests = true 45 pendingRequests = true
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts
index 5bed51d1a..98049ce19 100644
--- a/shared/extra-utils/server/plugins-command.ts
+++ b/shared/extra-utils/server/plugins-command.ts
@@ -251,6 +251,6 @@ export class PluginsCommand extends AbstractCommand {
251 } 251 }
252 252
253 private getPackageJSONPath (npmName: string) { 253 private getPackageJSONPath (npmName: string) {
254 return this.server.serversCommand.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json')) 254 return this.server.servers.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
255 } 255 }
256} 256}
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 1084ea4f4..d1cc7e383 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
4import { ServerInfo } from '../server/servers' 4import { ServerInfo } from '../server/servers'
5 5
6async function testHelloWorldRegisteredSettings (server: ServerInfo) { 6async function testHelloWorldRegisteredSettings (server: ServerInfo) {
7 const body = await server.pluginsCommand.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' }) 7 const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
8 8
9 const registeredSettings = body.registeredSettings 9 const registeredSettings = body.registeredSettings
10 expect(registeredSettings).to.have.length.at.least(1) 10 expect(registeredSettings).to.have.length.at.least(1)
diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts
index 9ef68fede..a7c5a868d 100644
--- a/shared/extra-utils/server/servers-command.ts
+++ b/shared/extra-utils/server/servers-command.ts
@@ -37,7 +37,7 @@ export class ServersCommand extends AbstractCommand {
37 if (isGithubCI()) { 37 if (isGithubCI()) {
38 await ensureDir('artifacts') 38 await ensureDir('artifacts')
39 39
40 const origin = this.server.serversCommand.buildDirectory('logs/peertube.log') 40 const origin = this.server.servers.buildDirectory('logs/peertube.log')
41 const destname = `peertube-${this.server.internalServerNumber}.log` 41 const destname = `peertube-${this.server.internalServerNumber}.log`
42 console.log('Saving logs %s.', destname) 42 console.log('Saving logs %s.', destname)
43 43
@@ -56,7 +56,7 @@ export class ServersCommand extends AbstractCommand {
56 } 56 }
57 57
58 async waitUntilLog (str: string, count = 1, strictCount = true) { 58 async waitUntilLog (str: string, count = 1, strictCount = true) {
59 const logfile = this.server.serversCommand.buildDirectory('logs/peertube.log') 59 const logfile = this.server.servers.buildDirectory('logs/peertube.log')
60 60
61 while (true) { 61 while (true) {
62 const buf = await readFile(logfile) 62 const buf = await readFile(logfile)
@@ -74,7 +74,7 @@ export class ServersCommand extends AbstractCommand {
74 } 74 }
75 75
76 async getServerFileSize (subPath: string) { 76 async getServerFileSize (subPath: string) {
77 const path = this.server.serversCommand.buildDirectory(subPath) 77 const path = this.server.servers.buildDirectory(subPath)
78 78
79 return getFileSize(path) 79 return getFileSize(path)
80 } 80 }
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index fda5c3d6d..ea3f19a92 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -53,83 +53,81 @@ interface ServerInfo {
53 53
54 parallel?: boolean 54 parallel?: boolean
55 internalServerNumber: number 55 internalServerNumber: number
56
56 serverNumber?: number 57 serverNumber?: number
58 customConfigFile?: string
57 59
58 client?: { 60 store?: {
59 id?: string 61 client?: {
60 secret?: string 62 id?: string
61 } 63 secret?: string
64 }
62 65
63 user?: { 66 user?: {
64 username: string 67 username: string
65 password: string 68 password: string
66 email?: string 69 email?: string
67 } 70 }
68 71
69 customConfigFile?: string 72 channel?: VideoChannel
70 73
71 accessToken?: string 74 video?: {
72 refreshToken?: string 75 id: number
73 videoChannel?: VideoChannel 76 uuid: string
77 shortUUID: string
78 name?: string
79 url?: string
74 80
75 video?: { 81 account?: {
76 id: number 82 name: string
77 uuid: string 83 }
78 shortUUID: string
79 name?: string
80 url?: string
81 84
82 account?: { 85 embedPath?: string
83 name: string
84 } 86 }
85 87
86 embedPath?: string 88 videos?: { id: number, uuid: string }[]
87 } 89 }
88 90
89 remoteVideo?: { 91 accessToken?: string
90 id: number 92 refreshToken?: string
91 uuid: string
92 }
93 93
94 videos?: { id: number, uuid: string }[] 94 bulk?: BulkCommand
95 95 cli?: CLICommand
96 bulkCommand?: BulkCommand 96 customPage?: CustomPagesCommand
97 cliCommand?: CLICommand 97 feed?: FeedCommand
98 customPageCommand?: CustomPagesCommand 98 logs?: LogsCommand
99 feedCommand?: FeedCommand 99 abuses?: AbusesCommand
100 logsCommand?: LogsCommand 100 overviews?: OverviewsCommand
101 abusesCommand?: AbusesCommand 101 search?: SearchCommand
102 overviewsCommand?: OverviewsCommand 102 contactForm?: ContactFormCommand
103 searchCommand?: SearchCommand 103 debug?: DebugCommand
104 contactFormCommand?: ContactFormCommand 104 follows?: FollowsCommand
105 debugCommand?: DebugCommand 105 jobs?: JobsCommand
106 followsCommand?: FollowsCommand 106 plugins?: PluginsCommand
107 jobsCommand?: JobsCommand 107 redundancy?: RedundancyCommand
108 pluginsCommand?: PluginsCommand 108 stats?: StatsCommand
109 redundancyCommand?: RedundancyCommand 109 config?: ConfigCommand
110 statsCommand?: StatsCommand 110 socketIO?: SocketIOCommand
111 configCommand?: ConfigCommand 111 accounts?: AccountsCommand
112 socketIOCommand?: SocketIOCommand 112 blocklist?: BlocklistCommand
113 accountsCommand?: AccountsCommand 113 subscriptions?: SubscriptionsCommand
114 blocklistCommand?: BlocklistCommand 114 live?: LiveCommand
115 subscriptionsCommand?: SubscriptionsCommand 115 services?: ServicesCommand
116 liveCommand?: LiveCommand 116 blacklist?: BlacklistCommand
117 servicesCommand?: ServicesCommand 117 captions?: CaptionsCommand
118 blacklistCommand?: BlacklistCommand 118 changeOwnership?: ChangeOwnershipCommand
119 captionsCommand?: CaptionsCommand 119 playlists?: PlaylistsCommand
120 changeOwnershipCommand?: ChangeOwnershipCommand 120 history?: HistoryCommand
121 playlistsCommand?: PlaylistsCommand 121 imports?: ImportsCommand
122 historyCommand?: HistoryCommand 122 streamingPlaylists?: StreamingPlaylistsCommand
123 importsCommand?: ImportsCommand 123 channels?: ChannelsCommand
124 streamingPlaylistsCommand?: StreamingPlaylistsCommand 124 comments?: CommentsCommand
125 channelsCommand?: ChannelsCommand 125 sql?: SQLCommand
126 commentsCommand?: CommentsCommand 126 notifications?: NotificationsCommand
127 sqlCommand?: SQLCommand 127 servers?: ServersCommand
128 notificationsCommand?: NotificationsCommand 128 login?: LoginCommand
129 serversCommand?: ServersCommand 129 users?: UsersCommand
130 loginCommand?: LoginCommand 130 videos?: VideosCommand
131 usersCommand?: UsersCommand
132 videosCommand?: VideosCommand
133} 131}
134 132
135function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) { 133function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
@@ -189,13 +187,15 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object,
189 url: `http://localhost:${port}`, 187 url: `http://localhost:${port}`,
190 host: `localhost:${port}`, 188 host: `localhost:${port}`,
191 hostname: 'localhost', 189 hostname: 'localhost',
192 client: { 190 store: {
193 id: null, 191 client: {
194 secret: null 192 id: null,
195 }, 193 secret: null
196 user: { 194 },
197 username: null, 195 user: {
198 password: null 196 username: null,
197 password: null
198 }
199 } 199 }
200 } 200 }
201 201
@@ -291,10 +291,10 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
291 const regexp = regexps[key] 291 const regexp = regexps[key]
292 const matches = data.toString().match(regexp) 292 const matches = data.toString().match(regexp)
293 if (matches !== null) { 293 if (matches !== null) {
294 if (key === 'client_id') server.client.id = matches[1] 294 if (key === 'client_id') server.store.client.id = matches[1]
295 else if (key === 'client_secret') server.client.secret = matches[1] 295 else if (key === 'client_secret') server.store.client.secret = matches[1]
296 else if (key === 'user_username') server.user.username = matches[1] 296 else if (key === 'user_username') server.store.user.username = matches[1]
297 else if (key === 'user_password') server.user.password = matches[1] 297 else if (key === 'user_password') server.store.user.password = matches[1]
298 } 298 }
299 } 299 }
300 300
@@ -327,43 +327,43 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
327} 327}
328 328
329function assignCommands (server: ServerInfo) { 329function assignCommands (server: ServerInfo) {
330 server.bulkCommand = new BulkCommand(server) 330 server.bulk = new BulkCommand(server)
331 server.cliCommand = new CLICommand(server) 331 server.cli = new CLICommand(server)
332 server.customPageCommand = new CustomPagesCommand(server) 332 server.customPage = new CustomPagesCommand(server)
333 server.feedCommand = new FeedCommand(server) 333 server.feed = new FeedCommand(server)
334 server.logsCommand = new LogsCommand(server) 334 server.logs = new LogsCommand(server)
335 server.abusesCommand = new AbusesCommand(server) 335 server.abuses = new AbusesCommand(server)
336 server.overviewsCommand = new OverviewsCommand(server) 336 server.overviews = new OverviewsCommand(server)
337 server.searchCommand = new SearchCommand(server) 337 server.search = new SearchCommand(server)
338 server.contactFormCommand = new ContactFormCommand(server) 338 server.contactForm = new ContactFormCommand(server)
339 server.debugCommand = new DebugCommand(server) 339 server.debug = new DebugCommand(server)
340 server.followsCommand = new FollowsCommand(server) 340 server.follows = new FollowsCommand(server)
341 server.jobsCommand = new JobsCommand(server) 341 server.jobs = new JobsCommand(server)
342 server.pluginsCommand = new PluginsCommand(server) 342 server.plugins = new PluginsCommand(server)
343 server.redundancyCommand = new RedundancyCommand(server) 343 server.redundancy = new RedundancyCommand(server)
344 server.statsCommand = new StatsCommand(server) 344 server.stats = new StatsCommand(server)
345 server.configCommand = new ConfigCommand(server) 345 server.config = new ConfigCommand(server)
346 server.socketIOCommand = new SocketIOCommand(server) 346 server.socketIO = new SocketIOCommand(server)
347 server.accountsCommand = new AccountsCommand(server) 347 server.accounts = new AccountsCommand(server)
348 server.blocklistCommand = new BlocklistCommand(server) 348 server.blocklist = new BlocklistCommand(server)
349 server.subscriptionsCommand = new SubscriptionsCommand(server) 349 server.subscriptions = new SubscriptionsCommand(server)
350 server.liveCommand = new LiveCommand(server) 350 server.live = new LiveCommand(server)
351 server.servicesCommand = new ServicesCommand(server) 351 server.services = new ServicesCommand(server)
352 server.blacklistCommand = new BlacklistCommand(server) 352 server.blacklist = new BlacklistCommand(server)
353 server.captionsCommand = new CaptionsCommand(server) 353 server.captions = new CaptionsCommand(server)
354 server.changeOwnershipCommand = new ChangeOwnershipCommand(server) 354 server.changeOwnership = new ChangeOwnershipCommand(server)
355 server.playlistsCommand = new PlaylistsCommand(server) 355 server.playlists = new PlaylistsCommand(server)
356 server.historyCommand = new HistoryCommand(server) 356 server.history = new HistoryCommand(server)
357 server.importsCommand = new ImportsCommand(server) 357 server.imports = new ImportsCommand(server)
358 server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server) 358 server.streamingPlaylists = new StreamingPlaylistsCommand(server)
359 server.channelsCommand = new ChannelsCommand(server) 359 server.channels = new ChannelsCommand(server)
360 server.commentsCommand = new CommentsCommand(server) 360 server.comments = new CommentsCommand(server)
361 server.sqlCommand = new SQLCommand(server) 361 server.sql = new SQLCommand(server)
362 server.notificationsCommand = new NotificationsCommand(server) 362 server.notifications = new NotificationsCommand(server)
363 server.serversCommand = new ServersCommand(server) 363 server.servers = new ServersCommand(server)
364 server.loginCommand = new LoginCommand(server) 364 server.login = new LoginCommand(server)
365 server.usersCommand = new UsersCommand(server) 365 server.users = new UsersCommand(server)
366 server.videosCommand = new VideosCommand(server) 366 server.videos = new VideosCommand(server)
367} 367}
368 368
369async function reRunServer (server: ServerInfo, configOverride?: any) { 369async function reRunServer (server: ServerInfo, configOverride?: any) {
@@ -377,7 +377,7 @@ async function killallServers (servers: ServerInfo[]) {
377 for (const server of servers) { 377 for (const server of servers) {
378 if (!server.app) continue 378 if (!server.app) continue
379 379
380 await server.sqlCommand.cleanup() 380 await server.sql.cleanup()
381 381
382 process.kill(-server.app.pid) 382 process.kill(-server.app.pid)
383 383
@@ -394,7 +394,7 @@ async function cleanupTests (servers: ServerInfo[]) {
394 394
395 let p: Promise<any>[] = [] 395 let p: Promise<any>[] = []
396 for (const server of servers) { 396 for (const server of servers) {
397 p = p.concat(server.serversCommand.cleanupTests()) 397 p = p.concat(server.servers.cleanupTests())
398 } 398 }
399 399
400 return Promise.all(p) 400 return Promise.all(p)