diff --git a/services/web/app/src/Features/Compile/CompileManager.js b/services/web/app/src/Features/Compile/CompileManager.js index 63badf4dc7..8798859831 100644 --- a/services/web/app/src/Features/Compile/CompileManager.js +++ b/services/web/app/src/Features/Compile/CompileManager.js @@ -147,8 +147,6 @@ module.exports = CompileManager = { analyticsId: 1, betaProgram: 1, features: 1, - splitTests: 1, - signUpDate: 1, // for compile-timeout-20s }, function (err, owner) { if (err) { @@ -168,16 +166,10 @@ module.exports = CompileManager = { const compileGroup = ownerFeatures.compileGroup || Settings.defaultFeatures.compileGroup - const compileTimeout = - ownerFeatures.compileTimeout || - Settings.defaultFeatures.compileTimeout - const limits = { timeout: - // temporary override until users' compileTimeout is migrated - compileGroup === 'standard' && compileTimeout <= 60 - ? 20 - : compileTimeout, + ownerFeatures.compileTimeout || + Settings.defaultFeatures.compileTimeout, compileGroup, compileBackendClass: compileGroup === 'standard' ? 'n2d' : 'c2d', diff --git a/services/web/scripts/migration_compile_timeout_60s_to_20s.js b/services/web/scripts/migration_compile_timeout_60s_to_20s.js index 5f18f248fa..1df2834b16 100644 --- a/services/web/scripts/migration_compile_timeout_60s_to_20s.js +++ b/services/web/scripts/migration_compile_timeout_60s_to_20s.js @@ -13,20 +13,22 @@ async function logCount() { { 'features.compileTimeout': { $lte: 60, $ne: 20 } }, { readPreference: READ_PREFERENCE_SECONDARY } ) + console.log(`Found ${count60s} users with compileTimeout <= 60s && != 20s`) const count20s = await db.users.countDocuments( { 'features.compileTimeout': 20 }, { readPreference: READ_PREFERENCE_SECONDARY } ) - console.log(`Found ${count60s} users with compileTimeout <= 60s && != 20s`) console.log(`Found ${count20s} users with compileTimeout == 20s`) } -const main = async ({ COMMIT }) => { +const main = async ({ COMMIT, SKIP_COUNT }) => { console.time('Script Duration') await waitForDb() - await logCount() + if (!SKIP_COUNT) { + await logCount() + } if (COMMIT) { const nModified = await batchedUpdate( @@ -43,10 +45,11 @@ const main = async ({ COMMIT }) => { const setup = () => { const argv = minimist(process.argv.slice(2)) const COMMIT = argv.commit !== undefined + const SKIP_COUNT = argv['skip-count'] !== undefined if (!COMMIT) { console.warn('Doing dry run. Add --commit to commit changes') } - return { COMMIT } + return { COMMIT, SKIP_COUNT } } main(setup()) diff --git a/services/web/test/unit/src/Compile/CompileManagerTests.js b/services/web/test/unit/src/Compile/CompileManagerTests.js index e9501c647a..8cfca421d7 100644 --- a/services/web/test/unit/src/Compile/CompileManagerTests.js +++ b/services/web/test/unit/src/Compile/CompileManagerTests.js @@ -42,13 +42,6 @@ describe('CompileManager', function () { get: sinon.stub().yields(null, 'abc'), }, }), - '../SplitTests/SplitTestHandler': { - getAssignmentForMongoUser: (this.getAssignmentForMongoUser = sinon - .stub() - .yields(null, { - variant: 'default', - })), - }, }, }) this.project_id = 'mock-project-id-123' @@ -224,8 +217,6 @@ describe('CompileManager', function () { analyticsId: 1, betaProgram: 1, features: 1, - splitTests: 1, - signUpDate: 1, }) .should.equal(true) }) @@ -242,171 +233,6 @@ describe('CompileManager', function () { }) }) - describe('getProjectCompileLimits with reduced compile timeout', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.callsFake((user, test, cb) => { - if (test === 'compile-backend-class-n2d') { - cb(null, { variant: 'n2d' }) - } - if (test === 'compile-timeout-20s') { - cb(null, { variant: '20s' }) - } - }) - this.features = { - compileTimeout: (this.timeout = 60), - compileGroup: (this.group = 'standard'), - } - this.ProjectGetter.getProject = sinon - .stub() - .callsArgWith( - 2, - null, - (this.project = { owner_ref: (this.owner_id = 'owner-id-123') }) - ) - this.UserGetter.getUser = sinon - .stub() - .callsArgWith( - 2, - null, - (this.user = { features: this.features, analyticsId: 'abc' }) - ) - }) - - describe('user is in the n2d group and compile-timeout-20s split test variant', function () { - describe('user has a timeout of more than 60s', function () { - beforeEach(function () { - this.features.compileTimeout = 120 - }) - it('should keep the users compile timeout', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 120 })) - .should.equal(true) - }) - }) - describe('user registered before the cut off date', function () { - beforeEach(function () { - this.features.compileTimeout = 60 - const signUpDate = new Date( - this.CompileManager.NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF - ) - signUpDate.setDate(signUpDate.getDate() - 1) - this.user.signUpDate = signUpDate - }) - it('should keep the users compile timeout', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 20 })) - .should.equal(true) - }) - describe('user is in the compile-timeout-20s-existing-users treatment', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.callsFake((user, test, cb) => { - if (test === 'compile-backend-class-n2d') { - cb(null, { variant: 'n2d' }) - } - if (test === 'compile-timeout-20s') { - cb(null, { variant: '20s' }) - } - if (test === 'compile-timeout-20s-existing-users') { - cb(null, { variant: '20s' }) - } - }) - }) - - it('should reduce compile timeout to 20s', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 20 })) - .should.equal(true) - }) - }) - }) - describe('user registered after the cut off date', function () { - beforeEach(function () { - this.timeout = 60 - const signUpDate = new Date( - this.CompileManager.NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF - ) - signUpDate.setDate(signUpDate.getDate() + 1) - this.user.signUpDate = signUpDate - }) - it('should reduce compile timeout to 20s', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 20 })) - .should.equal(true) - }) - }) - - describe('user was in the default n2d variant at the baseline test version', function () { - beforeEach(function () { - this.UserGetter.getUser = sinon.stub().callsArgWith( - 2, - null, - (this.user = { - features: this.features, - analyticsId: 'abc', - splitTests: { - 'compile-backend-class-n2d': [ - { - variantName: 'default', - versionNumber: 8, - phase: 'release', - }, - ], - }, - }) - ) - }) - - describe('user signed up after the original rollout but before the second phase rollout', function () { - beforeEach(function () { - const signUpDate = new Date( - this.CompileManager.NEW_COMPILE_TIMEOUT_ENFORCED_CUTOFF - ) - signUpDate.setDate(signUpDate.getDate() + 1) - this.user.signUpDate = signUpDate - }) - - it('should keep the users compile timeout', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 20 })) - .should.equal(true) - }) - }) - - describe('user signed up after the second phase rollout', function () { - it('should reduce compile timeout to 20s', function () { - this.CompileManager.getProjectCompileLimits( - this.project_id, - this.callback - ) - this.callback - .calledWith(null, sinon.match({ timeout: 20 })) - .should.equal(true) - }) - }) - }) - }) - }) - describe('compileBackendClass', function () { beforeEach(function () { this.features = { @@ -421,110 +247,19 @@ describe('CompileManager', function () { .yields(null, { features: this.features, analyticsId: 'abc' }) }) - describe('with standard compile', function () { - beforeEach(function () { - this.features.compileGroup = 'standard' - }) - - describe('default', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.yields(null, { - variant: 'default', - }) - }) - it('should return the n2d class and disable the ui', function (done) { - this.CompileManager.getProjectCompileLimits( - this.project_id, - (err, { compileBackendClass }) => { - if (err) return done(err) - expect(compileBackendClass).to.equal('n2d') - 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 }) => { - if (err) return done(err) - expect(compileBackendClass).to.equal('n2d') - done() - } - ) - }) - }) - }) - describe('with priority compile', function () { beforeEach(function () { this.features.compileGroup = 'priority' }) - describe('split test not active', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.yields(null, { - analytics: { segmentation: {} }, - variant: 'default', - }) - }) - - it('should return the default class and disable ui', function (done) { - this.CompileManager.getProjectCompileLimits( - this.project_id, - (err, { compileBackendClass }) => { - if (err) return done(err) - expect(compileBackendClass).to.equal('c2d') - done() - } - ) - }) - }) - - describe('split test active', function () { - describe('default variant', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.yields(null, { - analytics: { segmentation: { splitTest: 'foo' } }, - variant: 'default', - }) - }) - it('should return the default class and enable ui', function (done) { - this.CompileManager.getProjectCompileLimits( - this.project_id, - (err, { compileBackendClass }) => { - if (err) return done(err) - expect(compileBackendClass).to.equal('c2d') - done() - } - ) - }) - }) - - describe('c2d variant', function () { - beforeEach(function () { - this.getAssignmentForMongoUser.yields(null, { - analytics: { segmentation: { splitTest: 'foo' } }, - variant: 'c2d', - }) - }) - it('should return the c2d class and enable ui', function (done) { - this.CompileManager.getProjectCompileLimits( - this.project_id, - (err, { compileBackendClass }) => { - if (err) return done(err) - expect(compileBackendClass).to.equal('c2d') - done() - } - ) - }) - }) + it('should return the default class', function (done) { + this.CompileManager.getProjectCompileLimits( + this.project_id, + (err, { compileBackendClass }) => { + if (err) return done(err) + expect(compileBackendClass).to.equal('c2d') + done() + } + ) }) }) })