2020-01-31 09:56:52 -06:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-12-17 04:58:15 -06:00
|
|
|
import { wait } from '@shared/core-utils'
|
|
|
|
import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
|
2018-12-07 09:09:57 -06:00
|
|
|
import {
|
2021-07-07 06:38:26 -05:00
|
|
|
cleanupTests,
|
2021-07-16 02:47:51 -05:00
|
|
|
createMultipleServers,
|
2021-07-16 07:27:30 -05:00
|
|
|
doubleFollow,
|
2019-04-26 01:50:52 -05:00
|
|
|
killallServers,
|
2021-07-16 02:47:51 -05:00
|
|
|
PeerTubeServer,
|
2018-12-07 09:09:57 -06:00
|
|
|
setAccessTokensToServers,
|
2019-03-19 08:13:53 -05:00
|
|
|
setDefaultVideoChannel,
|
2018-12-07 09:09:57 -06:00
|
|
|
waitJobs
|
2021-12-17 02:29:23 -06:00
|
|
|
} from '@shared/server-commands'
|
2018-11-20 03:05:51 -06:00
|
|
|
|
|
|
|
describe('Test AP refresher', function () {
|
2021-07-16 02:47:51 -05:00
|
|
|
let servers: PeerTubeServer[] = []
|
2018-11-20 03:05:51 -06:00
|
|
|
let videoUUID1: string
|
|
|
|
let videoUUID2: string
|
|
|
|
let videoUUID3: string
|
2019-03-19 08:13:53 -05:00
|
|
|
let playlistUUID1: string
|
|
|
|
let playlistUUID2: string
|
2018-11-20 03:05:51 -06:00
|
|
|
|
|
|
|
before(async function () {
|
2019-01-08 08:51:52 -06:00
|
|
|
this.timeout(60000)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2022-02-11 03:51:33 -06:00
|
|
|
servers = await createMultipleServers(2)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
2019-03-19 08:13:53 -05:00
|
|
|
await setDefaultVideoChannel(servers)
|
|
|
|
|
2022-02-11 03:51:33 -06:00
|
|
|
for (const server of servers) {
|
|
|
|
await server.config.disableTranscoding()
|
|
|
|
}
|
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid
|
|
|
|
videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid
|
|
|
|
videoUUID3 = (await servers[1].videos.quickUpload({ name: 'video3' })).uuid
|
2019-03-19 08:13:53 -05:00
|
|
|
}
|
2018-11-20 03:05:51 -06:00
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
const token1 = await servers[1].users.generateUserAndToken('user1')
|
|
|
|
await servers[1].videos.upload({ token: token1, attributes: { name: 'video4' } })
|
2019-03-19 08:13:53 -05:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
const token2 = await servers[1].users.generateUserAndToken('user2')
|
|
|
|
await servers[1].videos.upload({ token: token2, attributes: { name: 'video5' } })
|
2018-11-20 03:05:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
|
|
|
|
const created = await servers[1].playlists.create({ attributes })
|
2021-07-08 08:54:39 -05:00
|
|
|
playlistUUID1 = created.uuid
|
2018-11-20 03:05:51 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2021-07-16 02:04:35 -05:00
|
|
|
const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
|
|
|
|
const created = await servers[1].playlists.create({ attributes })
|
2021-07-08 08:54:39 -05:00
|
|
|
playlistUUID2 = created.uuid
|
2018-11-20 03:05:51 -06:00
|
|
|
}
|
|
|
|
|
2020-01-31 09:56:52 -06:00
|
|
|
await doubleFollow(servers[0], servers[1])
|
2018-11-20 03:05:51 -06:00
|
|
|
})
|
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
describe('Videos refresher', function () {
|
|
|
|
|
|
|
|
it('Should remove a deleted remote video', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
|
|
|
await wait(10000)
|
|
|
|
|
|
|
|
// Change UUID so the remote server returns a 404
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
|
2019-03-19 08:13:53 -05:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].videos.get({ id: videoUUID1 })
|
|
|
|
await servers[0].videos.get({ id: videoUUID2 })
|
2019-03-19 08:13:53 -05:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].videos.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
|
|
|
|
await servers[0].videos.get({ id: videoUUID2 })
|
2019-03-19 08:13:53 -05:00
|
|
|
})
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
it('Should not update a remote video if the remote instance is down', async function () {
|
2020-01-22 02:24:26 -06:00
|
|
|
this.timeout(70000)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-07-09 08:37:43 -05:00
|
|
|
await killallServers([ servers[1] ])
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
// Video will need a refresh
|
|
|
|
await wait(10000)
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].videos.get({ id: videoUUID3 })
|
2019-03-19 08:13:53 -05:00
|
|
|
// The refresh should fail
|
2020-01-31 09:56:52 -06:00
|
|
|
await waitJobs([ servers[0] ])
|
2019-03-19 08:13:53 -05:00
|
|
|
|
2021-07-16 02:47:51 -05:00
|
|
|
await servers[1].run()
|
2019-03-19 08:13:53 -05:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].videos.get({ id: videoUUID3 })
|
2019-03-19 08:13:53 -05:00
|
|
|
})
|
2018-11-20 03:05:51 -06:00
|
|
|
})
|
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
describe('Actors refresher', function () {
|
|
|
|
|
|
|
|
it('Should remove a deleted actor', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
const command = servers[0].accounts
|
2021-07-07 06:38:26 -05:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
await wait(10000)
|
|
|
|
|
|
|
|
// Change actor name so the remote server returns a 404
|
2020-01-31 09:56:52 -06:00
|
|
|
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
|
2019-03-19 08:13:53 -05:00
|
|
|
|
2021-07-07 06:38:26 -05:00
|
|
|
await command.get({ accountName: 'user1@localhost:' + servers[1].port })
|
|
|
|
await command.get({ accountName: 'user2@localhost:' + servers[1].port })
|
2019-03-19 08:13:53 -05:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2021-07-07 06:38:26 -05:00
|
|
|
await command.get({ accountName: 'user1@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.OK_200 })
|
|
|
|
await command.get({ accountName: 'user2@localhost:' + servers[1].port, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
|
2019-03-19 08:13:53 -05:00
|
|
|
})
|
|
|
|
})
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
describe('Playlist refresher', function () {
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
it('Should remove a deleted playlist', async function () {
|
|
|
|
this.timeout(60000)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
await wait(10000)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
// Change UUID so the remote server returns a 404
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].playlists.get({ playlistId: playlistUUID1 })
|
|
|
|
await servers[0].playlists.get({ playlistId: playlistUUID2 })
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2019-03-19 08:13:53 -05:00
|
|
|
await waitJobs(servers)
|
2018-11-20 03:05:51 -06:00
|
|
|
|
2021-07-16 02:04:35 -05:00
|
|
|
await servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
|
|
|
|
await servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
|
2019-03-19 08:13:53 -05:00
|
|
|
})
|
2018-11-20 03:05:51 -06:00
|
|
|
})
|
|
|
|
|
2019-04-26 01:50:52 -05:00
|
|
|
after(async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
await cleanupTests(servers)
|
2018-11-20 03:05:51 -06:00
|
|
|
})
|
|
|
|
})
|