aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-views-cleaner.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/videos-views-cleaner.ts')
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts101
1 files changed, 0 insertions, 101 deletions
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
deleted file mode 100644
index e6815a4a8..000000000
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ /dev/null
@@ -1,101 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import * as chai from 'chai'
5import { wait } from '@shared/core-utils'
6import {
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 killallServers,
11 PeerTubeServer,
12 setAccessTokensToServers,
13 waitJobs
14} from '@shared/server-commands'
15
16const expect = chai.expect
17
18describe('Test video views cleaner', function () {
19 let servers: PeerTubeServer[]
20
21 let videoIdServer1: string
22 let videoIdServer2: string
23
24 before(async function () {
25 this.timeout(120000)
26
27 servers = await createMultipleServers(2)
28 await setAccessTokensToServers(servers)
29
30 await doubleFollow(servers[0], servers[1])
31
32 videoIdServer1 = (await servers[0].videos.quickUpload({ name: 'video server 1' })).uuid
33 videoIdServer2 = (await servers[1].videos.quickUpload({ name: 'video server 2' })).uuid
34
35 await waitJobs(servers)
36
37 await servers[0].videos.view({ id: videoIdServer1 })
38 await servers[1].videos.view({ id: videoIdServer1 })
39 await servers[0].videos.view({ id: videoIdServer2 })
40 await servers[1].videos.view({ id: videoIdServer2 })
41
42 await waitJobs(servers)
43 })
44
45 it('Should not clean old video views', async function () {
46 this.timeout(50000)
47
48 await killallServers([ servers[0] ])
49
50 await servers[0].run({ views: { videos: { remote: { max_age: '10 days' } } } })
51
52 await wait(6000)
53
54 // Should still have views
55
56 {
57 for (const server of servers) {
58 const total = await server.sql.countVideoViewsOf(videoIdServer1)
59 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
60 }
61 }
62
63 {
64 for (const server of servers) {
65 const total = await server.sql.countVideoViewsOf(videoIdServer2)
66 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
67 }
68 }
69 })
70
71 it('Should clean old video views', async function () {
72 this.timeout(50000)
73
74 await killallServers([ servers[0] ])
75
76 await servers[0].run({ views: { videos: { remote: { max_age: '5 seconds' } } } })
77
78 await wait(6000)
79
80 // Should still have views
81
82 {
83 for (const server of servers) {
84 const total = await server.sql.countVideoViewsOf(videoIdServer1)
85 expect(total).to.equal(2)
86 }
87 }
88
89 {
90 const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2)
91 expect(totalServer1).to.equal(0)
92
93 const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2)
94 expect(totalServer2).to.equal(2)
95 }
96 })
97
98 after(async function () {
99 await cleanupTests(servers)
100 })
101})