import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
-import { HttpStatusCode } from '@shared/core-utils'
+import { checkLiveCleanupAfterSave } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
import {
- checkLiveCleanup,
cleanupTests,
ConfigCommand,
+ createMultipleServers,
doubleFollow,
- flushAndRunMultipleServers,
- ServerInfo,
+ PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
- wait,
- waitJobs
-} from '@shared/extra-utils'
-import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
+ waitJobs,
+ waitUntilLivePublishedOnAllServers,
+ waitUntilLiveSavedOnAllServers
+} from '@shared/server-commands'
const expect = chai.expect
describe('Save replay setting', function () {
- let servers: ServerInfo[] = []
+ let servers: PeerTubeServer[] = []
let liveVideoUUID: string
let ffmpegCommand: FfmpegCommand
}
}
- async function waitUntilLivePublishedOnAllServers (videoId: string) {
- for (const server of servers) {
- await server.live.waitUntilPublished({ videoId })
- }
- }
-
- async function waitUntilLiveSavedOnAllServers (videoId: string) {
- for (const server of servers) {
- await server.live.waitUntilSaved({ videoId })
- }
- }
-
before(async function () {
this.timeout(120000)
- servers = await flushAndRunMultipleServers(2)
+ servers = await createMultipleServers(2)
// Get the access tokens
await setAccessTokensToServers(servers)
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
// No resolutions saved since we did not save replay
- await checkLiveCleanup(servers[0], liveVideoUUID, [])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
})
it('Should correctly terminate the stream on blacklist and delete the live', async function () {
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await wait(5000)
await waitJobs(servers)
- await checkLiveCleanup(servers[0], liveVideoUUID, [])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
})
it('Should correctly terminate the stream on delete and delete the video', async function () {
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
- await checkLiveCleanup(servers[0], liveVideoUUID, [])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
})
})
this.timeout(20000)
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await stopFfmpeg(ffmpegCommand)
- await waitUntilLiveSavedOnAllServers(liveVideoUUID)
+ await waitUntilLiveSavedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
// Live has been transcoded
})
it('Should have cleaned up the live files', async function () {
- await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ])
})
it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await wait(5000)
await waitJobs(servers)
- await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ])
})
it('Should correctly terminate the stream on delete and delete the video', async function () {
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
- await waitUntilLivePublishedOnAllServers(liveVideoUUID)
+ await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
- await checkLiveCleanup(servers[0], liveVideoUUID, [])
+ await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [])
})
})