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