]>
Commit | Line | Data |
---|---|---|
09cababd C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import * as chai from 'chai' | |
4 | import 'mocha' | |
5 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' | |
6 | import { | |
7 | createUser, | |
8 | doubleFollow, | |
9 | flushAndRunMultipleServers, | |
10 | follow, | |
11 | killallServers, | |
12 | ServerInfo, | |
13 | uploadVideo, | |
14 | viewVideo, | |
15 | wait | |
9639bd17 | 16 | } from '../../../../shared/utils' |
17 | import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' | |
18 | import { getStats } from '../../../../shared/utils/server/stats' | |
19 | import { addVideoCommentThread } from '../../../../shared/utils/videos/video-comments' | |
20 | import { waitJobs } from '../../../../shared/utils/server/jobs' | |
09cababd C |
21 | |
22 | const expect = chai.expect | |
23 | ||
4b5384f6 | 24 | describe('Test stats (excluding redundancy)', function () { |
09cababd C |
25 | let servers: ServerInfo[] = [] |
26 | ||
27 | before(async function () { | |
28 | this.timeout(60000) | |
29 | ||
30 | await flushTests() | |
31 | servers = await flushAndRunMultipleServers(3) | |
32 | await setAccessTokensToServers(servers) | |
33 | ||
34 | await doubleFollow(servers[0], servers[1]) | |
35 | ||
36 | const user = { | |
37 | username: 'user1', | |
38 | password: 'super_password' | |
39 | } | |
40 | await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) | |
41 | ||
44b9c0ba | 42 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' }) |
09cababd C |
43 | const videoUUID = resVideo.body.video.uuid |
44 | ||
45 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, 'comment') | |
46 | ||
47 | await viewVideo(servers[0].url, videoUUID) | |
48 | ||
6b616860 C |
49 | // Wait the video views repeatable job |
50 | await wait(8000) | |
51 | ||
09cababd | 52 | await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) |
3cd0734f | 53 | await waitJobs(servers) |
09cababd C |
54 | }) |
55 | ||
56 | it('Should have the correct stats on instance 1', async function () { | |
57 | const res = await getStats(servers[0].url) | |
58 | const data: ServerStats = res.body | |
59 | ||
60 | expect(data.totalLocalVideoComments).to.equal(1) | |
61 | expect(data.totalLocalVideos).to.equal(1) | |
62 | expect(data.totalLocalVideoViews).to.equal(1) | |
44b9c0ba | 63 | expect(data.totalLocalVideoFilesSize).to.equal(218910) |
09cababd C |
64 | expect(data.totalUsers).to.equal(2) |
65 | expect(data.totalVideoComments).to.equal(1) | |
66 | expect(data.totalVideos).to.equal(1) | |
67 | expect(data.totalInstanceFollowers).to.equal(2) | |
68 | expect(data.totalInstanceFollowing).to.equal(1) | |
69 | }) | |
70 | ||
71 | it('Should have the correct stats on instance 2', async function () { | |
72 | const res = await getStats(servers[1].url) | |
73 | const data: ServerStats = res.body | |
74 | ||
75 | expect(data.totalLocalVideoComments).to.equal(0) | |
76 | expect(data.totalLocalVideos).to.equal(0) | |
77 | expect(data.totalLocalVideoViews).to.equal(0) | |
848f499d | 78 | expect(data.totalLocalVideoFilesSize).to.equal(0) |
09cababd C |
79 | expect(data.totalUsers).to.equal(1) |
80 | expect(data.totalVideoComments).to.equal(1) | |
81 | expect(data.totalVideos).to.equal(1) | |
82 | expect(data.totalInstanceFollowers).to.equal(1) | |
83 | expect(data.totalInstanceFollowing).to.equal(1) | |
84 | }) | |
85 | ||
86 | it('Should have the correct stats on instance 3', async function () { | |
87 | const res = await getStats(servers[2].url) | |
88 | const data: ServerStats = res.body | |
89 | ||
90 | expect(data.totalLocalVideoComments).to.equal(0) | |
91 | expect(data.totalLocalVideos).to.equal(0) | |
92 | expect(data.totalLocalVideoViews).to.equal(0) | |
93 | expect(data.totalUsers).to.equal(1) | |
94 | expect(data.totalVideoComments).to.equal(1) | |
95 | expect(data.totalVideos).to.equal(1) | |
96 | expect(data.totalInstanceFollowing).to.equal(1) | |
97 | expect(data.totalInstanceFollowers).to.equal(0) | |
98 | }) | |
99 | ||
100 | after(async function () { | |
101 | killallServers(servers) | |
09cababd C |
102 | }) |
103 | }) |