diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-22 15:52:59 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-22 15:52:59 +0200 |
commit | 3f0ceab06e5320f62f593c49daa30d963dbc36f9 (patch) | |
tree | c041455a11c55617251def4b7b35eff8d530a97a /server/tests/api | |
parent | fa3da7a623fdb25be52ebff14e066a99ea9fb0cf (diff) | |
download | PeerTube-3f0ceab06e5320f62f593c49daa30d963dbc36f9.tar.gz PeerTube-3f0ceab06e5320f62f593c49daa30d963dbc36f9.tar.zst PeerTube-3f0ceab06e5320f62f593c49daa30d963dbc36f9.zip |
More robust quota check
Avoid concurrency issues with permanent lives
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/live/live-constraints.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 168241b79..7af6af193 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { wait } from '@shared/core-utils' | 4 | import { wait } from '@shared/core-utils' |
5 | import { LiveVideoError, VideoPrivacy } from '@shared/models' | 5 | import { LiveVideoError, UserVideoQuota, VideoPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | ConfigCommand, | 8 | ConfigCommand, |
@@ -172,12 +172,18 @@ describe('Test live constraints', function () { | |||
172 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ token: userAccessToken, videoId: userVideoLiveoId }) | 172 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ token: userAccessToken, videoId: userVideoLiveoId }) |
173 | 173 | ||
174 | await servers[0].live.waitUntilPublished({ videoId: userVideoLiveoId }) | 174 | await servers[0].live.waitUntilPublished({ videoId: userVideoLiveoId }) |
175 | // Wait previous live cleanups | ||
176 | await wait(3000) | ||
175 | 177 | ||
176 | const baseQuota = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) | 178 | const baseQuota = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) |
177 | 179 | ||
178 | await wait(3000) | 180 | let quotaUser: UserVideoQuota |
181 | |||
182 | do { | ||
183 | await wait(500) | ||
179 | 184 | ||
180 | const quotaUser = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) | 185 | quotaUser = await servers[0].users.getMyQuotaUsed({ token: userAccessToken }) |
186 | } while (quotaUser.videoQuotaUsed < baseQuota.videoQuotaUsed) | ||
181 | 187 | ||
182 | const { data } = await servers[0].users.list() | 188 | const { data } = await servers[0].users.list() |
183 | const quotaAdmin = data.find(u => u.username === 'user1') | 189 | const quotaAdmin = data.find(u => u.username === 'user1') |