aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/server')
-rw-r--r--shared/extra-utils/server/debug-command.ts32
-rw-r--r--shared/extra-utils/server/debug.ts33
-rw-r--r--shared/extra-utils/server/index.ts1
-rw-r--r--shared/extra-utils/server/jobs.ts9
-rw-r--r--shared/extra-utils/server/servers.ts3
5 files changed, 40 insertions, 38 deletions
diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts
new file mode 100644
index 000000000..eecbb1711
--- /dev/null
+++ b/shared/extra-utils/server/debug-command.ts
@@ -0,0 +1,32 @@
1import { Debug, SendDebugCommand } from '@shared/models'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4
5export class DebugCommand extends AbstractCommand {
6
7 getDebug (options: OverrideCommandOptions = {}) {
8 const path = '/api/v1/server/debug'
9
10 return this.getRequestBody<Debug>({
11 ...options,
12
13 path,
14 defaultExpectedStatus: HttpStatusCode.OK_200
15 })
16 }
17
18 sendCommand (options: OverrideCommandOptions & {
19 body: SendDebugCommand
20 }) {
21 const { body } = options
22 const path = '/api/v1/server/debug/run-command'
23
24 return this.postBodyRequest({
25 ...options,
26
27 path,
28 fields: body,
29 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
30 })
31 }
32}
diff --git a/shared/extra-utils/server/debug.ts b/shared/extra-utils/server/debug.ts
deleted file mode 100644
index f196812b7..000000000
--- a/shared/extra-utils/server/debug.ts
+++ /dev/null
@@ -1,33 +0,0 @@
1import { makeGetRequest, makePostBodyRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3import { SendDebugCommand } from '@shared/models'
4
5function getDebug (url: string, token: string) {
6 const path = '/api/v1/server/debug'
7
8 return makeGetRequest({
9 url,
10 path,
11 token,
12 statusCodeExpected: HttpStatusCode.OK_200
13 })
14}
15
16function sendDebugCommand (url: string, token: string, body: SendDebugCommand) {
17 const path = '/api/v1/server/debug/run-command'
18
19 return makePostBodyRequest({
20 url,
21 path,
22 token,
23 fields: body,
24 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
25 })
26}
27
28// ---------------------------------------------------------------------------
29
30export {
31 getDebug,
32 sendDebugCommand
33}
diff --git a/shared/extra-utils/server/index.ts b/shared/extra-utils/server/index.ts
index 4121c8828..f0071ba72 100644
--- a/shared/extra-utils/server/index.ts
+++ b/shared/extra-utils/server/index.ts
@@ -1 +1,2 @@
1export * from './contact-form-command' 1export * from './contact-form-command'
2export * from './debug-command'
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index 763374e03..a3683913a 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -1,7 +1,7 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3import { getDebug, makeGetRequest } from '../../../shared/extra-utils' 3import { makeGetRequest } from '../../../shared/extra-utils'
4import { Job, JobState, JobType, ServerDebug } from '../../models' 4import { Job, JobState, JobType } from '../../models'
5import { wait } from '../miscs/miscs' 5import { wait } from '../miscs/miscs'
6import { ServerInfo } from './servers' 6import { ServerInfo } from './servers'
7 7
@@ -90,9 +90,8 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
90 tasks.push(p) 90 tasks.push(p)
91 } 91 }
92 92
93 const p = getDebug(server.url, server.accessToken) 93 const p = server.debugCommand.getDebug()
94 .then(res => res.body) 94 .then(obj => {
95 .then((obj: ServerDebug) => {
96 if (obj.activityPubMessagesWaiting !== 0) { 95 if (obj.activityPubMessagesWaiting !== 0) {
97 pendingRequests = true 96 pendingRequests = true
98 } 97 }
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index b58639ba6..30e712ab8 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -17,6 +17,7 @@ import { OverviewsCommand } from '../overviews'
17import { makeGetRequest } from '../requests/requests' 17import { makeGetRequest } from '../requests/requests'
18import { SearchCommand } from '../search' 18import { SearchCommand } from '../search'
19import { ContactFormCommand } from './contact-form-command' 19import { ContactFormCommand } from './contact-form-command'
20import { DebugCommand } from './debug-command'
20 21
21interface ServerInfo { 22interface ServerInfo {
22 app: ChildProcess 23 app: ChildProcess
@@ -79,6 +80,7 @@ interface ServerInfo {
79 overviewsCommand?: OverviewsCommand 80 overviewsCommand?: OverviewsCommand
80 searchCommand?: SearchCommand 81 searchCommand?: SearchCommand
81 contactFormCommand?: ContactFormCommand 82 contactFormCommand?: ContactFormCommand
83 debugCommand?: DebugCommand
82} 84}
83 85
84function parallelTests () { 86function parallelTests () {
@@ -293,6 +295,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
293 server.overviewsCommand = new OverviewsCommand(server) 295 server.overviewsCommand = new OverviewsCommand(server)
294 server.searchCommand = new SearchCommand(server) 296 server.searchCommand = new SearchCommand(server)
295 server.contactFormCommand = new ContactFormCommand(server) 297 server.contactFormCommand = new ContactFormCommand(server)
298 server.debugCommand = new DebugCommand(server)
296 299
297 res(server) 300 res(server)
298 }) 301 })