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