]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/activitypub/refresher.ts
Add runner server tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / activitypub / refresher.ts
index 81fee004471c2a348884f7271ecce2385443c8c6..6c48b7ac8d312613520a27478e51a25cfd1ab777 100644 (file)
@@ -1,6 +1,8 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
+import { SQLCommand } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
 import {
   cleanupTests,
   createMultipleServers,
@@ -9,13 +11,12 @@ import {
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel,
-  wait,
   waitJobs
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
+} from '@shared/server-commands'
 
 describe('Test AP refresher', function () {
   let servers: PeerTubeServer[] = []
+  let sqlCommandServer2: SQLCommand
   let videoUUID1: string
   let videoUUID2: string
   let videoUUID3: string
@@ -25,12 +26,16 @@ describe('Test AP refresher', function () {
   before(async function () {
     this.timeout(60000)
 
-    servers = await createMultipleServers(2, { transcoding: { enabled: false } })
+    servers = await createMultipleServers(2)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
     await setDefaultVideoChannel(servers)
 
+    for (const server of servers) {
+      await server.config.disableTranscoding()
+    }
+
     {
       videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid
       videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid
@@ -58,6 +63,8 @@ describe('Test AP refresher', function () {
     }
 
     await doubleFollow(servers[0], servers[1])
+
+    sqlCommandServer2 = new SQLCommand(servers[1])
   })
 
   describe('Videos refresher', function () {
@@ -68,7 +75,7 @@ describe('Test AP refresher', function () {
       await wait(10000)
 
       // Change UUID so the remote server returns a 404
-      await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
+      await sqlCommandServer2.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
 
       await servers[0].videos.get({ id: videoUUID1 })
       await servers[0].videos.get({ id: videoUUID2 })
@@ -84,7 +91,7 @@ describe('Test AP refresher', function () {
 
       await killallServers([ servers[1] ])
 
-      await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
+      await sqlCommandServer2.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
 
       // Video will need a refresh
       await wait(10000)
@@ -109,16 +116,16 @@ describe('Test AP refresher', function () {
       await wait(10000)
 
       // Change actor name so the remote server returns a 404
-      const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
-      await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
+      const to = servers[1].url + '/accounts/user2'
+      await sqlCommandServer2.setActorField(to, 'preferredUsername', 'toto')
 
-      await command.get({ accountName: 'user1@localhost:' + servers[1].port })
-      await command.get({ accountName: 'user2@localhost:' + servers[1].port })
+      await command.get({ accountName: 'user1@' + servers[1].host })
+      await command.get({ accountName: 'user2@' + servers[1].host })
 
       await waitJobs(servers)
 
-      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 })
+      await command.get({ accountName: 'user1@' + servers[1].host, expectedStatus: HttpStatusCode.OK_200 })
+      await command.get({ accountName: 'user2@' + servers[1].host, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
     })
   })
 
@@ -130,7 +137,7 @@ describe('Test AP refresher', function () {
       await wait(10000)
 
       // Change UUID so the remote server returns a 404
-      await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
+      await sqlCommandServer2.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
 
       await servers[0].playlists.get({ playlistId: playlistUUID1 })
       await servers[0].playlists.get({ playlistId: playlistUUID2 })
@@ -145,6 +152,8 @@ describe('Test AP refresher', function () {
   after(async function () {
     this.timeout(10000)
 
+    await sqlCommandServer2.cleanup()
+
     await cleanupTests(servers)
   })
 })