]>
Commit | Line | Data |
---|---|---|
04b8c3fb C |
1 | /* tslint:disable:no-unused-expression */ |
2 | ||
3 | import 'mocha' | |
2a8c5d0a | 4 | import { |
9f79ade6 | 5 | createVideoPlaylist, |
2a8c5d0a C |
6 | doubleFollow, |
7 | flushAndRunMultipleServers, | |
9f79ade6 | 8 | generateUserAccessToken, |
2a8c5d0a | 9 | getVideo, |
9f79ade6 | 10 | getVideoPlaylist, |
2ba92871 | 11 | killallServers, rateVideo, |
2a8c5d0a C |
12 | reRunServer, |
13 | ServerInfo, | |
14 | setAccessTokensToServers, | |
9f79ade6 C |
15 | setActorField, |
16 | setDefaultVideoChannel, | |
17 | setPlaylistField, | |
18 | setVideoField, | |
2a8c5d0a | 19 | uploadVideo, |
9f79ade6 | 20 | uploadVideoAndGetId, |
2a8c5d0a | 21 | wait, |
2a8c5d0a C |
22 | waitJobs |
23 | } from '../../../../shared/utils' | |
9f79ade6 C |
24 | import { getAccount } from '../../../../shared/utils/users/accounts' |
25 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos' | |
04b8c3fb C |
26 | |
27 | describe('Test AP refresher', function () { | |
28 | let servers: ServerInfo[] = [] | |
29 | let videoUUID1: string | |
30 | let videoUUID2: string | |
31 | let videoUUID3: string | |
9f79ade6 C |
32 | let playlistUUID1: string |
33 | let playlistUUID2: string | |
04b8c3fb C |
34 | |
35 | before(async function () { | |
89ada4e2 | 36 | this.timeout(60000) |
04b8c3fb | 37 | |
9f79ade6 | 38 | servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } }) |
04b8c3fb C |
39 | |
40 | // Get the access tokens | |
41 | await setAccessTokensToServers(servers) | |
9f79ade6 C |
42 | await setDefaultVideoChannel(servers) |
43 | ||
44 | { | |
45 | videoUUID1 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video1' })).uuid | |
46 | videoUUID2 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video2' })).uuid | |
47 | videoUUID3 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video3' })).uuid | |
48 | } | |
04b8c3fb C |
49 | |
50 | { | |
9f79ade6 C |
51 | const a1 = await generateUserAccessToken(servers[1], 'user1') |
52 | await uploadVideo(servers[1].url, a1, { name: 'video4' }) | |
53 | ||
54 | const a2 = await generateUserAccessToken(servers[1], 'user2') | |
55 | await uploadVideo(servers[1].url, a2, { name: 'video5' }) | |
04b8c3fb C |
56 | } |
57 | ||
58 | { | |
9f79ade6 C |
59 | const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } |
60 | const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) | |
61 | playlistUUID1 = res.body.videoPlaylist.uuid | |
04b8c3fb C |
62 | } |
63 | ||
64 | { | |
9f79ade6 C |
65 | const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } |
66 | const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs }) | |
67 | playlistUUID2 = res.body.videoPlaylist.uuid | |
04b8c3fb C |
68 | } |
69 | ||
70 | await doubleFollow(servers[0], servers[1]) | |
71 | }) | |
72 | ||
9f79ade6 C |
73 | describe('Videos refresher', function () { |
74 | ||
75 | it('Should remove a deleted remote video', async function () { | |
76 | this.timeout(60000) | |
77 | ||
78 | await wait(10000) | |
79 | ||
80 | // Change UUID so the remote server returns a 404 | |
81 | await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') | |
82 | ||
83 | await getVideo(servers[ 0 ].url, videoUUID1) | |
84 | await getVideo(servers[ 0 ].url, videoUUID2) | |
85 | ||
86 | await waitJobs(servers) | |
04b8c3fb | 87 | |
9f79ade6 C |
88 | await getVideo(servers[ 0 ].url, videoUUID1, 404) |
89 | await getVideo(servers[ 0 ].url, videoUUID2, 200) | |
90 | }) | |
04b8c3fb | 91 | |
9f79ade6 C |
92 | it('Should not update a remote video if the remote instance is down', async function () { |
93 | this.timeout(60000) | |
04b8c3fb | 94 | |
9f79ade6 | 95 | killallServers([ servers[ 1 ] ]) |
04b8c3fb | 96 | |
9f79ade6 | 97 | await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') |
04b8c3fb | 98 | |
9f79ade6 C |
99 | // Video will need a refresh |
100 | await wait(10000) | |
101 | ||
102 | await getVideo(servers[ 0 ].url, videoUUID3) | |
103 | // The refresh should fail | |
104 | await waitJobs([ servers[ 0 ] ]) | |
105 | ||
106 | await reRunServer(servers[ 1 ]) | |
107 | ||
108 | // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances) | |
109 | await getVideo(servers[ 0 ].url, videoUUID3) | |
110 | await waitJobs(servers) | |
111 | ||
112 | await getVideo(servers[ 0 ].url, videoUUID3, 200) | |
113 | }) | |
04b8c3fb C |
114 | }) |
115 | ||
9f79ade6 C |
116 | describe('Actors refresher', function () { |
117 | ||
118 | it('Should remove a deleted actor', async function () { | |
119 | this.timeout(60000) | |
120 | ||
121 | await wait(10000) | |
122 | ||
123 | // Change actor name so the remote server returns a 404 | |
124 | await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto') | |
125 | ||
126 | await getAccount(servers[ 0 ].url, 'user1@localhost:9002') | |
127 | await getAccount(servers[ 0 ].url, 'user2@localhost:9002') | |
128 | ||
129 | await waitJobs(servers) | |
130 | ||
131 | await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200) | |
132 | await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404) | |
133 | }) | |
134 | }) | |
04b8c3fb | 135 | |
9f79ade6 | 136 | describe('Playlist refresher', function () { |
04b8c3fb | 137 | |
9f79ade6 C |
138 | it('Should remove a deleted playlist', async function () { |
139 | this.timeout(60000) | |
04b8c3fb | 140 | |
9f79ade6 | 141 | await wait(10000) |
04b8c3fb | 142 | |
9f79ade6 C |
143 | // Change UUID so the remote server returns a 404 |
144 | await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') | |
04b8c3fb | 145 | |
9f79ade6 C |
146 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID1) |
147 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID2) | |
04b8c3fb | 148 | |
9f79ade6 | 149 | await waitJobs(servers) |
04b8c3fb | 150 | |
9f79ade6 C |
151 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID1, 200) |
152 | await getVideoPlaylist(servers[ 0 ].url, playlistUUID2, 404) | |
153 | }) | |
04b8c3fb C |
154 | }) |
155 | ||
156 | after(async function () { | |
157 | killallServers(servers) | |
158 | }) | |
159 | }) |