2019-04-10 15:26:33 +02:00
|
|
|
/* tslint:disable:no-unused-expression */
|
|
|
|
|
|
|
|
import * as chai from 'chai'
|
|
|
|
import 'mocha'
|
2019-04-24 15:10:37 +02:00
|
|
|
import {
|
|
|
|
flushTests,
|
|
|
|
killallServers,
|
|
|
|
flushAndRunServer,
|
|
|
|
ServerInfo,
|
|
|
|
setAccessTokensToServers,
|
|
|
|
cleanupTests
|
|
|
|
} from '../../../../shared/extra-utils/index'
|
2019-04-15 15:26:15 +02:00
|
|
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
|
|
import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'
|
|
|
|
import { getLogs } from '../../../../shared/extra-utils/logs/logs'
|
2019-04-10 15:26:33 +02:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('Test logs', function () {
|
|
|
|
let server: ServerInfo
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
this.timeout(30000)
|
|
|
|
|
2019-04-24 10:53:40 +02:00
|
|
|
server = await flushAndRunServer(1)
|
2019-04-10 15:26:33 +02:00
|
|
|
await setAccessTokensToServers([ server ])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should get logs with a start date', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 1' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 2' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
const res = await getLogs(server.url, server.accessToken, now)
|
|
|
|
const logsString = JSON.stringify(res.body)
|
|
|
|
|
|
|
|
expect(logsString.includes('video 1')).to.be.false
|
|
|
|
expect(logsString.includes('video 2')).to.be.true
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should get logs with an end date', async function () {
|
2019-04-26 08:50:52 +02:00
|
|
|
this.timeout(20000)
|
2019-04-10 15:26:33 +02:00
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 3' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
const now1 = new Date()
|
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 4' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
const now2 = new Date()
|
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 5' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
const res = await getLogs(server.url, server.accessToken, now1, now2)
|
|
|
|
const logsString = JSON.stringify(res.body)
|
|
|
|
|
|
|
|
expect(logsString.includes('video 3')).to.be.false
|
|
|
|
expect(logsString.includes('video 4')).to.be.true
|
|
|
|
expect(logsString.includes('video 5')).to.be.false
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Should get filter by level', async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
|
|
await uploadVideo(server.url, server.accessToken, { name: 'video 6' })
|
|
|
|
await waitJobs([ server ])
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getLogs(server.url, server.accessToken, now, undefined, 'info')
|
|
|
|
const logsString = JSON.stringify(res.body)
|
|
|
|
|
|
|
|
expect(logsString.includes('video 6')).to.be.true
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const res = await getLogs(server.url, server.accessToken, now, undefined, 'warn')
|
|
|
|
const logsString = JSON.stringify(res.body)
|
|
|
|
|
|
|
|
expect(logsString.includes('video 6')).to.be.false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2019-04-24 15:10:37 +02:00
|
|
|
after(async function () {
|
|
|
|
await cleanupTests([ server ])
|
2019-04-10 15:26:33 +02:00
|
|
|
})
|
|
|
|
})
|