Эх сурвалжийг харах

Merge pull request #13454 from overleaf/jpa-n2d-split-test

[web] add split test for running standard compiles on n2d instances

GitOrigin-RevId: 05b85870c2ff5eb0345e700101225535a4a569f1
Eric Mc Sween 3 жил өмнө
parent
commit
f038cd4d10

+ 13 - 4
services/web/app/src/Features/Compile/CompileManager.js

@@ -246,10 +246,19 @@ module.exports = CompileManager = {
   _getCompileBackendClassDetails(owner, compileGroup, callback) {
   _getCompileBackendClassDetails(owner, compileGroup, callback) {
     const { defaultBackendClass } = Settings.apis.clsi
     const { defaultBackendClass } = Settings.apis.clsi
     if (compileGroup === 'standard') {
     if (compileGroup === 'standard') {
-      return callback(null, {
-        compileBackendClass: defaultBackendClass,
-        showFasterCompilesFeedbackUI: false,
-      })
+      return SplitTestHandler.getAssignmentForMongoUser(
+        owner,
+        'compile-backend-class-n2d',
+        (err, assignment) => {
+          if (err) return callback(err, {})
+          const { variant } = assignment
+          callback(null, {
+            compileBackendClass:
+              variant === 'default' ? defaultBackendClass : variant,
+            showFasterCompilesFeedbackUI: false,
+          })
+        }
+      )
     }
     }
     SplitTestHandler.getAssignmentForMongoUser(
     SplitTestHandler.getAssignmentForMongoUser(
       owner,
       owner,

+ 37 - 10
services/web/test/unit/src/Compile/CompileManagerTests.js

@@ -250,16 +250,43 @@ describe('CompileManager', function () {
       beforeEach(function () {
       beforeEach(function () {
         this.features.compileGroup = 'standard'
         this.features.compileGroup = 'standard'
       })
       })
-      it('should return the default class and disable ui', function (done) {
-        this.CompileManager.getProjectCompileLimits(
-          this.project_id,
-          (err, { compileBackendClass, showFasterCompilesFeedbackUI }) => {
-            if (err) return done(err)
-            expect(compileBackendClass).to.equal('e2')
-            expect(showFasterCompilesFeedbackUI).to.equal(false)
-            done()
-          }
-        )
+
+      describe('default', function () {
+        beforeEach(function () {
+          this.getAssignmentForMongoUser.yields(null, {
+            variant: 'default',
+          })
+        })
+        it('should return the e2 class and disable the ui', function (done) {
+          this.CompileManager.getProjectCompileLimits(
+            this.project_id,
+            (err, { compileBackendClass, showFasterCompilesFeedbackUI }) => {
+              if (err) return done(err)
+              expect(compileBackendClass).to.equal('e2')
+              expect(showFasterCompilesFeedbackUI).to.equal(false)
+              done()
+            }
+          )
+        })
+      })
+
+      describe('n2d variant', function () {
+        beforeEach(function () {
+          this.getAssignmentForMongoUser.yields(null, {
+            variant: 'n2d',
+          })
+        })
+        it('should return the n2d class and disable the ui', function (done) {
+          this.CompileManager.getProjectCompileLimits(
+            this.project_id,
+            (err, { compileBackendClass, showFasterCompilesFeedbackUI }) => {
+              if (err) return done(err)
+              expect(compileBackendClass).to.equal('n2d')
+              expect(showFasterCompilesFeedbackUI).to.equal(false)
+              done()
+            }
+          )
+        })
       })
       })
     })
     })