Try to speed up server tests

This commit is contained in:
Chocobozzz
2021-02-18 14:44:12 +01:00
committed by Chocobozzz
parent 3f8ae0e4e4
commit fae6e4da8f
11 changed files with 121 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
addVideoToBlacklist,
checkLiveCleanup,
@@ -23,9 +24,9 @@ import {
updateCustomSubConfig,
updateVideo,
waitJobs,
waitUntilLiveEnded,
waitUntilLivePublished
} from '../../../../shared/extra-utils'
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const expect = chai.expect
@@ -74,6 +75,12 @@ describe('Save replay setting', function () {
}
}
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
await waitUntilLivePublished(server.url, server.accessToken, videoId)
}
}
before(async function () {
this.timeout(120000)
@@ -125,10 +132,11 @@ describe('Save replay setting', function () {
})
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
this.timeout(20000)
this.timeout(30000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
@@ -141,6 +149,9 @@ describe('Save replay setting', function () {
await stopFfmpeg(ffmpegCommand)
for (const server of servers) {
await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID)
}
await waitJobs(servers)
// Live still exist, but cannot be played anymore
@@ -159,7 +170,8 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -185,7 +197,8 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(false)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -219,7 +232,7 @@ describe('Save replay setting', function () {
this.timeout(20000)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
@@ -262,7 +275,7 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -288,7 +301,7 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(true)
ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)

View File

@@ -50,6 +50,12 @@ const expect = chai.expect
describe('Test live', function () {
let servers: ServerInfo[] = []
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
await waitUntilLivePublished(server.url, server.accessToken, videoId)
}
}
before(async function () {
this.timeout(120000)
@@ -390,7 +396,7 @@ describe('Test live', function () {
liveVideoId = await createLiveWrapper(false)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublishedOnAllServers(liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, [ 720 ])
@@ -406,7 +412,7 @@ describe('Test live', function () {
liveVideoId = await createLiveWrapper(false)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublishedOnAllServers(liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, resolutions)
@@ -423,7 +429,7 @@ describe('Test live', function () {
liveVideoId = await createLiveWrapper(true)
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublishedOnAllServers(liveVideoId)
await waitJobs(servers)
await testVideoResolutions(liveVideoId, resolutions)
@@ -433,7 +439,7 @@ describe('Test live', function () {
await waitJobs(servers)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublishedOnAllServers(liveVideoId)
const bitrateLimits = {
720: 5000 * 1000, // 60FPS
@@ -514,7 +520,7 @@ describe('Test live', function () {
liveVideoId = res.body.video.uuid
command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId)
await waitUntilLivePublishedOnAllServers(liveVideoId)
await waitJobs(servers)
})
@@ -602,10 +608,7 @@ describe('Test live', function () {
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
for (const server of servers) {
await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
}
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
for (const stateChanges of [ localStateChanges, remoteStateChanges ]) {
@@ -618,7 +621,6 @@ describe('Test live', function () {
for (const server of servers) {
await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID)
}
await waitJobs(servers)
for (const stateChanges of [ localStateChanges, remoteStateChanges ]) {
@@ -654,10 +656,7 @@ describe('Test live', function () {
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
for (const server of servers) {
await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
}
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
expect(localLastVideoViews).to.equal(0)
@@ -691,7 +690,8 @@ describe('Test live', function () {
socket.emit('subscribe', { videoId })
const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID)
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
expect(stateChanges).to.have.lengthOf(1)