/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
import { wait } from '@shared/core-utils'
import { LiveVideoError, VideoPrivacy } from '@shared/models'
import {
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
+ stopFfmpeg,
waitJobs,
+ waitUntilLiveReplacedByReplayOnAllServers,
waitUntilLiveWaitingOnAllServers
} from '@shared/server-commands'
import { checkLiveCleanup } from '../../shared'
-const expect = chai.expect
-
describe('Test live constraints', function () {
let servers: PeerTubeServer[] = []
let userId: number
expect(video.duration).to.be.greaterThan(0)
}
- await checkLiveCleanup(servers[0], videoId, resolutions)
- }
-
- async function waitUntilLivePublishedOnAllServers (videoId: string) {
- for (const server of servers) {
- await server.live.waitUntilPublished({ videoId })
- }
+ await checkLiveCleanup({ server: servers[0], permanent: false, videoUUID: videoId, savedResolutions: resolutions })
}
function updateQuota (options: { total: number, daily: number }) {
const userVideoLiveoId = await createLiveWrapper({ replay: true, permanent: false })
await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
- await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
+ await waitUntilLiveReplacedByReplayOnAllServers(servers, userVideoLiveoId)
await waitJobs(servers)
await checkSaveReplay(userVideoLiveoId)
const userVideoLiveoId = await createLiveWrapper({ replay: true, permanent: false })
await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
- await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
+ await waitUntilLiveReplacedByReplayOnAllServers(servers, userVideoLiveoId)
await waitJobs(servers)
await checkSaveReplay(userVideoLiveoId)
await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
})
+ it('Should have the same quota in admin and as a user', async function () {
+ this.timeout(120000)
+
+ const userVideoLiveoId = await createLiveWrapper({ replay: true, permanent: false })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ token: userAccessToken, videoId: userVideoLiveoId })
+
+ await servers[0].live.waitUntilPublished({ videoId: userVideoLiveoId })
+
+ await wait(3000)
+
+ const quotaUser = await servers[0].users.getMyQuotaUsed({ token: userAccessToken })
+
+ const { data } = await servers[0].users.list()
+ const quotaAdmin = data.find(u => u.username === 'user1')
+
+ expect(quotaUser.videoQuotaUsed).to.equal(quotaAdmin.videoQuotaUsed)
+ expect(quotaUser.videoQuotaUsedDaily).to.equal(quotaAdmin.videoQuotaUsedDaily)
+
+ expect(quotaUser.videoQuotaUsed).to.be.above(10)
+ expect(quotaUser.videoQuotaUsedDaily).to.be.above(10)
+
+ await stopFfmpeg(ffmpegCommand)
+ })
+
it('Should have max duration limit', async function () {
this.timeout(60000)
const userVideoLiveoId = await createLiveWrapper({ replay: true, permanent: false })
await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
- await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
+ await waitUntilLiveReplacedByReplayOnAllServers(servers, userVideoLiveoId)
await waitJobs(servers)
await checkSaveReplay(userVideoLiveoId, [ 720, 480, 360, 240, 144 ])