Fix live tests
This commit is contained in:
parent
8c13fd744f
commit
bbae45c32e
5 changed files with 62 additions and 22 deletions
|
@ -43,12 +43,31 @@ describe('Fast restream in live', function () {
|
||||||
// Streaming session #1
|
// Streaming session #1
|
||||||
let ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
|
let ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
|
||||||
await server.live.waitUntilPublished({ videoId: liveVideoUUID })
|
await server.live.waitUntilPublished({ videoId: liveVideoUUID })
|
||||||
|
|
||||||
|
const video = await server.videos.get({ id: liveVideoUUID })
|
||||||
|
const session1PlaylistId = video.streamingPlaylists[0].id
|
||||||
|
|
||||||
await stopFfmpeg(ffmpegCommand)
|
await stopFfmpeg(ffmpegCommand)
|
||||||
await server.live.waitUntilWaiting({ videoId: liveVideoUUID })
|
await server.live.waitUntilWaiting({ videoId: liveVideoUUID })
|
||||||
|
|
||||||
// Streaming session #2
|
// Streaming session #2
|
||||||
ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
|
ffmpegCommand = await server.live.sendRTMPStreamInVideo(rtmpOptions)
|
||||||
await server.live.waitUntilSegmentGeneration({ videoUUID: liveVideoUUID, segment: 0, playlistNumber: 0, totalSessions: 2 })
|
|
||||||
|
let hasNewPlaylist = false
|
||||||
|
do {
|
||||||
|
const video = await server.videos.get({ id: liveVideoUUID })
|
||||||
|
hasNewPlaylist = video.streamingPlaylists.length === 1 && video.streamingPlaylists[0].id !== session1PlaylistId
|
||||||
|
|
||||||
|
await wait(100)
|
||||||
|
} while (!hasNewPlaylist)
|
||||||
|
|
||||||
|
await server.live.waitUntilSegmentGeneration({
|
||||||
|
server,
|
||||||
|
videoUUID: liveVideoUUID,
|
||||||
|
segment: 1,
|
||||||
|
playlistNumber: 0,
|
||||||
|
objectStorage: false
|
||||||
|
})
|
||||||
|
|
||||||
return { ffmpegCommand, liveVideoUUID }
|
return { ffmpegCommand, liveVideoUUID }
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,9 +695,15 @@ describe('Test live', function () {
|
||||||
commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
commands[0].waitUntilPublished({ videoId: liveVideoReplayId })
|
||||||
])
|
])
|
||||||
|
|
||||||
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoId, playlistNumber: 0, segment: 2 })
|
for (const videoUUID of [ liveVideoId, liveVideoReplayId, permanentLiveVideoReplayId ]) {
|
||||||
await commands[0].waitUntilSegmentGeneration({ videoUUID: liveVideoReplayId, playlistNumber: 0, segment: 2 })
|
await commands[0].waitUntilSegmentGeneration({
|
||||||
await commands[0].waitUntilSegmentGeneration({ videoUUID: permanentLiveVideoReplayId, playlistNumber: 0, segment: 2 })
|
server: servers[0],
|
||||||
|
videoUUID,
|
||||||
|
playlistNumber: 0,
|
||||||
|
segment: 2,
|
||||||
|
objectStorage: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const video = await servers[0].videos.get({ id: permanentLiveVideoReplayId })
|
const video = await servers[0].videos.get({ id: permanentLiveVideoReplayId })
|
||||||
|
|
|
@ -545,7 +545,7 @@ describe('Test moderation notifications', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
|
it('Should send unblacklist but not published/subscription notes after unblacklisted if scheduled update pending', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(120000)
|
||||||
|
|
||||||
const updateAt = new Date(new Date().getTime() + 1000000)
|
const updateAt = new Date(new Date().getTime() + 1000000)
|
||||||
|
|
||||||
|
|
|
@ -56,15 +56,19 @@ async function testVideoResolutions (options: {
|
||||||
for (let i = 0; i < resolutions.length; i++) {
|
for (let i = 0; i < resolutions.length; i++) {
|
||||||
const segmentNum = 3
|
const segmentNum = 3
|
||||||
const segmentName = `${i}-00000${segmentNum}.ts`
|
const segmentName = `${i}-00000${segmentNum}.ts`
|
||||||
await originServer.live.waitUntilSegmentGeneration({ videoUUID: video.uuid, playlistNumber: i, segment: segmentNum })
|
await originServer.live.waitUntilSegmentGeneration({
|
||||||
|
server: originServer,
|
||||||
|
videoUUID: video.uuid,
|
||||||
|
playlistNumber: i,
|
||||||
|
segment: segmentNum,
|
||||||
|
objectStorage
|
||||||
|
})
|
||||||
|
|
||||||
const baseUrl = objectStorage
|
const baseUrl = objectStorage
|
||||||
? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls'
|
? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls'
|
||||||
: originServer.url + '/static/streaming-playlists/hls'
|
: originServer.url + '/static/streaming-playlists/hls'
|
||||||
|
|
||||||
if (objectStorage) {
|
if (objectStorage) {
|
||||||
await originServer.live.waitUntilSegmentUpload({ playlistNumber: i, segment: segmentNum })
|
|
||||||
|
|
||||||
expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl())
|
expect(hlsPlaylist.segmentsSha256Url).to.contain(ObjectStorageCommand.getPlaylistBaseUrl())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
VideoState
|
VideoState
|
||||||
} from '@shared/models'
|
} from '@shared/models'
|
||||||
import { unwrapBody } from '../requests'
|
import { unwrapBody } from '../requests'
|
||||||
import { ObjectStorageCommand } from '../server'
|
import { ObjectStorageCommand, PeerTubeServer } from '../server'
|
||||||
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
import { sendRTMPStream, testFfmpegStreamError } from './live'
|
import { sendRTMPStream, testFfmpegStreamError } from './live'
|
||||||
|
|
||||||
|
@ -160,27 +160,38 @@ export class LiveCommand extends AbstractCommand {
|
||||||
return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED })
|
return this.waitUntilState({ videoId, state: VideoState.LIVE_ENDED })
|
||||||
}
|
}
|
||||||
|
|
||||||
waitUntilSegmentGeneration (options: OverrideCommandOptions & {
|
async waitUntilSegmentGeneration (options: OverrideCommandOptions & {
|
||||||
|
server: PeerTubeServer
|
||||||
videoUUID: string
|
videoUUID: string
|
||||||
playlistNumber: number
|
playlistNumber: number
|
||||||
segment: number
|
segment: number
|
||||||
totalSessions?: number
|
objectStorage: boolean
|
||||||
}) {
|
}) {
|
||||||
const { playlistNumber, segment, videoUUID, totalSessions = 1 } = options
|
const { server, objectStorage, playlistNumber, segment, videoUUID } = options
|
||||||
const segmentName = `${playlistNumber}-00000${segment}.ts`
|
|
||||||
|
|
||||||
return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, totalSessions * 2, false)
|
const segmentName = `${playlistNumber}-00000${segment}.ts`
|
||||||
|
const baseUrl = objectStorage
|
||||||
|
? ObjectStorageCommand.getPlaylistBaseUrl() + 'hls'
|
||||||
|
: server.url + '/static/streaming-playlists/hls'
|
||||||
|
|
||||||
|
let error = true
|
||||||
|
|
||||||
|
while (error) {
|
||||||
|
try {
|
||||||
|
await this.getRawRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
url: `${baseUrl}/${videoUUID}/${segmentName}`,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
|
||||||
|
error = false
|
||||||
|
} catch {
|
||||||
|
error = true
|
||||||
|
await wait(100)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waitUntilSegmentUpload (options: OverrideCommandOptions & {
|
|
||||||
playlistNumber: number
|
|
||||||
segment: number
|
|
||||||
totalSessions?: number
|
|
||||||
}) {
|
|
||||||
const { playlistNumber, segment, totalSessions = 1 } = options
|
|
||||||
const segmentName = `${playlistNumber}-00000${segment}.ts`
|
|
||||||
|
|
||||||
return this.server.servers.waitUntilLog(`${segmentName} in bucket `, totalSessions * 2, false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
|
async waitUntilReplacedByReplay (options: OverrideCommandOptions & {
|
||||||
|
|
Loading…
Reference in a new issue