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