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