2020-01-31 16:56:52 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
2018-11-20 10:05:51 +01:00
|
|
|
|
|
|
|
import 'mocha'
|
2018-12-07 16:09:57 +01:00
|
|
|
import {
|
2019-04-26 08:50:52 +02:00
|
|
|
cleanupTests, closeAllSequelize,
|
2019-03-19 14:13:53 +01:00
|
|
|
createVideoPlaylist,
|
2018-12-07 16:09:57 +01:00
|
|
|
doubleFollow,
|
|
|
|
flushAndRunMultipleServers,
|
2019-03-19 14:13:53 +01:00
|
|
|
generateUserAccessToken,
|
2018-12-07 16:09:57 +01:00
|
|
|
getVideo,
|
2019-03-19 14:13:53 +01:00
|
|
|
getVideoPlaylist,
|
2019-04-26 08:50:52 +02:00
|
|
|
killallServers,
|
2018-12-07 16:09:57 +01:00
|
|
|
reRunServer,
|
|
|
|
ServerInfo,
|
|
|
|
setAccessTokensToServers,
|
2019-03-19 14:13:53 +01:00
|
|
|
setActorField,
|
|
|
|
setDefaultVideoChannel,
|
|
|
|
setPlaylistField,
|
|
|
|
setVideoField,
|
2018-12-07 16:09:57 +01:00
|
|
|
uploadVideo,
|
2019-03-19 14:13:53 +01:00
|
|
|
uploadVideoAndGetId,
|
2018-12-07 16:09:57 +01:00
|
|
|
wait,
|
|
|
|
waitJobs
|
2019-04-15 15:26:15 +02:00
|
|
|
} from '../../../../shared/extra-utils'
|
|
|
|
import { getAccount } from '../../../../shared/extra-utils/users/accounts'
|
2019-03-19 14:13:53 +01:00
|
|
|
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
|
2018-11-20 10:05:51 +01:00
|
|
|
|
|
|
|
describe('Test AP refresher', function () {
|
|
|
|
let servers: ServerInfo[] = []
|
|
|
|
let videoUUID1: string
|
|
|
|
let videoUUID2: string
|
|
|
|
let videoUUID3: string
|
2019-03-19 14:13:53 +01:00
|
|
|
let playlistUUID1: string
|
|
|
|
let playlistUUID2: string
|
2018-11-20 10:05:51 +01:00
|
|
|
|
|
|
|
before(async function () {
|
2019-01-08 15:51:52 +01:00
|
|
|
this.timeout(60000)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } })
|
2018-11-20 10:05:51 +01:00
|
|
|
|
|
|
|
// Get the access tokens
|
|
|
|
await setAccessTokensToServers(servers)
|
2019-03-19 14:13:53 +01:00
|
|
|
await setDefaultVideoChannel(servers)
|
|
|
|
|
|
|
|
{
|
2020-01-31 16:56:52 +01:00
|
|
|
videoUUID1 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video1' })).uuid
|
|
|
|
videoUUID2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video2' })).uuid
|
|
|
|
videoUUID3 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video3' })).uuid
|
2019-03-19 14:13:53 +01:00
|
|
|
}
|
2018-11-20 10:05:51 +01:00
|
|
|
|
|
|
|
{
|
2020-01-31 16:56:52 +01:00
|
|
|
const a1 = await generateUserAccessToken(servers[1], 'user1')
|
|
|
|
await uploadVideo(servers[1].url, a1, { name: 'video4' })
|
2019-03-19 14:13:53 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
const a2 = await generateUserAccessToken(servers[1], 'user2')
|
|
|
|
await uploadVideo(servers[1].url, a2, { name: 'video5' })
|
2018-11-20 10:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2020-01-31 16:56:52 +01:00
|
|
|
const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
|
|
|
|
const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
|
2019-03-19 14:13:53 +01:00
|
|
|
playlistUUID1 = res.body.videoPlaylist.uuid
|
2018-11-20 10:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2020-01-31 16:56:52 +01:00
|
|
|
const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
|
|
|
|
const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
|
2019-03-19 14:13:53 +01:00
|
|
|
playlistUUID2 = res.body.videoPlaylist.uuid
|
2018-11-20 10:05:51 +01:00
|
|
|
}
|
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await doubleFollow(servers[0], servers[1])
|
2018-11-20 10:05:51 +01:00
|
|
|
})
|
|
|
|
|
2019-03-19 14:13:53 +01: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
|
2020-01-31 16:56:52 +01:00
|
|
|
await setVideoField(servers[1].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
|
2019-03-19 14:13:53 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideo(servers[0].url, videoUUID1)
|
|
|
|
await getVideo(servers[0].url, videoUUID2)
|
2019-03-19 14:13:53 +01:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideo(servers[0].url, videoUUID1, 404)
|
|
|
|
await getVideo(servers[0].url, videoUUID2, 200)
|
2019-03-19 14:13:53 +01:00
|
|
|
})
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
it('Should not update a remote video if the remote instance is down', async function () {
|
2020-01-22 09:24:26 +01:00
|
|
|
this.timeout(70000)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
killallServers([ servers[1] ])
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await setVideoField(servers[1].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
// Video will need a refresh
|
|
|
|
await wait(10000)
|
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideo(servers[0].url, videoUUID3)
|
2019-03-19 14:13:53 +01:00
|
|
|
// The refresh should fail
|
2020-01-31 16:56:52 +01:00
|
|
|
await waitJobs([ servers[0] ])
|
2019-03-19 14:13:53 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await reRunServer(servers[1])
|
2019-03-19 14:13:53 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideo(servers[0].url, videoUUID3, 200)
|
2019-03-19 14:13:53 +01:00
|
|
|
})
|
2018-11-20 10:05:51 +01:00
|
|
|
})
|
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
describe('Actors refresher', function () {
|
|
|
|
|
|
|
|
it('Should remove a deleted actor', async function () {
|
|
|
|
this.timeout(60000)
|
|
|
|
|
|
|
|
await wait(10000)
|
|
|
|
|
|
|
|
// Change actor name so the remote server returns a 404
|
2020-01-31 16:56:52 +01:00
|
|
|
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
|
|
|
|
await setActorField(servers[1].internalServerNumber, to, 'preferredUsername', 'toto')
|
2019-03-19 14:13:53 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port)
|
|
|
|
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port)
|
2019-03-19 14:13:53 +01:00
|
|
|
|
|
|
|
await waitJobs(servers)
|
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, 200)
|
|
|
|
await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, 404)
|
2019-03-19 14:13:53 +01:00
|
|
|
})
|
|
|
|
})
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
describe('Playlist refresher', function () {
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
it('Should remove a deleted playlist', async function () {
|
|
|
|
this.timeout(60000)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
await wait(10000)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
// Change UUID so the remote server returns a 404
|
2020-01-31 16:56:52 +01:00
|
|
|
await setPlaylistField(servers[1].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideoPlaylist(servers[0].url, playlistUUID1)
|
|
|
|
await getVideoPlaylist(servers[0].url, playlistUUID2)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2019-03-19 14:13:53 +01:00
|
|
|
await waitJobs(servers)
|
2018-11-20 10:05:51 +01:00
|
|
|
|
2020-01-31 16:56:52 +01:00
|
|
|
await getVideoPlaylist(servers[0].url, playlistUUID1, 200)
|
|
|
|
await getVideoPlaylist(servers[0].url, playlistUUID2, 404)
|
2019-03-19 14:13:53 +01:00
|
|
|
})
|
2018-11-20 10:05:51 +01:00
|
|
|
})
|
|
|
|
|
2019-04-26 08:50:52 +02:00
|
|
|
after(async function () {
|
|
|
|
this.timeout(10000)
|
|
|
|
|
|
|
|
await cleanupTests(servers)
|
|
|
|
|
|
|
|
await closeAllSequelize(servers)
|
2018-11-20 10:05:51 +01:00
|
|
|
})
|
|
|
|
})
|