diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-10 15:43:01 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-12-14 09:11:27 +0100 |
commit | e0783718079c1fcb6554ea20e762cfb0592de5b0 (patch) | |
tree | 8a13865dde332bd0e5dbe4fa6c5b1ac395237d32 | |
parent | 0d9c2cc0a2983b678bc839fe95b90cb7781b8149 (diff) | |
download | PeerTube-e0783718079c1fcb6554ea20e762cfb0592de5b0.tar.gz PeerTube-e0783718079c1fcb6554ea20e762cfb0592de5b0.tar.zst PeerTube-e0783718079c1fcb6554ea20e762cfb0592de5b0.zip |
Parse log script can take files as args
-rwxr-xr-x | scripts/parse-log.ts | 40 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 5 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 2 |
3 files changed, 29 insertions, 18 deletions
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 58e052b9f..410da3c61 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts | |||
@@ -12,6 +12,7 @@ import { mtimeSortFilesDesc } from '../shared/core-utils/logs/logs' | |||
12 | 12 | ||
13 | program | 13 | program |
14 | .option('-l, --level [level]', 'Level log (debug/info/warn/error)') | 14 | .option('-l, --level [level]', 'Level log (debug/info/warn/error)') |
15 | .option('-f, --files [file...]', 'Files to parse. If not provided, the script will parse the latest log file from config)') | ||
15 | .parse(process.argv) | 16 | .parse(process.argv) |
16 | 17 | ||
17 | const excludedKeys = { | 18 | const excludedKeys = { |
@@ -62,27 +63,27 @@ run() | |||
62 | 63 | ||
63 | function run () { | 64 | function run () { |
64 | return new Promise(async res => { | 65 | return new Promise(async res => { |
65 | const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR) | 66 | const files = await getFiles() |
66 | const lastLogFile = await getNewestFile(logFiles, CONFIG.STORAGE.LOG_DIR) | ||
67 | 67 | ||
68 | const path = join(CONFIG.STORAGE.LOG_DIR, lastLogFile) | 68 | for (const file of files) { |
69 | console.log('Opening %s.', path) | 69 | console.log('Opening %s.', file) |
70 | 70 | ||
71 | const stream = createReadStream(path) | 71 | const stream = createReadStream(file) |
72 | 72 | ||
73 | const rl = createInterface({ | 73 | const rl = createInterface({ |
74 | input: stream | 74 | input: stream |
75 | }) | 75 | }) |
76 | 76 | ||
77 | rl.on('line', line => { | 77 | rl.on('line', line => { |
78 | const log = JSON.parse(line) | 78 | const log = JSON.parse(line) |
79 | // Don't know why but loggerFormat does not remove splat key | 79 | // Don't know why but loggerFormat does not remove splat key |
80 | Object.assign(log, { splat: undefined }) | 80 | Object.assign(log, { splat: undefined }) |
81 | 81 | ||
82 | logLevels[log.level](log) | 82 | logLevels[log.level](log) |
83 | }) | 83 | }) |
84 | 84 | ||
85 | stream.once('close', () => res()) | 85 | stream.once('close', () => res()) |
86 | } | ||
86 | }) | 87 | }) |
87 | } | 88 | } |
88 | 89 | ||
@@ -93,6 +94,15 @@ async function getNewestFile (files: string[], basePath: string) { | |||
93 | return (sorted.length > 0) ? sorted[0].file : '' | 94 | return (sorted.length > 0) ? sorted[0].file : '' |
94 | } | 95 | } |
95 | 96 | ||
97 | async function getFiles () { | ||
98 | if (program['files']) return program['files'] | ||
99 | |||
100 | const logFiles = await readdir(CONFIG.STORAGE.LOG_DIR) | ||
101 | |||
102 | const filename = await getNewestFile(logFiles, CONFIG.STORAGE.LOG_DIR) | ||
103 | return [ join(CONFIG.STORAGE.LOG_DIR, filename) ] | ||
104 | } | ||
105 | |||
96 | function toTimeFormat (time: string) { | 106 | function toTimeFormat (time: string) { |
97 | const timestamp = Date.parse(time) | 107 | const timestamp = Date.parse(time) |
98 | 108 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 6d504f742..6a1f6e759 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -413,10 +413,10 @@ describe('Test live', function () { | |||
413 | await testVideoResolutions(liveVideoId, resolutions) | 413 | await testVideoResolutions(liveVideoId, resolutions) |
414 | 414 | ||
415 | await stopFfmpeg(command) | 415 | await stopFfmpeg(command) |
416 | await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) | ||
417 | |||
418 | await waitJobs(servers) | 416 | await waitJobs(servers) |
419 | 417 | ||
418 | await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) | ||
419 | |||
420 | const bitrateLimits = { | 420 | const bitrateLimits = { |
421 | 720: 5000 * 1000, // 60FPS | 421 | 720: 5000 * 1000, // 60FPS |
422 | 360: 1100 * 1000, | 422 | 360: 1100 * 1000, |
@@ -427,6 +427,7 @@ describe('Test live', function () { | |||
427 | const resVideo = await getVideo(server.url, liveVideoId) | 427 | const resVideo = await getVideo(server.url, liveVideoId) |
428 | const video: VideoDetails = resVideo.body | 428 | const video: VideoDetails = resVideo.body |
429 | 429 | ||
430 | expect(video.state.id).to.equal(VideoState.PUBLISHED) | ||
430 | expect(video.duration).to.be.greaterThan(1) | 431 | expect(video.duration).to.be.greaterThan(1) |
431 | expect(video.files).to.have.lengthOf(0) | 432 | expect(video.files).to.have.lengthOf(0) |
432 | 433 | ||
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 9233a210b..6467238cd 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -302,7 +302,7 @@ describe('Test follows', function () { | |||
302 | }) | 302 | }) |
303 | 303 | ||
304 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { | 304 | it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { |
305 | this.timeout(35000) | 305 | this.timeout(60000) |
306 | 306 | ||
307 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) | 307 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'server2' }) |
308 | await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' }) | 308 | await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3' }) |