Răsfoiți Sursa

[web] move free compiles up one bracket (#29411)

GitOrigin-RevId: 613b703d677d91110cd6dcf085e9291008e05f5c
Jakob Ackermann 9 luni în urmă
părinte
comite
a80b69abe5

+ 2 - 0
services/web/app/src/Features/Compile/ClsiManager.mjs

@@ -52,6 +52,8 @@ function getNewCompileBackendClass(projectId, compileBackendClass) {
       return 'n4'
     case 'c2d':
       return 'n4'
+    case 'c3d':
+      return 'n4'
     case 'c4d':
       return 'n4'
     default:

+ 1 - 1
services/web/app/src/Features/Compile/CompileManager.mjs

@@ -135,7 +135,7 @@ async function _getProjectCompileLimits(project) {
     timeout:
       ownerFeatures.compileTimeout || Settings.defaultFeatures.compileTimeout,
     compileGroup,
-    compileBackendClass: compileGroup === 'standard' ? 'n2d' : 'c4d',
+    compileBackendClass: compileGroup === 'standard' ? 'c3d' : 'c4d',
     ownerAnalyticsId: analyticsId,
   }
   return limits

+ 21 - 21
services/web/test/unit/src/Compile/ClsiCookieManager.test.mjs

@@ -55,17 +55,17 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         '',
-        'n2d'
+        'c3d'
       )
       ctx.redis.get
-        .calledWith(`clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`)
+        .calledWith(`clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`)
         .should.equal(true)
       serverId.should.equal('clsi-7')
     })
 
     it('should fallback to old key', async function (ctx) {
       ctx.redis.get
-        .withArgs(`clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`)
+        .withArgs(`clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`)
         .resolves(null)
       ctx.redis.get
         .withArgs(`clsiserver:${ctx.project_id}:${ctx.user_id}`)
@@ -74,10 +74,10 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         '',
-        'n2d'
+        'c3d'
       )
       ctx.redis.get
-        .calledWith(`clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`)
+        .calledWith(`clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`)
         .should.equal(true)
       ctx.redis.get
         .calledWith(`clsiserver:${ctx.project_id}:${ctx.user_id}`)
@@ -109,7 +109,7 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         '',
-        'n2d'
+        'c3d'
       )
       ctx.ClsiCookieManager.promises._populateServerIdViaRequest
         .calledWith(ctx.project_id, ctx.user_id)
@@ -140,13 +140,13 @@ describe('ClsiCookieManager', function () {
           ctx.project_id,
           ctx.user_id,
           'standard',
-          'n2d'
+          'c3d'
         )
         const args = ctx.ClsiCookieManager.promises.setServerId.args[0]
         args[0].should.equal(ctx.project_id)
         args[1].should.equal(ctx.user_id)
         args[2].should.equal('standard')
-        args[3].should.equal('n2d')
+        args[3].should.equal('c3d')
         args[4].should.deep.equal(ctx.clsiServerId)
       })
 
@@ -156,7 +156,7 @@ describe('ClsiCookieManager', function () {
             ctx.project_id,
             ctx.user_id,
             '',
-            'n2d'
+            'c3d'
           )
         serverId.should.equal(ctx.clsiServerId)
       })
@@ -175,7 +175,7 @@ describe('ClsiCookieManager', function () {
           ctx.project_id,
           ctx.user_id,
           'standard',
-          'n2d',
+          'c3d',
           ctx.clsiServerId,
           null
         )
@@ -189,10 +189,10 @@ describe('ClsiCookieManager', function () {
       await ctx.ClsiCookieManager.promises.clearServerId(
         ctx.project_id,
         ctx.user_id,
-        'n2d'
+        'c3d'
       )
       ctx.redis.del.should.have.been.calledWith(
-        `clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`,
+        `clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`,
         `clsiserver:${ctx.project_id}:${ctx.user_id}`
       )
     })
@@ -211,12 +211,12 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         'standard',
-        'n2d',
+        'c3d',
         ctx.clsiServerId,
         null
       )
       ctx.redis.setex.should.have.been.calledWith(
-        `clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`,
+        `clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`,
         ctx.settings.clsiCookie.ttlInSeconds,
         ctx.clsiServerId
       )
@@ -228,12 +228,12 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         'standard',
-        'n2d',
+        'c3d',
         ctx.clsiServerId,
         null
       )
       expect(ctx.redis.setex).to.have.been.calledWith(
-        `clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`,
+        `clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`,
         ctx.settings.clsiCookie.ttlInSecondsRegular,
         ctx.clsiServerId
       )
@@ -256,7 +256,7 @@ describe('ClsiCookieManager', function () {
           ctx.project_id,
           ctx.user_id,
           'standard',
-          'n2d',
+          'c3d',
           ctx.clsiServerId,
           null
         )
@@ -281,12 +281,12 @@ describe('ClsiCookieManager', function () {
         ctx.project_id,
         ctx.user_id,
         'standard',
-        'n2d',
+        'c3d',
         ctx.clsiServerId,
         null
       )
       ctx.redis_secondary.setex.should.have.been.calledWith(
-        `clsiserver:n2d:${ctx.project_id}:${ctx.user_id}`,
+        `clsiserver:c3d:${ctx.project_id}:${ctx.user_id}`,
         ctx.settings.clsiCookie.ttlInSeconds,
         ctx.clsiServerId
       )
@@ -300,14 +300,14 @@ describe('ClsiCookieManager', function () {
             ctx.project_id,
             ctx.user_id,
             'standard',
-            'n2d',
+            'c3d',
             ctx.clsiServerId,
             'previous-clsi-server-id'
           )
           expect(
             ctx.fetchUtils.fetchStringWithResponse
           ).to.have.been.calledWith(
-            `${ctx.settings.apis.clsi.url}/instance-state?clsiserverid=previous-clsi-server-id&compileGroup=standard&compileBackendClass=n2d`,
+            `${ctx.settings.apis.clsi.url}/instance-state?clsiserverid=previous-clsi-server-id&compileGroup=standard&compileBackendClass=c3d`,
             { method: 'GET', signal: sinon.match.instanceOf(AbortSignal) }
           )
         }

+ 18 - 18
services/web/test/unit/src/Compile/ClsiManager.test.mjs

@@ -149,7 +149,7 @@ describe('ClsiManager', function () {
         },
         clsi: {
           url: `http://${CLSI_HOST}`,
-          submissionBackendClass: 'n2d',
+          submissionBackendClass: 'c3d',
         },
         clsi_new: {
           sample: 100,
@@ -280,7 +280,7 @@ describe('ClsiManager', function () {
           ctx.project._id,
           ctx.user_id,
           {
-            compileBackendClass: 'n2d',
+            compileBackendClass: 'c3d',
             compileGroup: 'standard',
             timeout: ctx.timeout,
           }
@@ -294,7 +294,7 @@ describe('ClsiManager', function () {
               url.host === CLSI_HOST &&
               url.pathname ===
                 `/project/${ctx.project._id}/user/${ctx.user_id}/compile` &&
-              url.searchParams.get('compileBackendClass') === 'n2d' &&
+              url.searchParams.get('compileBackendClass') === 'c3d' &&
               url.searchParams.get('compileGroup') === 'standard'
           ),
           {
@@ -374,7 +374,7 @@ describe('ClsiManager', function () {
           ctx.project._id,
           ctx.user_id,
           'standard',
-          'n2d',
+          'c3d',
           ctx.newClsiServerId
         )
       })
@@ -417,7 +417,7 @@ describe('ClsiManager', function () {
         ctx.result = await ctx.ClsiManager.promises.sendRequest(
           ctx.project._id,
           ctx.user_id,
-          { compileBackendClass: 'n2d', compileGroup: 'standard' }
+          { compileBackendClass: 'c3d', compileGroup: 'standard' }
         )
       })
 
@@ -452,7 +452,7 @@ describe('ClsiManager', function () {
           {
             timeout: 100,
             incrementalCompilesEnabled: true,
-            compileBackendClass: 'n2d',
+            compileBackendClass: 'c3d',
             compileGroup: 'priority',
             compileFromClsiCache: true,
             populateClsiCache: true,
@@ -499,7 +499,7 @@ describe('ClsiManager', function () {
               url.hostname === CLSI_HOST &&
               url.pathname ===
                 `/project/${ctx.project._id}/user/${ctx.user_id}/compile` &&
-              url.searchParams.get('compileBackendClass') === 'n2d' &&
+              url.searchParams.get('compileBackendClass') === 'c3d' &&
               url.searchParams.get('compileGroup') === 'priority'
           ),
           {
@@ -798,7 +798,7 @@ describe('ClsiManager', function () {
         ctx.result = await ctx.ClsiManager.promises.sendRequest(
           ctx.project._id,
           ctx.user_id,
-          { compileBackendClass: 'n2d' }
+          { compileBackendClass: 'c3d' }
         )
       })
 
@@ -823,7 +823,7 @@ describe('ClsiManager', function () {
       it('should clear the CLSI server id cookie', function (ctx) {
         expect(
           ctx.ClsiCookieManager.promises.clearServerId
-        ).to.have.been.calledWith(ctx.project._id, ctx.user_id, 'n2d')
+        ).to.have.been.calledWith(ctx.project._id, ctx.user_id, 'c3d')
       })
 
       it('should return a success status', function (ctx) {
@@ -930,7 +930,7 @@ describe('ClsiManager', function () {
         ctx.result = await ctx.ClsiManager.promises.sendExternalRequest(
           ctx.submissionId,
           ctx.clsiRequest,
-          { compileBackendClass: 'n2d', compileGroup: 'standard' }
+          { compileBackendClass: 'c3d', compileGroup: 'standard' }
         )
       })
 
@@ -940,7 +940,7 @@ describe('ClsiManager', function () {
             url =>
               url.host === CLSI_HOST &&
               url.pathname === `/project/${ctx.submissionId}/compile` &&
-              url.searchParams.get('compileBackendClass') === 'n2d' &&
+              url.searchParams.get('compileBackendClass') === 'c3d' &&
               url.searchParams.get('compileGroup') === 'standard'
           ),
           {
@@ -1005,7 +1005,7 @@ describe('ClsiManager', function () {
         await ctx.ClsiManager.promises.deleteAuxFiles(
           ctx.project._id,
           ctx.user_id,
-          { compileBackendClass: 'n2d', compileGroup: 'standard' },
+          { compileBackendClass: 'c3d', compileGroup: 'standard' },
           'node-1'
         )
       })
@@ -1017,7 +1017,7 @@ describe('ClsiManager', function () {
               url.host === CLSI_HOST &&
               url.pathname ===
                 `/project/${ctx.project._id}/user/${ctx.user_id}` &&
-              url.searchParams.get('compileBackendClass') === 'n2d' &&
+              url.searchParams.get('compileBackendClass') === 'c3d' &&
               url.searchParams.get('compileGroup') === 'standard' &&
               url.searchParams.get('clsiserverid') === 'node-1'
           ),
@@ -1039,7 +1039,7 @@ describe('ClsiManager', function () {
 
       it('should clear the clsi persistance', function (ctx) {
         ctx.ClsiCookieManager.promises.clearServerId
-          .calledWith(ctx.project._id, ctx.user_id, 'n2d')
+          .calledWith(ctx.project._id, ctx.user_id, 'c3d')
           .should.equal(true)
       })
 
@@ -1107,7 +1107,7 @@ describe('ClsiManager', function () {
           ctx.project._id,
           ctx.user_id,
           false,
-          { compileBackendClass: 'n2d', compileGroup: 'standard' },
+          { compileBackendClass: 'c3d', compileGroup: 'standard' },
           'node-1'
         )
       })
@@ -1117,7 +1117,7 @@ describe('ClsiManager', function () {
           sinon.match(
             url =>
               url.toString() ===
-              `http://clsi.example.com/project/${ctx.project._id}/user/${ctx.user_id}/wordcount?compileBackendClass=n2d&compileGroup=standard&file=main.tex&image=mock-image-name&clsiserverid=node-1`
+              `http://clsi.example.com/project/${ctx.project._id}/user/${ctx.user_id}/wordcount?compileBackendClass=c3d&compileGroup=standard&file=main.tex&image=mock-image-name&clsiserverid=node-1`
           )
         )
       })
@@ -1134,7 +1134,7 @@ describe('ClsiManager', function () {
           ctx.project._id,
           ctx.user_id,
           'other.tex',
-          { compileBackendClass: 'n2d', compileGroup: 'standard' },
+          { compileBackendClass: 'c3d', compileGroup: 'standard' },
           'node-2'
         )
       })
@@ -1146,7 +1146,7 @@ describe('ClsiManager', function () {
               url.host === CLSI_HOST &&
               url.pathname ===
                 `/project/${ctx.project._id}/user/${ctx.user_id}/wordcount` &&
-              url.searchParams.get('compileBackendClass') === 'n2d' &&
+              url.searchParams.get('compileBackendClass') === 'c3d' &&
               url.searchParams.get('compileGroup') === 'standard' &&
               url.searchParams.get('clsiserverid') === 'node-2' &&
               url.searchParams.get('file') === 'other.tex' &&

+ 13 - 13
services/web/test/unit/src/Compile/CompileController.test.mjs

@@ -40,7 +40,7 @@ describe('CompileController', function () {
       apis: {
         clsi: {
           url: 'http://clsi.example.com',
-          submissionBackendClass: 'n2d',
+          submissionBackendClass: 'c3d',
         },
         clsi_priority: {
           url: 'http://clsi-priority.example.com',
@@ -442,7 +442,7 @@ describe('CompileController', function () {
         ctx.ClsiManager.promises.sendExternalRequest.should.have.been.calledWith(
           ctx.submission_id,
           { compileGroup: 'special', timeout: 600 },
-          { compileGroup: 'special', compileBackendClass: 'n2d', timeout: 600 }
+          { compileGroup: 'special', compileBackendClass: 'c3d', timeout: 600 }
         )
       })
     })
@@ -473,7 +473,7 @@ describe('CompileController', function () {
             draft: true,
             check: 'validate',
             compileGroup: 'standard',
-            compileBackendClass: 'n2d',
+            compileBackendClass: 'c3d',
             timeout: 60,
           }
         )
@@ -606,7 +606,7 @@ describe('CompileController', function () {
           'output-file',
           ctx.expected_url,
           {},
-          { compileGroup: 'standard', compileBackendClass: 'n2d' }
+          { compileGroup: 'standard', compileBackendClass: 'c3d' }
         )
       })
     })
@@ -629,7 +629,7 @@ describe('CompileController', function () {
           {},
           {
             compileGroup: 'special',
-            compileBackendClass: 'n2d',
+            compileBackendClass: 'c3d',
           }
         )
       })
@@ -753,7 +753,7 @@ describe('CompileController', function () {
             .stub()
             .resolves({
               compileGroup: 'standard',
-              compileBackendClass: 'n2d',
+              compileBackendClass: 'c3d',
             })
           await ctx.CompileController._proxyToClsi(
             ctx.projectId,
@@ -768,7 +768,7 @@ describe('CompileController', function () {
 
         it('should open a request to the CLSI', function (ctx) {
           ctx.fetchUtils.fetchStreamWithResponse.should.have.been.calledWith(
-            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=n2d&query=foo`
+            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=c3d&query=foo`
           )
         })
 
@@ -810,7 +810,7 @@ describe('CompileController', function () {
             .stub()
             .resolves({
               compileGroup: 'standard',
-              compileBackendClass: 'n2d',
+              compileBackendClass: 'c3d',
             })
           await ctx.CompileController._proxyToClsi(
             ctx.projectId,
@@ -825,7 +825,7 @@ describe('CompileController', function () {
 
         it('should open a request to the CLSI', function (ctx) {
           ctx.fetchUtils.fetchStreamWithResponse.should.have.been.calledWith(
-            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=n2d`
+            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=c3d`
           )
         })
 
@@ -841,7 +841,7 @@ describe('CompileController', function () {
             .stub()
             .resolves({
               compileGroup: 'standard',
-              compileBackendClass: 'n2d',
+              compileBackendClass: 'c3d',
             })
           await ctx.CompileController._proxyToClsi(
             ctx.projectId,
@@ -856,7 +856,7 @@ describe('CompileController', function () {
 
         it('should proxy to the standard url', function (ctx) {
           ctx.fetchUtils.fetchStreamWithResponse.should.have.been.calledWith(
-            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=n2d`
+            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=c3d`
           )
         })
       })
@@ -867,7 +867,7 @@ describe('CompileController', function () {
             .stub()
             .resolves({
               compileGroup: 'standard',
-              compileBackendClass: 'n2d',
+              compileBackendClass: 'c3d',
             })
           ctx.req.query = { build: 1234 }
           await ctx.CompileController._proxyToClsi(
@@ -883,7 +883,7 @@ describe('CompileController', function () {
 
         it('should proxy to the standard url without the build parameter', function (ctx) {
           ctx.fetchUtils.fetchStreamWithResponse.should.have.been.calledWith(
-            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=n2d`
+            `${ctx.settings.apis.clsi.url}${ctx.url}?compileGroup=standard&compileBackendClass=c3d`
           )
         })
       })

+ 1 - 1
services/web/test/unit/src/Compile/CompileManager.test.mjs

@@ -19,7 +19,7 @@ describe('CompileManager', function () {
     vi.doMock('@overleaf/settings', () => ({
       default: (ctx.settings = {
         apis: {
-          clsi: { submissionBackendClass: 'n2d' },
+          clsi: { submissionBackendClass: 'c3d' },
         },
         redis: { web: { host: '127.0.0.1', port: 42 } },
         rateLimit: { autoCompile: {} },