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