aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 14:13:53 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 14:13:53 +0100
commit9f79ade627f0044606a9fbbe16ca0154661d12b9 (patch)
treeccfc1876da591bc52cbb4b8ccddedbeae7876679 /server/tests
parent0e0c745b62b2f18e228328e8c4f95b17e54f7a5e (diff)
downloadPeerTube-9f79ade627f0044606a9fbbe16ca0154661d12b9.tar.gz
PeerTube-9f79ade627f0044606a9fbbe16ca0154661d12b9.tar.zst
PeerTube-9f79ade627f0044606a9fbbe16ca0154661d12b9.zip
Refresh playlists
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/refresher.ts130
1 files changed, 98 insertions, 32 deletions
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 62ad8a0b5..ae4859076 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -2,89 +2,155 @@
2 2
3import 'mocha' 3import 'mocha'
4import { 4import {
5 createVideoPlaylist,
5 doubleFollow, 6 doubleFollow,
6 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
8 generateUserAccessToken,
7 getVideo, 9 getVideo,
10 getVideoPlaylist,
8 killallServers, 11 killallServers,
9 reRunServer, 12 reRunServer,
10 ServerInfo, 13 ServerInfo,
11 setAccessTokensToServers, 14 setAccessTokensToServers,
15 setActorField,
16 setDefaultVideoChannel,
17 setPlaylistField,
18 setVideoField,
12 uploadVideo, 19 uploadVideo,
20 uploadVideoAndGetId,
13 wait, 21 wait,
14 setVideoField,
15 waitJobs 22 waitJobs
16} from '../../../../shared/utils' 23} from '../../../../shared/utils'
24import { getAccount } from '../../../../shared/utils/users/accounts'
25import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
17 26
18describe('Test AP refresher', function () { 27describe('Test AP refresher', function () {
19 let servers: ServerInfo[] = [] 28 let servers: ServerInfo[] = []
20 let videoUUID1: string 29 let videoUUID1: string
21 let videoUUID2: string 30 let videoUUID2: string
22 let videoUUID3: string 31 let videoUUID3: string
32 let playlistUUID1: string
33 let playlistUUID2: string
23 34
24 before(async function () { 35 before(async function () {
25 this.timeout(60000) 36 this.timeout(60000)
26 37
27 servers = await flushAndRunMultipleServers(2) 38 servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } })
28 39
29 // Get the access tokens 40 // Get the access tokens
30 await setAccessTokensToServers(servers) 41 await setAccessTokensToServers(servers)
42 await setDefaultVideoChannel(servers)
43
44 {
45 videoUUID1 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video1' })).uuid
46 videoUUID2 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video2' })).uuid
47 videoUUID3 = (await uploadVideoAndGetId({ server: servers[ 1 ], videoName: 'video3' })).uuid
48 }
31 49
32 { 50 {
33 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video1' }) 51 const a1 = await generateUserAccessToken(servers[1], 'user1')
34 videoUUID1 = res.body.video.uuid 52 await uploadVideo(servers[1].url, a1, { name: 'video4' })
53
54 const a2 = await generateUserAccessToken(servers[1], 'user2')
55 await uploadVideo(servers[1].url, a2, { name: 'video5' })
35 } 56 }
36 57
37 { 58 {
38 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) 59 const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
39 videoUUID2 = res.body.video.uuid 60 const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
61 playlistUUID1 = res.body.videoPlaylist.uuid
40 } 62 }
41 63
42 { 64 {
43 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video3' }) 65 const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
44 videoUUID3 = res.body.video.uuid 66 const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })
67 playlistUUID2 = res.body.videoPlaylist.uuid
45 } 68 }
46 69
47 await doubleFollow(servers[0], servers[1]) 70 await doubleFollow(servers[0], servers[1])
48 }) 71 })
49 72
50 it('Should remove a deleted remote video', async function () { 73 describe('Videos refresher', function () {
51 this.timeout(60000) 74
75 it('Should remove a deleted remote video', async function () {
76 this.timeout(60000)
77
78 await wait(10000)
79
80 // Change UUID so the remote server returns a 404
81 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
82
83 await getVideo(servers[ 0 ].url, videoUUID1)
84 await getVideo(servers[ 0 ].url, videoUUID2)
85
86 await waitJobs(servers)
52 87
53 await wait(10000) 88 await getVideo(servers[ 0 ].url, videoUUID1, 404)
89 await getVideo(servers[ 0 ].url, videoUUID2, 200)
90 })
54 91
55 // Change UUID so the remote server returns a 404 92 it('Should not update a remote video if the remote instance is down', async function () {
56 await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') 93 this.timeout(60000)
57 94
58 await getVideo(servers[0].url, videoUUID1) 95 killallServers([ servers[ 1 ] ])
59 await getVideo(servers[0].url, videoUUID2)
60 96
61 await waitJobs(servers) 97 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
62 98
63 await getVideo(servers[0].url, videoUUID1, 404) 99 // Video will need a refresh
64 await getVideo(servers[0].url, videoUUID2, 200) 100 await wait(10000)
101
102 await getVideo(servers[ 0 ].url, videoUUID3)
103 // The refresh should fail
104 await waitJobs([ servers[ 0 ] ])
105
106 await reRunServer(servers[ 1 ])
107
108 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances)
109 await getVideo(servers[ 0 ].url, videoUUID3)
110 await waitJobs(servers)
111
112 await getVideo(servers[ 0 ].url, videoUUID3, 200)
113 })
65 }) 114 })
66 115
67 it('Should not update a remote video if the remote instance is down', async function () { 116 describe('Actors refresher', function () {
68 this.timeout(60000) 117
118 it('Should remove a deleted actor', async function () {
119 this.timeout(60000)
120
121 await wait(10000)
122
123 // Change actor name so the remote server returns a 404
124 await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto')
125
126 await getAccount(servers[ 0 ].url, 'user1@localhost:9002')
127 await getAccount(servers[ 0 ].url, 'user2@localhost:9002')
128
129 await waitJobs(servers)
130
131 await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200)
132 await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404)
133 })
134 })
69 135
70 killallServers([ servers[1] ]) 136 describe('Playlist refresher', function () {
71 137
72 await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') 138 it('Should remove a deleted playlist', async function () {
139 this.timeout(60000)
73 140
74 // Video will need a refresh 141 await wait(10000)
75 await wait(10000)
76 142
77 await getVideo(servers[0].url, videoUUID3) 143 // Change UUID so the remote server returns a 404
78 // The refresh should fail 144 await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
79 await waitJobs([ servers[0] ])
80 145
81 await reRunServer(servers[1]) 146 await getVideoPlaylist(servers[ 0 ].url, playlistUUID1)
147 await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)
82 148
83 // Should not refresh the video, even if the last refresh failed (to avoir a loop on dead instances) 149 await waitJobs(servers)
84 await getVideo(servers[0].url, videoUUID3)
85 await waitJobs(servers)
86 150
87 await getVideo(servers[0].url, videoUUID3, 200) 151 await getVideoPlaylist(servers[ 0 ].url, playlistUUID1, 200)
152 await getVideoPlaylist(servers[ 0 ].url, playlistUUID2, 404)
153 })
88 }) 154 })
89 155
90 after(async function () { 156 after(async function () {