diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 11:35:10 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | afffe98839db7ccbfa9fb8b7d1413b97900fdc73 (patch) | |
tree | f0b3cbe58f73e81a5ba4bb31dabd9691994cf2ca /server/tests/api/request-schedulers.ts | |
parent | 1b3989b0961d22a5a45ad16239e3c3f58f66180c (diff) | |
download | PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.gz PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.zst PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.zip |
Speed up activity pub http requests
Diffstat (limited to 'server/tests/api/request-schedulers.ts')
-rw-r--r-- | server/tests/api/request-schedulers.ts | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/server/tests/api/request-schedulers.ts b/server/tests/api/request-schedulers.ts deleted file mode 100644 index c136d1cea..000000000 --- a/server/tests/api/request-schedulers.ts +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | const expect = chai.expect | ||
6 | |||
7 | import { | ||
8 | ServerInfo, | ||
9 | flushTests, | ||
10 | uploadVideo, | ||
11 | makeFriends, | ||
12 | wait, | ||
13 | setAccessTokensToServers, | ||
14 | flushAndRunMultipleServers, | ||
15 | getRequestsStats, | ||
16 | killallServers | ||
17 | } from '../utils' | ||
18 | |||
19 | describe('Test requests schedulers stats', function () { | ||
20 | const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ] | ||
21 | let servers: ServerInfo[] = [] | ||
22 | |||
23 | function uploadVideoWrapper (server: ServerInfo) { | ||
24 | const videoAttributes = { | ||
25 | tags: [ 'tag1', 'tag2' ] | ||
26 | } | ||
27 | |||
28 | return uploadVideo(server.url, server.accessToken, videoAttributes) | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------- | ||
32 | |||
33 | before(async function () { | ||
34 | this.timeout(120000) | ||
35 | |||
36 | servers = await flushAndRunMultipleServers(2) | ||
37 | |||
38 | await setAccessTokensToServers(servers) | ||
39 | |||
40 | await makeFriends(servers[0].url, servers[0].accessToken) | ||
41 | }) | ||
42 | |||
43 | it('Should have a correct timer', async function () { | ||
44 | const server = servers[0] | ||
45 | |||
46 | const res = await getRequestsStats(server) | ||
47 | |||
48 | const requestSchedulers = res.body | ||
49 | for (const requestSchedulerName of requestSchedulerNames) { | ||
50 | const requestScheduler = requestSchedulers[requestSchedulerName] | ||
51 | |||
52 | expect(requestScheduler.remainingMilliSeconds).to.be.at.least(0) | ||
53 | expect(requestScheduler.remainingMilliSeconds).to.be.at.most(10000) | ||
54 | } | ||
55 | }) | ||
56 | |||
57 | it('Should have the correct total request', async function () { | ||
58 | this.timeout(15000) | ||
59 | |||
60 | const server = servers[0] | ||
61 | // Ensure the requests of pod 1 won't be made | ||
62 | servers[1].app.kill() | ||
63 | |||
64 | await uploadVideoWrapper(server) | ||
65 | |||
66 | await wait(1000) | ||
67 | |||
68 | const res = await getRequestsStats(server) | ||
69 | const requestSchedulers = res.body | ||
70 | const requestScheduler = requestSchedulers.requestScheduler | ||
71 | expect(requestScheduler.totalRequests).to.equal(3) | ||
72 | }) | ||
73 | |||
74 | after(async function () { | ||
75 | // Server 1 has already been killed | ||
76 | killallServers([ servers[0] ]) | ||
77 | |||
78 | if (this['ok']) { | ||
79 | await flushTests() | ||
80 | } | ||
81 | }) | ||
82 | }) | ||