From f038cd4d10ff816e248c15f156230c75484080ea Mon Sep 17 00:00:00 2001 From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com> Date: Wed, 14 Jun 2023 07:10:23 -0400 Subject: [PATCH] Merge pull request #13454 from overleaf/jpa-n2d-split-test [web] add split test for running standard compiles on n2d instances GitOrigin-RevId: 05b85870c2ff5eb0345e700101225535a4a569f1 --- .../src/Features/Compile/CompileManager.js | 17 +++++-- .../unit/src/Compile/CompileManagerTests.js | 47 +++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/services/web/app/src/Features/Compile/CompileManager.js b/services/web/app/src/Features/Compile/CompileManager.js index 7b569d0a32..07a59a0166 100644 --- a/services/web/app/src/Features/Compile/CompileManager.js +++ b/services/web/app/src/Features/Compile/CompileManager.js @@ -246,10 +246,19 @@ module.exports = CompileManager = { _getCompileBackendClassDetails(owner, compileGroup, callback) { const { defaultBackendClass } = Settings.apis.clsi 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( owner, diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js index 52c7d6e017..cf9b05163f 100644 --- a/services/web/test/unit/src/Compile/CompileManagerTests.js +++ b/services/web/test/unit/src/Compile/CompileManagerTests.js @@ -250,16 +250,43 @@ describe('CompileManager', function () { beforeEach(function () { 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() + } + ) + }) }) })