X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Flogs.ts;h=697f10337980a27822c0df4eb1fd0b4e841b5e24;hb=db1ccd05d349c400c658dec68d11c8b01c9ccd01;hp=ab83a329f4966132f1d34ca221bc51137eac564c;hpb=a92ddacb38a4a17e117ca9ed41680a03580fb81d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts index ab83a329f..697f10337 100644 --- a/server/tests/api/server/logs.ts +++ b/server/tests/api/server/logs.ts @@ -4,30 +4,27 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, LogsCommand, - makePingRequest, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, - uploadVideo, waitJobs -} from '@shared/extra-utils' +} from '@shared/server-commands' const expect = chai.expect describe('Test logs', function () { - let server: ServerInfo + let server: PeerTubeServer let logsCommand: LogsCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) - logsCommand = server.logsCommand + logsCommand = server.logs }) describe('With the standard log file', function () { @@ -35,12 +32,12 @@ describe('Test logs', function () { it('Should get logs with a start date', async function () { this.timeout(20000) - await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) + await server.videos.upload({ attributes: { name: 'video 1' } }) await waitJobs([ server ]) const now = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) + await server.videos.upload({ attributes: { name: 'video 2' } }) await waitJobs([ server ]) const body = await logsCommand.getLogs({ startDate: now }) @@ -53,17 +50,17 @@ describe('Test logs', function () { it('Should get logs with an end date', async function () { this.timeout(30000) - await uploadVideo(server.url, server.accessToken, { name: 'video 3' }) + await server.videos.upload({ attributes: { name: 'video 3' } }) await waitJobs([ server ]) const now1 = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 4' }) + await server.videos.upload({ attributes: { name: 'video 4' } }) await waitJobs([ server ]) const now2 = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 5' }) + await server.videos.upload({ attributes: { name: 'video 5' } }) await waitJobs([ server ]) const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 }) @@ -74,12 +71,12 @@ describe('Test logs', function () { expect(logsString.includes('video 5')).to.be.false }) - it('Should get filter by level', async function () { + it('Should filter by level', async function () { this.timeout(20000) const now = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 6' }) + await server.videos.upload({ attributes: { name: 'video 6' } }) await waitJobs([ server ]) { @@ -97,12 +94,33 @@ describe('Test logs', function () { } }) + it('Should filter by tag', async function () { + const now = new Date() + + const { uuid } = await server.videos.upload({ attributes: { name: 'video 6' } }) + await waitJobs([ server ]) + + { + const body = await logsCommand.getLogs({ startDate: now, level: 'debug', tagsOneOf: [ 'toto' ] }) + expect(body).to.have.lengthOf(0) + } + + { + const body = await logsCommand.getLogs({ startDate: now, level: 'debug', tagsOneOf: [ uuid ] }) + expect(body).to.not.have.lengthOf(0) + + for (const line of body) { + expect(line.tags).to.contain(uuid) + } + } + }) + it('Should log ping requests', async function () { this.timeout(10000) const now = new Date() - await makePingRequest(server) + await server.servers.ping() const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) const logsString = JSON.stringify(body) @@ -113,13 +131,13 @@ describe('Test logs', function () { it('Should not log ping requests', async function () { this.timeout(30000) - killallServers([ server ]) + await killallServers([ server ]) - await reRunServer(server, { log: { log_ping_requests: false } }) + await server.run({ log: { log_ping_requests: false } }) const now = new Date() - await makePingRequest(server) + await server.servers.ping() const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) const logsString = JSON.stringify(body) @@ -132,12 +150,12 @@ describe('Test logs', function () { it('Should get logs with a start date', async function () { this.timeout(20000) - await uploadVideo(server.url, server.accessToken, { name: 'video 7' }) + await server.videos.upload({ attributes: { name: 'video 7' } }) await waitJobs([ server ]) const now = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 8' }) + await server.videos.upload({ attributes: { name: 'video 8' } }) await waitJobs([ server ]) const body = await logsCommand.getAuditLogs({ startDate: now }) @@ -158,17 +176,17 @@ describe('Test logs', function () { it('Should get logs with an end date', async function () { this.timeout(30000) - await uploadVideo(server.url, server.accessToken, { name: 'video 9' }) + await server.videos.upload({ attributes: { name: 'video 9' } }) await waitJobs([ server ]) const now1 = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 10' }) + await server.videos.upload({ attributes: { name: 'video 10' } }) await waitJobs([ server ]) const now2 = new Date() - await uploadVideo(server.url, server.accessToken, { name: 'video 11' }) + await server.videos.upload({ attributes: { name: 'video 11' } }) await waitJobs([ server ]) const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 })