diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-07 11:53:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-07 11:53:46 +0200 |
commit | a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c (patch) | |
tree | 0386b60da767075a890d45d947a6805ca32fd742 /server/tests/api/live/live-constraints.ts | |
parent | bc4c9cc1d75d591c217d61ab22a107b7f1044c76 (diff) | |
download | PeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.tar.gz PeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.tar.zst PeerTube-a1bb73f9b591686b2ddfeb3291f305dae9f7fc6c.zip |
Refactor a little bit live tests
Diffstat (limited to 'server/tests/api/live/live-constraints.ts')
-rw-r--r-- | server/tests/api/live/live-constraints.ts | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 5569e6066..cc635de33 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -2,15 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { User, VideoDetails, VideoPrivacy } from '@shared/models' | 5 | import { VideoDetails, VideoPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkLiveCleanup, | 7 | checkLiveCleanup, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createLive, | 9 | createLive, |
10 | createUser, | ||
11 | doubleFollow, | 10 | doubleFollow, |
12 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
13 | getMyUserInformation, | 12 | generateUser, |
13 | getCustomConfigResolutions, | ||
14 | getVideo, | 14 | getVideo, |
15 | runAndTestFfmpegStreamError, | 15 | runAndTestFfmpegStreamError, |
16 | ServerInfo, | 16 | ServerInfo, |
@@ -18,7 +18,6 @@ import { | |||
18 | setDefaultVideoChannel, | 18 | setDefaultVideoChannel, |
19 | updateCustomSubConfig, | 19 | updateCustomSubConfig, |
20 | updateUser, | 20 | updateUser, |
21 | userLogin, | ||
22 | wait, | 21 | wait, |
23 | waitJobs, | 22 | waitJobs, |
24 | waitUntilLivePublished | 23 | waitUntilLivePublished |
@@ -62,6 +61,16 @@ describe('Test live constraints', function () { | |||
62 | } | 61 | } |
63 | } | 62 | } |
64 | 63 | ||
64 | function updateQuota (options: { total: number, daily: number }) { | ||
65 | return updateUser({ | ||
66 | url: servers[0].url, | ||
67 | accessToken: servers[0].accessToken, | ||
68 | userId, | ||
69 | videoQuota: options.total, | ||
70 | videoQuotaDaily: options.daily | ||
71 | }) | ||
72 | } | ||
73 | |||
65 | before(async function () { | 74 | before(async function () { |
66 | this.timeout(120000) | 75 | this.timeout(120000) |
67 | 76 | ||
@@ -82,27 +91,12 @@ describe('Test live constraints', function () { | |||
82 | }) | 91 | }) |
83 | 92 | ||
84 | { | 93 | { |
85 | const user = { username: 'user1', password: 'superpassword' } | 94 | const res = await generateUser(servers[0], 'user1') |
86 | const res = await createUser({ | 95 | userId = res.userId |
87 | url: servers[0].url, | 96 | userChannelId = res.userChannelId |
88 | accessToken: servers[0].accessToken, | 97 | userAccessToken = res.token |
89 | username: user.username, | 98 | |
90 | password: user.password | 99 | await updateQuota({ total: 1, daily: -1 }) |
91 | }) | ||
92 | userId = res.body.user.id | ||
93 | |||
94 | userAccessToken = await userLogin(servers[0], user) | ||
95 | |||
96 | const resMe = await getMyUserInformation(servers[0].url, userAccessToken) | ||
97 | userChannelId = (resMe.body as User).videoChannels[0].id | ||
98 | |||
99 | await updateUser({ | ||
100 | url: servers[0].url, | ||
101 | userId, | ||
102 | accessToken: servers[0].accessToken, | ||
103 | videoQuota: 1, | ||
104 | videoQuotaDaily: -1 | ||
105 | }) | ||
106 | } | 100 | } |
107 | 101 | ||
108 | // Server 1 and server 2 follow each other | 102 | // Server 1 and server 2 follow each other |
@@ -137,13 +131,7 @@ describe('Test live constraints', function () { | |||
137 | // Wait for user quota memoize cache invalidation | 131 | // Wait for user quota memoize cache invalidation |
138 | await wait(5000) | 132 | await wait(5000) |
139 | 133 | ||
140 | await updateUser({ | 134 | await updateQuota({ total: -1, daily: 1 }) |
141 | url: servers[0].url, | ||
142 | userId, | ||
143 | accessToken: servers[0].accessToken, | ||
144 | videoQuota: -1, | ||
145 | videoQuotaDaily: 1 | ||
146 | }) | ||
147 | 135 | ||
148 | const userVideoLiveoId = await createLiveWrapper(true) | 136 | const userVideoLiveoId = await createLiveWrapper(true) |
149 | await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true) | 137 | await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, true) |
@@ -160,13 +148,7 @@ describe('Test live constraints', function () { | |||
160 | // Wait for user quota memoize cache invalidation | 148 | // Wait for user quota memoize cache invalidation |
161 | await wait(5000) | 149 | await wait(5000) |
162 | 150 | ||
163 | await updateUser({ | 151 | await updateQuota({ total: 10 * 1000 * 1000, daily: -1 }) |
164 | url: servers[0].url, | ||
165 | userId, | ||
166 | accessToken: servers[0].accessToken, | ||
167 | videoQuota: 10 * 1000 * 1000, | ||
168 | videoQuotaDaily: -1 | ||
169 | }) | ||
170 | 152 | ||
171 | const userVideoLiveoId = await createLiveWrapper(true) | 153 | const userVideoLiveoId = await createLiveWrapper(true) |
172 | await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false) | 154 | await runAndTestFfmpegStreamError(servers[0].url, userAccessToken, userVideoLiveoId, false) |
@@ -182,15 +164,7 @@ describe('Test live constraints', function () { | |||
182 | maxDuration: 1, | 164 | maxDuration: 1, |
183 | transcoding: { | 165 | transcoding: { |
184 | enabled: true, | 166 | enabled: true, |
185 | resolutions: { | 167 | resolutions: getCustomConfigResolutions(true) |
186 | '240p': true, | ||
187 | '360p': true, | ||
188 | '480p': true, | ||
189 | '720p': true, | ||
190 | '1080p': true, | ||
191 | '1440p': true, | ||
192 | '2160p': true | ||
193 | } | ||
194 | } | 168 | } |
195 | } | 169 | } |
196 | }) | 170 | }) |