Merge pull request #17925 from overleaf/jpa-ac-20s-timeout-migration-logging-tweaks

[web] timeout 20s split-test teardown cleanups (remove override, remove tests, ...)

GitOrigin-RevId: 8d8c44539cf45d0f5142f84cf8372cecda3bf77a
This commit is contained in:
Antoine Clausse
2024-04-16 13:10:44 +02:00
committed by Copybot
parent 238e63e08c
commit 616bd0df16
3 changed files with 18 additions and 288 deletions

View File

@@ -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',

View File

@@ -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())

View File

@@ -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()
}
)
})
})
})