]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/activitypub/refresher.ts
Fix adding captions to a video
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / refresher.ts
1 /* tslint:disable:no-unused-expression */
2
3 import 'mocha'
4 import { doubleFollow, getVideo, reRunServer } from '../../utils'
5 import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../utils/index'
6 import { waitJobs } from '../../utils/server/jobs'
7 import { setVideoField } from '../../utils/miscs/sql'
8
9 describe('Test AP refresher', function () {
10 let servers: ServerInfo[] = []
11 let videoUUID1: string
12 let videoUUID2: string
13 let videoUUID3: string
14
15 before(async function () {
16 this.timeout(30000)
17
18 servers = await flushAndRunMultipleServers(2)
19
20 // Get the access tokens
21 await setAccessTokensToServers(servers)
22
23 {
24 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
25 videoUUID1 = res.body.video.uuid
26 }
27
28 {
29 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
30 videoUUID2 = res.body.video.uuid
31 }
32
33 {
34 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' })
35 videoUUID3 = res.body.video.uuid
36 }
37
38 await doubleFollow(servers[0], servers[1])
39 })
40
41 it('Should remove a deleted remote video', async function () {
42 this.timeout(60000)
43
44 await wait(10000)
45
46 // Change UUID so the remote server returns a 404
47 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
48
49 await getVideo(servers[0].url, videoUUID1)
50 await getVideo(servers[0].url, videoUUID2)
51
52 await waitJobs(servers)
53
54 await getVideo(servers[0].url, videoUUID1, 404)
55 await getVideo(servers[0].url, videoUUID2, 200)
56 })
57
58 it('Should not update a remote video if the remote instance is down', async function () {
59 this.timeout(60000)
60
61 killallServers([ servers[1] ])
62
63 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
64
65 // Video will need a refresh
66 await wait(10000)
67
68 await getVideo(servers[0].url, videoUUID3)
69 // The refresh should fail
70 await waitJobs([ servers[0] ])
71
72 await reRunServer(servers[1])
73
74 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances)
75 await getVideo(servers[0].url, videoUUID3)
76 await waitJobs(servers)
77
78 await getVideo(servers[0].url, videoUUID3, 200)
79 })
80
81 after(async function () {
82 killallServers(servers)
83 })
84 })