mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-30 19:21:01 +00:00
Merge pull request #8070 from overleaf/jpa-web-zonal-traffic-test
[web] add split test for rollout of zonal clsi-lb downloads GitOrigin-RevId: 67fb843ffb0c5902419a4e5c7d2ff9d35cf93470
This commit is contained in:
parent
fc9bfa84cd
commit
716aa174fb
2 changed files with 89 additions and 18 deletions
|
@ -27,6 +27,7 @@ const ClsiCookieManager = require('./ClsiCookieManager')(
|
|||
Settings.apis.clsi != null ? Settings.apis.clsi.backendGroupName : undefined
|
||||
)
|
||||
const Path = require('path')
|
||||
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
|
||||
|
||||
const COMPILE_TIMEOUT_MS = 10 * 60 * 1000
|
||||
|
||||
|
@ -93,16 +94,29 @@ module.exports = CompileController = {
|
|||
return next(error)
|
||||
}
|
||||
Metrics.inc('compile-status', 1, { status })
|
||||
res.json({
|
||||
status,
|
||||
outputFiles,
|
||||
compileGroup: limits != null ? limits.compileGroup : undefined,
|
||||
clsiServerId,
|
||||
validationProblems,
|
||||
stats,
|
||||
timings,
|
||||
pdfDownloadDomain: Settings.pdfDownloadDomain,
|
||||
})
|
||||
SplitTestHandler.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'zonal-clsi-lb-downloads',
|
||||
{},
|
||||
(_err, assignment) => {
|
||||
if (assignment?.variant !== 'zonal') {
|
||||
outputFiles.forEach(file => {
|
||||
file.url = file.url.replace(/^\/zone\/\w/, '')
|
||||
})
|
||||
}
|
||||
res.json({
|
||||
status,
|
||||
outputFiles,
|
||||
compileGroup: limits != null ? limits.compileGroup : undefined,
|
||||
clsiServerId,
|
||||
validationProblems,
|
||||
stats,
|
||||
timings,
|
||||
pdfDownloadDomain: Settings.pdfDownloadDomain,
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
|
|
|
@ -69,6 +69,11 @@ describe('CompileController', function () {
|
|||
'../Authentication/SessionManager': this.SessionManager,
|
||||
'../../infrastructure/RateLimiter': this.RateLimiter,
|
||||
'./ClsiCookieManager': () => this.ClsiCookieManager,
|
||||
'../SplitTests/SplitTestHandler': {
|
||||
getAssignment: (this.getAssignment = sinon.stub().yields(null, {
|
||||
variant: 'default',
|
||||
})),
|
||||
},
|
||||
},
|
||||
})
|
||||
this.project_id = 'project-id'
|
||||
|
@ -81,14 +86,66 @@ describe('CompileController', function () {
|
|||
beforeEach(function () {
|
||||
this.req.params = { Project_id: this.project_id }
|
||||
this.req.session = {}
|
||||
return (this.CompileManager.compile = sinon
|
||||
.stub()
|
||||
.callsArgWith(
|
||||
3,
|
||||
null,
|
||||
(this.status = 'success'),
|
||||
(this.outputFiles = ['mock-output-files'])
|
||||
))
|
||||
return (this.CompileManager.compile = sinon.stub().callsArgWith(
|
||||
3,
|
||||
null,
|
||||
(this.status = 'success'),
|
||||
(this.outputFiles = [
|
||||
{
|
||||
path: 'output.pdf',
|
||||
url: `/zone/b/project/${this.project_id}/user/${this.user_id}/build/id/output.pdf`,
|
||||
type: 'pdf',
|
||||
},
|
||||
])
|
||||
))
|
||||
})
|
||||
|
||||
describe('zonal downloads', function () {
|
||||
describe('when in the default split test variant', function () {
|
||||
beforeEach(function () {
|
||||
this.getAssignment.yields(null, { variant: 'default' })
|
||||
this.CompileController.compile(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should remove the zone prefix', function () {
|
||||
this.res.statusCode.should.equal(200)
|
||||
this.res.body.should.equal(
|
||||
JSON.stringify({
|
||||
status: this.status,
|
||||
outputFiles: [
|
||||
{
|
||||
path: 'output.pdf',
|
||||
url: `/project/${this.project_id}/user/${this.user_id}/build/id/output.pdf`,
|
||||
type: 'pdf',
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when in the zonal split test variant', function () {
|
||||
beforeEach(function () {
|
||||
this.getAssignment.yields(null, { variant: 'zonal' })
|
||||
this.CompileController.compile(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should keep the zone prefix', function () {
|
||||
this.res.statusCode.should.equal(200)
|
||||
this.res.body.should.equal(
|
||||
JSON.stringify({
|
||||
status: this.status,
|
||||
outputFiles: [
|
||||
{
|
||||
path: 'output.pdf',
|
||||
url: `/zone/b/project/${this.project_id}/user/${this.user_id}/build/id/output.pdf`,
|
||||
type: 'pdf',
|
||||
},
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when not an auto compile', function () {
|
||||
|
|
Loading…
Reference in a new issue