X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Flive%2Flive-permanent.ts;h=4203b1bfcf5b9eeb21fa83cca48a5da9a3abbadb;hb=1c7fbce4fa817cdbb873a2bcb8af379bcba0edc9;hp=f07d4cfecc7936b0df884abf4bd3da323ae45bdf;hpb=4c7e60bc17ee5830399bac4aa273356903421b4c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index f07d4cfec..4203b1bfc 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +import { expect } from 'chai' +import { checkLiveCleanup } from '@server/tests/shared' +import { wait } from '@shared/core-utils' import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' import { cleanupTests, @@ -12,11 +13,8 @@ import { setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, - wait, waitJobs -} from '../../../../shared/extra-utils' - -const expect = chai.expect +} from '@shared/server-commands' describe('Permanent live', function () { let servers: PeerTubeServer[] = [] @@ -99,8 +97,9 @@ describe('Permanent live', function () { }) it('Should stream into this permanent live', async function () { - this.timeout(120000) + this.timeout(240_000) + const beforePublication = new Date() const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) for (const server of servers) { @@ -109,13 +108,18 @@ describe('Permanent live', function () { await checkVideoState(videoUUID, VideoState.PUBLISHED) + for (const server of servers) { + const video = await server.videos.get({ id: videoUUID }) + expect(new Date(video.publishedAt)).greaterThan(beforePublication) + } + await stopFfmpeg(ffmpegCommand) await servers[0].live.waitUntilWaiting({ videoId: videoUUID }) await waitJobs(servers) }) - it('Should not have cleaned up this live', async function () { + it('Should have cleaned up this live', async function () { this.timeout(40000) await wait(5000) @@ -123,8 +127,11 @@ describe('Permanent live', function () { for (const server of servers) { const videoDetails = await server.videos.get({ id: videoUUID }) - expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) + + expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) } + + await checkLiveCleanup({ server: servers[0], permanent: true, videoUUID }) }) it('Should have set this live to waiting for live state', async function () { @@ -134,7 +141,7 @@ describe('Permanent live', function () { }) it('Should be able to stream again in the permanent live', async function () { - this.timeout(20000) + this.timeout(60000) await servers[0].config.updateCustomSubConfig({ newConfig: { @@ -165,6 +172,32 @@ describe('Permanent live', function () { await stopFfmpeg(ffmpegCommand) }) + it('Should have appropriate sessions', async function () { + this.timeout(60000) + + await servers[0].live.waitUntilWaiting({ videoId: videoUUID }) + + const { data, total } = await servers[0].live.listSessions({ videoId: videoUUID }) + expect(total).to.equal(2) + expect(data).to.have.lengthOf(2) + + for (const session of data) { + expect(session.startDate).to.exist + expect(session.endDate).to.exist + + expect(session.error).to.not.exist + } + }) + + it('Should remove the live and have cleaned up the directory', async function () { + this.timeout(60000) + + await servers[0].videos.remove({ id: videoUUID }) + await waitJobs(servers) + + await checkLiveCleanup({ server: servers[0], permanent: true, videoUUID }) + }) + after(async function () { await cleanupTests(servers) })