1 /* tslint:disable:no-unused-expression */
6 flushAndRunMultipleServers,
11 setAccessTokensToServers,
16 } from '../../../../shared/utils'
18 describe('Test AP refresher', function () {
19 let servers: ServerInfo[] = []
20 let videoUUID1: string
21 let videoUUID2: string
22 let videoUUID3: string
24 before(async function () {
27 servers = await flushAndRunMultipleServers(2)
29 // Get the access tokens
30 await setAccessTokensToServers(servers)
33 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' })
34 videoUUID1 = res.body.video.uuid
38 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' })
39 videoUUID2 = res.body.video.uuid
43 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' })
44 videoUUID3 = res.body.video.uuid
47 await doubleFollow(servers[0], servers[1])
50 it('Should remove a deleted remote video', async function () {
55 // Change UUID so the remote server returns a 404
56 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
58 await getVideo(servers[0].url, videoUUID1)
59 await getVideo(servers[0].url, videoUUID2)
61 await waitJobs(servers)
63 await getVideo(servers[0].url, videoUUID1, 404)
64 await getVideo(servers[0].url, videoUUID2, 200)
67 it('Should not update a remote video if the remote instance is down', async function () {
70 killallServers([ servers[1] ])
72 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
74 // Video will need a refresh
77 await getVideo(servers[0].url, videoUUID3)
78 // The refresh should fail
79 await waitJobs([ servers[0] ])
81 await reRunServer(servers[1])
83 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances)
84 await getVideo(servers[0].url, videoUUID3)
85 await waitJobs(servers)
87 await getVideo(servers[0].url, videoUUID3, 200)
90 after(async function () {
91 killallServers(servers)