diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/videos/videos-views-cleaner.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/videos/videos-views-cleaner.ts')
-rw-r--r-- | server/tests/api/videos/videos-views-cleaner.ts | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index b89f33217..82268b1be 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -1,19 +1,14 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | ||
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | closeAllSequelize, | 7 | createMultipleServers, |
8 | countVideoViewsOf, | ||
9 | doubleFollow, | 8 | doubleFollow, |
10 | flushAndRunMultipleServers, | ||
11 | killallServers, | 9 | killallServers, |
12 | reRunServer, | 10 | PeerTubeServer, |
13 | ServerInfo, | ||
14 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
15 | uploadVideoAndGetId, | ||
16 | viewVideo, | ||
17 | wait, | 12 | wait, |
18 | waitJobs | 13 | waitJobs |
19 | } from '../../../../shared/extra-utils' | 14 | } from '../../../../shared/extra-utils' |
@@ -21,7 +16,7 @@ import { | |||
21 | const expect = chai.expect | 16 | const expect = chai.expect |
22 | 17 | ||
23 | describe('Test video views cleaner', function () { | 18 | describe('Test video views cleaner', function () { |
24 | let servers: ServerInfo[] | 19 | let servers: PeerTubeServer[] |
25 | 20 | ||
26 | let videoIdServer1: string | 21 | let videoIdServer1: string |
27 | let videoIdServer2: string | 22 | let videoIdServer2: string |
@@ -29,20 +24,20 @@ describe('Test video views cleaner', function () { | |||
29 | before(async function () { | 24 | before(async function () { |
30 | this.timeout(120000) | 25 | this.timeout(120000) |
31 | 26 | ||
32 | servers = await flushAndRunMultipleServers(2) | 27 | servers = await createMultipleServers(2) |
33 | await setAccessTokensToServers(servers) | 28 | await setAccessTokensToServers(servers) |
34 | 29 | ||
35 | await doubleFollow(servers[0], servers[1]) | 30 | await doubleFollow(servers[0], servers[1]) |
36 | 31 | ||
37 | videoIdServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' })).uuid | 32 | videoIdServer1 = (await servers[0].videos.quickUpload({ name: 'video server 1' })).uuid |
38 | videoIdServer2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' })).uuid | 33 | videoIdServer2 = (await servers[1].videos.quickUpload({ name: 'video server 2' })).uuid |
39 | 34 | ||
40 | await waitJobs(servers) | 35 | await waitJobs(servers) |
41 | 36 | ||
42 | await viewVideo(servers[0].url, videoIdServer1) | 37 | await servers[0].videos.view({ id: videoIdServer1 }) |
43 | await viewVideo(servers[1].url, videoIdServer1) | 38 | await servers[1].videos.view({ id: videoIdServer1 }) |
44 | await viewVideo(servers[0].url, videoIdServer2) | 39 | await servers[0].videos.view({ id: videoIdServer2 }) |
45 | await viewVideo(servers[1].url, videoIdServer2) | 40 | await servers[1].videos.view({ id: videoIdServer2 }) |
46 | 41 | ||
47 | await waitJobs(servers) | 42 | await waitJobs(servers) |
48 | }) | 43 | }) |
@@ -50,9 +45,9 @@ describe('Test video views cleaner', function () { | |||
50 | it('Should not clean old video views', async function () { | 45 | it('Should not clean old video views', async function () { |
51 | this.timeout(50000) | 46 | this.timeout(50000) |
52 | 47 | ||
53 | killallServers([ servers[0] ]) | 48 | await killallServers([ servers[0] ]) |
54 | 49 | ||
55 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '10 days' } } } }) | 50 | await servers[0].run({ views: { videos: { remote: { max_age: '10 days' } } } }) |
56 | 51 | ||
57 | await wait(6000) | 52 | await wait(6000) |
58 | 53 | ||
@@ -60,14 +55,14 @@ describe('Test video views cleaner', function () { | |||
60 | 55 | ||
61 | { | 56 | { |
62 | for (const server of servers) { | 57 | for (const server of servers) { |
63 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) | 58 | const total = await server.sql.countVideoViewsOf(videoIdServer1) |
64 | expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') | 59 | expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') |
65 | } | 60 | } |
66 | } | 61 | } |
67 | 62 | ||
68 | { | 63 | { |
69 | for (const server of servers) { | 64 | for (const server of servers) { |
70 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) | 65 | const total = await server.sql.countVideoViewsOf(videoIdServer2) |
71 | expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') | 66 | expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') |
72 | } | 67 | } |
73 | } | 68 | } |
@@ -76,9 +71,9 @@ describe('Test video views cleaner', function () { | |||
76 | it('Should clean old video views', async function () { | 71 | it('Should clean old video views', async function () { |
77 | this.timeout(50000) | 72 | this.timeout(50000) |
78 | 73 | ||
79 | killallServers([ servers[0] ]) | 74 | await killallServers([ servers[0] ]) |
80 | 75 | ||
81 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) | 76 | await servers[0].run({ views: { videos: { remote: { max_age: '5 seconds' } } } }) |
82 | 77 | ||
83 | await wait(6000) | 78 | await wait(6000) |
84 | 79 | ||
@@ -86,23 +81,21 @@ describe('Test video views cleaner', function () { | |||
86 | 81 | ||
87 | { | 82 | { |
88 | for (const server of servers) { | 83 | for (const server of servers) { |
89 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) | 84 | const total = await server.sql.countVideoViewsOf(videoIdServer1) |
90 | expect(total).to.equal(2) | 85 | expect(total).to.equal(2) |
91 | } | 86 | } |
92 | } | 87 | } |
93 | 88 | ||
94 | { | 89 | { |
95 | const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2) | 90 | const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2) |
96 | expect(totalServer1).to.equal(0) | 91 | expect(totalServer1).to.equal(0) |
97 | 92 | ||
98 | const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2) | 93 | const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2) |
99 | expect(totalServer2).to.equal(2) | 94 | expect(totalServer2).to.equal(2) |
100 | } | 95 | } |
101 | }) | 96 | }) |
102 | 97 | ||
103 | after(async function () { | 98 | after(async function () { |
104 | await closeAllSequelize(servers) | ||
105 | |||
106 | await cleanupTests(servers) | 99 | await cleanupTests(servers) |
107 | }) | 100 | }) |
108 | }) | 101 | }) |