Fix getting live by anonymous user
This commit is contained in:
parent
c74cd9feab
commit
98ebfa3950
|
@ -50,6 +50,50 @@ describe('Save replay setting', function () {
|
||||||
return uuid
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function publishLive (options: { permanent: boolean, replay: boolean }) {
|
||||||
|
liveVideoUUID = await createLiveWrapper(options)
|
||||||
|
|
||||||
|
const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
||||||
|
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
||||||
|
|
||||||
|
const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
||||||
|
|
||||||
|
return { ffmpegCommand, liveDetails }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publishLiveAndDelete (options: { permanent: boolean, replay: boolean }) {
|
||||||
|
const { ffmpegCommand, liveDetails } = await publishLive(options)
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
servers[0].videos.remove({ id: liveVideoUUID }),
|
||||||
|
testFfmpegStreamError(ffmpegCommand, true)
|
||||||
|
])
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
await wait(5000)
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
return { liveDetails }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publishLiveAndBlacklist (options: { permanent: boolean, replay: boolean }) {
|
||||||
|
const { ffmpegCommand, liveDetails } = await publishLive(options)
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
|
||||||
|
testFfmpegStreamError(ffmpegCommand, true)
|
||||||
|
])
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
await wait(5000)
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
return { liveDetails }
|
||||||
|
}
|
||||||
|
|
||||||
async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) {
|
async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const length = existsInList ? 1 : 0
|
const length = existsInList ? 1 : 0
|
||||||
|
@ -100,10 +144,6 @@ describe('Save replay setting', function () {
|
||||||
|
|
||||||
describe('With save replay disabled', function () {
|
describe('With save replay disabled', function () {
|
||||||
|
|
||||||
before(async function () {
|
|
||||||
this.timeout(10000)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('Should correctly create and federate the "waiting for stream" live', async function () {
|
it('Should correctly create and federate the "waiting for stream" live', async function () {
|
||||||
this.timeout(20000)
|
this.timeout(20000)
|
||||||
|
|
||||||
|
@ -149,21 +189,7 @@ describe('Save replay setting', function () {
|
||||||
it('Should correctly terminate the stream on blacklist and delete the live', async function () {
|
it('Should correctly terminate the stream on blacklist and delete the live', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false })
|
await publishLiveAndBlacklist({ permanent: false, replay: false })
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true)
|
|
||||||
])
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
await checkVideosExist(liveVideoUUID, false)
|
await checkVideosExist(liveVideoUUID, false)
|
||||||
|
|
||||||
|
@ -178,22 +204,7 @@ describe('Save replay setting', function () {
|
||||||
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: false, replay: false })
|
await publishLiveAndDelete({ permanent: false, replay: false })
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true),
|
|
||||||
servers[0].videos.remove({ id: liveVideoUUID })
|
|
||||||
])
|
|
||||||
|
|
||||||
await wait(5000)
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
||||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||||
|
@ -258,20 +269,7 @@ describe('Save replay setting', function () {
|
||||||
it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
|
it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true })
|
await publishLiveAndBlacklist({ permanent: false, replay: true })
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true)
|
|
||||||
])
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
await checkVideosExist(liveVideoUUID, false)
|
await checkVideosExist(liveVideoUUID, false)
|
||||||
|
|
||||||
|
@ -286,21 +284,7 @@ describe('Save replay setting', function () {
|
||||||
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
it('Should correctly terminate the stream on delete and delete the video', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: false, replay: true })
|
await publishLiveAndDelete({ permanent: false, replay: true })
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
servers[0].videos.remove({ id: liveVideoUUID }),
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true)
|
|
||||||
])
|
|
||||||
|
|
||||||
await wait(5000)
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
|
||||||
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
await checkLiveCleanup(servers[0], liveVideoUUID, [])
|
||||||
|
@ -361,25 +345,7 @@ describe('Save replay setting', function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
await servers[0].videos.remove({ id: lastReplayUUID })
|
await servers[0].videos.remove({ id: lastReplayUUID })
|
||||||
|
const { liveDetails } = await publishLiveAndBlacklist({ permanent: true, replay: true })
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true })
|
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true)
|
|
||||||
])
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await wait(5000)
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
const replay = await findExternalSavedVideo(servers[0], liveDetails)
|
const replay = await findExternalSavedVideo(servers[0], liveDetails)
|
||||||
expect(replay).to.exist
|
expect(replay).to.exist
|
||||||
|
@ -397,23 +363,7 @@ describe('Save replay setting', function () {
|
||||||
it('Should correctly terminate the stream on delete and not save the video', async function () {
|
it('Should correctly terminate the stream on delete and not save the video', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true })
|
const { liveDetails } = await publishLiveAndDelete({ permanent: true, replay: true })
|
||||||
|
|
||||||
ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
|
|
||||||
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
|
|
||||||
|
|
||||||
const liveDetails = await servers[0].videos.get({ id: liveVideoUUID })
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
|
||||||
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
servers[0].videos.remove({ id: liveVideoUUID }),
|
|
||||||
testFfmpegStreamError(ffmpegCommand, true)
|
|
||||||
])
|
|
||||||
|
|
||||||
await wait(5000)
|
|
||||||
await waitJobs(servers)
|
|
||||||
|
|
||||||
const replay = await findExternalSavedVideo(servers[0], liveDetails)
|
const replay = await findExternalSavedVideo(servers[0], liveDetails)
|
||||||
expect(replay).to.not.exist
|
expect(replay).to.not.exist
|
||||||
|
|
|
@ -590,13 +590,17 @@ describe('Test live', function () {
|
||||||
describe('After a server restart', function () {
|
describe('After a server restart', function () {
|
||||||
let liveVideoId: string
|
let liveVideoId: string
|
||||||
let liveVideoReplayId: string
|
let liveVideoReplayId: string
|
||||||
|
let permanentLiveVideoReplayId: string
|
||||||
|
|
||||||
async function createLiveWrapper (saveReplay: boolean) {
|
let permanentLiveReplayName: string
|
||||||
const liveAttributes = {
|
|
||||||
|
async function createLiveWrapper (options: { saveReplay: boolean, permanent: boolean }) {
|
||||||
|
const liveAttributes: LiveVideoCreate = {
|
||||||
name: 'live video',
|
name: 'live video',
|
||||||
channelId: servers[0].store.channel.id,
|
channelId: servers[0].store.channel.id,
|
||||||
privacy: VideoPrivacy.PUBLIC,
|
privacy: VideoPrivacy.PUBLIC,
|
||||||
saveReplay
|
saveReplay: options.saveReplay,
|
||||||
|
permanentLive: options.permanent
|
||||||
}
|
}
|
||||||
|
|
||||||
const { uuid } = await commands[0].create({ fields: liveAttributes })
|
const { uuid } = await commands[0].create({ fields: liveAttributes })
|
||||||
|
@ -604,41 +608,59 @@ describe('Test live', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(120000)
|
this.timeout(160000)
|
||||||
|
|
||||||
liveVideoId = await createLiveWrapper(false)
|
liveVideoId = await createLiveWrapper({ saveReplay: false, permanent: false })
|
||||||
liveVideoReplayId = await createLiveWrapper(true)
|
liveVideoReplayId = await createLiveWrapper({ saveReplay: true, permanent: false })
|
||||||
|
permanentLiveVideoReplayId = await createLiveWrapper({ saveReplay: true, permanent: true })
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId }),
|
commands[0].sendRTMPStreamInVideo({ videoId: liveVideoId }),
|
||||||
|
commands[0].sendRTMPStreamInVideo({ videoId: permanentLiveVideoReplayId }),
|
||||||
commands[0].sendRTMPStreamInVideo({ videoId: liveVideoReplayId })
|
commands[0].sendRTMPStreamInVideo({ videoId: liveVideoReplayId })
|
||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
commands[0].waitUntilPublished({ videoId: liveVideoId }),
|
commands[0].waitUntilPublished({ videoId: liveVideoId }),
|
||||||
|
commands[0].waitUntilPublished({ videoId: permanentLiveVideoReplayId }),
|
||||||
commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
||||||
])
|
])
|
||||||
|
|
||||||
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoId, resolution: 0, segment: 2 })
|
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoId, resolution: 0, segment: 2 })
|
||||||
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, resolution: 0, segment: 2 })
|
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, resolution: 0, segment: 2 })
|
||||||
|
await commands[0].waitUntilSegmentGeneration({ videoUUID: permanentLiveVideoReplayId, resolution: 0, segment: 2 })
|
||||||
|
|
||||||
|
{
|
||||||
|
const video = await servers[0].videos.get({ id: permanentLiveVideoReplayId })
|
||||||
|
permanentLiveReplayName = video.name + ' - ' + new Date(video.publishedAt).toLocaleString()
|
||||||
|
}
|
||||||
|
|
||||||
await killallServers([ servers[0] ])
|
await killallServers([ servers[0] ])
|
||||||
await servers[0].run()
|
await servers[0].run()
|
||||||
|
|
||||||
await wait(5000)
|
await wait(5000)
|
||||||
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should cleanup lives', async function () {
|
it('Should cleanup lives', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
await commands[0].waitUntilEnded({ videoId: liveVideoId })
|
await commands[0].waitUntilEnded({ videoId: liveVideoId })
|
||||||
|
await commands[0].waitUntilWaiting({ videoId: permanentLiveVideoReplayId })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should save a live replay', async function () {
|
it('Should save a non permanent live replay', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
await commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
await commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should have saved a permanent live replay', async function () {
|
||||||
|
this.timeout(120000)
|
||||||
|
|
||||||
|
const { data } = await servers[0].videos.listMyVideos({ sort: '-publishedAt' })
|
||||||
|
expect(data.find(v => v.name === permanentLiveReplayName)).to.exist
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
|
|
Loading…
Reference in New Issue