]>
Commit | Line | Data |
---|---|---|
04b8c3fb C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
2a8c5d0a C |
4 | import { |
5 | doubleFollow, | |
6 | flushAndRunMultipleServers, | |
7 | getVideo, | |
8 | killallServers, | |
9 | reRunServer, | |
10 | ServerInfo, | |
11 | setAccessTokensToServers, | |
12 | uploadVideo, | |
13 | wait, | |
14 | setVideoField, | |
15 | waitJobs | |
16 | } from '../../../../shared/utils' | |
04b8c3fb C |
17 | |
18 | describe('Test AP refresher', function () { | |
19 | let servers: ServerInfo[] = [] | |
20 | let videoUUID1: string | |
21 | let videoUUID2: string | |
22 | let videoUUID3: string | |
23 | ||
24 | before(async function () { | |
89ada4e2 | 25 | this.timeout(60000) |
04b8c3fb C |
26 | |
27 | servers = await flushAndRunMultipleServers(2) | |
28 | ||
29 | // Get the access tokens | |
30 | await setAccessTokensToServers(servers) | |
31 | ||
32 | { | |
33 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' }) | |
34 | videoUUID1 = res.body.video.uuid | |
35 | } | |
36 | ||
37 | { | |
38 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) | |
39 | videoUUID2 = res.body.video.uuid | |
40 | } | |
41 | ||
42 | { | |
43 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' }) | |
44 | videoUUID3 = res.body.video.uuid | |
45 | } | |
46 | ||
47 | await doubleFollow(servers[0], servers[1]) | |
48 | }) | |
49 | ||
50 | it('Should remove a deleted remote video', async function () { | |
51 | this.timeout(60000) | |
52 | ||
53 | await wait(10000) | |
54 | ||
55 | // Change UUID so the remote server returns a 404 | |
56 | await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') | |
57 | ||
58 | await getVideo(servers[0].url, videoUUID1) | |
59 | await getVideo(servers[0].url, videoUUID2) | |
60 | ||
61 | await waitJobs(servers) | |
62 | ||
63 | await getVideo(servers[0].url, videoUUID1, 404) | |
64 | await getVideo(servers[0].url, videoUUID2, 200) | |
65 | }) | |
66 | ||
67 | it('Should not update a remote video if the remote instance is down', async function () { | |
68 | this.timeout(60000) | |
69 | ||
70 | killallServers([ servers[1] ]) | |
71 | ||
72 | await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') | |
73 | ||
74 | // Video will need a refresh | |
75 | await wait(10000) | |
76 | ||
77 | await getVideo(servers[0].url, videoUUID3) | |
78 | // The refresh should fail | |
79 | await waitJobs([ servers[0] ]) | |
80 | ||
81 | await reRunServer(servers[1]) | |
82 | ||
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) | |
86 | ||
87 | await getVideo(servers[0].url, videoUUID3, 200) | |
88 | }) | |
89 | ||
90 | after(async function () { | |
91 | killallServers(servers) | |
92 | }) | |
93 | }) |