diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
commit | 88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch) | |
tree | b242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /server/tests/api/activitypub/refresher.ts | |
parent | 53a94c7cfa8368da4cd248d65df8346905938f0c (diff) | |
parent | 9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff) | |
download | PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip |
Merge branch 'develop' into pr/1217
Diffstat (limited to 'server/tests/api/activitypub/refresher.ts')
-rw-r--r-- | server/tests/api/activitypub/refresher.ts | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts new file mode 100644 index 000000000..62ad8a0b5 --- /dev/null +++ b/server/tests/api/activitypub/refresher.ts | |||
@@ -0,0 +1,93 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
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' | ||
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 () { | ||
25 | this.timeout(60000) | ||
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 | }) | ||