diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-06 10:34:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:16 +0200 |
commit | a92ddacb38a4a17e117ca9ed41680a03580fb81d (patch) | |
tree | 7b7fc6ef31e86870cee20b915e05c49af1910055 /server/tests/api | |
parent | f59545d97a80bf06025bf6343a80d834c7eb237f (diff) | |
download | PeerTube-a92ddacb38a4a17e117ca9ed41680a03580fb81d.tar.gz PeerTube-a92ddacb38a4a17e117ca9ed41680a03580fb81d.tar.zst PeerTube-a92ddacb38a4a17e117ca9ed41680a03580fb81d.zip |
Introduce logs command
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/server/logs.ts | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts index bc398ea73..ab83a329f 100644 --- a/server/tests/api/server/logs.ts +++ b/server/tests/api/server/logs.ts | |||
@@ -6,25 +6,28 @@ import { | |||
6 | cleanupTests, | 6 | cleanupTests, |
7 | flushAndRunServer, | 7 | flushAndRunServer, |
8 | killallServers, | 8 | killallServers, |
9 | LogsCommand, | ||
9 | makePingRequest, | 10 | makePingRequest, |
10 | reRunServer, | 11 | reRunServer, |
11 | ServerInfo, | 12 | ServerInfo, |
12 | setAccessTokensToServers | 13 | setAccessTokensToServers, |
13 | } from '../../../../shared/extra-utils/index' | 14 | uploadVideo, |
14 | import { getAuditLogs, getLogs } from '../../../../shared/extra-utils/logs/logs' | 15 | waitJobs |
15 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 16 | } from '@shared/extra-utils' |
16 | import { uploadVideo } from '../../../../shared/extra-utils/videos/videos' | ||
17 | 17 | ||
18 | const expect = chai.expect | 18 | const expect = chai.expect |
19 | 19 | ||
20 | describe('Test logs', function () { | 20 | describe('Test logs', function () { |
21 | let server: ServerInfo | 21 | let server: ServerInfo |
22 | let logsCommand: LogsCommand | ||
22 | 23 | ||
23 | before(async function () { | 24 | before(async function () { |
24 | this.timeout(30000) | 25 | this.timeout(30000) |
25 | 26 | ||
26 | server = await flushAndRunServer(1) | 27 | server = await flushAndRunServer(1) |
27 | await setAccessTokensToServers([ server ]) | 28 | await setAccessTokensToServers([ server ]) |
29 | |||
30 | logsCommand = server.logsCommand | ||
28 | }) | 31 | }) |
29 | 32 | ||
30 | describe('With the standard log file', function () { | 33 | describe('With the standard log file', function () { |
@@ -40,8 +43,8 @@ describe('Test logs', function () { | |||
40 | await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) | 43 | await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) |
41 | await waitJobs([ server ]) | 44 | await waitJobs([ server ]) |
42 | 45 | ||
43 | const res = await getLogs(server.url, server.accessToken, now) | 46 | const body = await logsCommand.getLogs({ startDate: now }) |
44 | const logsString = JSON.stringify(res.body) | 47 | const logsString = JSON.stringify(body) |
45 | 48 | ||
46 | expect(logsString.includes('video 1')).to.be.false | 49 | expect(logsString.includes('video 1')).to.be.false |
47 | expect(logsString.includes('video 2')).to.be.true | 50 | expect(logsString.includes('video 2')).to.be.true |
@@ -63,8 +66,8 @@ describe('Test logs', function () { | |||
63 | await uploadVideo(server.url, server.accessToken, { name: 'video 5' }) | 66 | await uploadVideo(server.url, server.accessToken, { name: 'video 5' }) |
64 | await waitJobs([ server ]) | 67 | await waitJobs([ server ]) |
65 | 68 | ||
66 | const res = await getLogs(server.url, server.accessToken, now1, now2) | 69 | const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 }) |
67 | const logsString = JSON.stringify(res.body) | 70 | const logsString = JSON.stringify(body) |
68 | 71 | ||
69 | expect(logsString.includes('video 3')).to.be.false | 72 | expect(logsString.includes('video 3')).to.be.false |
70 | expect(logsString.includes('video 4')).to.be.true | 73 | expect(logsString.includes('video 4')).to.be.true |
@@ -80,15 +83,15 @@ describe('Test logs', function () { | |||
80 | await waitJobs([ server ]) | 83 | await waitJobs([ server ]) |
81 | 84 | ||
82 | { | 85 | { |
83 | const res = await getLogs(server.url, server.accessToken, now, undefined, 'info') | 86 | const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) |
84 | const logsString = JSON.stringify(res.body) | 87 | const logsString = JSON.stringify(body) |
85 | 88 | ||
86 | expect(logsString.includes('video 6')).to.be.true | 89 | expect(logsString.includes('video 6')).to.be.true |
87 | } | 90 | } |
88 | 91 | ||
89 | { | 92 | { |
90 | const res = await getLogs(server.url, server.accessToken, now, undefined, 'warn') | 93 | const body = await logsCommand.getLogs({ startDate: now, level: 'warn' }) |
91 | const logsString = JSON.stringify(res.body) | 94 | const logsString = JSON.stringify(body) |
92 | 95 | ||
93 | expect(logsString.includes('video 6')).to.be.false | 96 | expect(logsString.includes('video 6')).to.be.false |
94 | } | 97 | } |
@@ -101,8 +104,8 @@ describe('Test logs', function () { | |||
101 | 104 | ||
102 | await makePingRequest(server) | 105 | await makePingRequest(server) |
103 | 106 | ||
104 | const res = await getLogs(server.url, server.accessToken, now, undefined, 'info') | 107 | const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) |
105 | const logsString = JSON.stringify(res.body) | 108 | const logsString = JSON.stringify(body) |
106 | 109 | ||
107 | expect(logsString.includes('/api/v1/ping')).to.be.true | 110 | expect(logsString.includes('/api/v1/ping')).to.be.true |
108 | }) | 111 | }) |
@@ -118,8 +121,8 @@ describe('Test logs', function () { | |||
118 | 121 | ||
119 | await makePingRequest(server) | 122 | await makePingRequest(server) |
120 | 123 | ||
121 | const res = await getLogs(server.url, server.accessToken, now, undefined, 'info') | 124 | const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) |
122 | const logsString = JSON.stringify(res.body) | 125 | const logsString = JSON.stringify(body) |
123 | 126 | ||
124 | expect(logsString.includes('/api/v1/ping')).to.be.false | 127 | expect(logsString.includes('/api/v1/ping')).to.be.false |
125 | }) | 128 | }) |
@@ -137,15 +140,15 @@ describe('Test logs', function () { | |||
137 | await uploadVideo(server.url, server.accessToken, { name: 'video 8' }) | 140 | await uploadVideo(server.url, server.accessToken, { name: 'video 8' }) |
138 | await waitJobs([ server ]) | 141 | await waitJobs([ server ]) |
139 | 142 | ||
140 | const res = await getAuditLogs(server.url, server.accessToken, now) | 143 | const body = await logsCommand.getAuditLogs({ startDate: now }) |
141 | const logsString = JSON.stringify(res.body) | 144 | const logsString = JSON.stringify(body) |
142 | 145 | ||
143 | expect(logsString.includes('video 7')).to.be.false | 146 | expect(logsString.includes('video 7')).to.be.false |
144 | expect(logsString.includes('video 8')).to.be.true | 147 | expect(logsString.includes('video 8')).to.be.true |
145 | 148 | ||
146 | expect(res.body).to.have.lengthOf(1) | 149 | expect(body).to.have.lengthOf(1) |
147 | 150 | ||
148 | const item = res.body[0] | 151 | const item = body[0] |
149 | 152 | ||
150 | const message = JSON.parse(item.message) | 153 | const message = JSON.parse(item.message) |
151 | expect(message.domain).to.equal('videos') | 154 | expect(message.domain).to.equal('videos') |
@@ -168,8 +171,8 @@ describe('Test logs', function () { | |||
168 | await uploadVideo(server.url, server.accessToken, { name: 'video 11' }) | 171 | await uploadVideo(server.url, server.accessToken, { name: 'video 11' }) |
169 | await waitJobs([ server ]) | 172 | await waitJobs([ server ]) |
170 | 173 | ||
171 | const res = await getAuditLogs(server.url, server.accessToken, now1, now2) | 174 | const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 }) |
172 | const logsString = JSON.stringify(res.body) | 175 | const logsString = JSON.stringify(body) |
173 | 176 | ||
174 | expect(logsString.includes('video 9')).to.be.false | 177 | expect(logsString.includes('video 9')).to.be.false |
175 | expect(logsString.includes('video 10')).to.be.true | 178 | expect(logsString.includes('video 10')).to.be.true |