|
@@ -59,7 +59,21 @@ describe('ClsiManager', function () {
|
|
|
this.newClsiServerId = 'newserver'
|
|
this.newClsiServerId = 'newserver'
|
|
|
this.rawOutputFiles = {}
|
|
this.rawOutputFiles = {}
|
|
|
this.responseBody = {
|
|
this.responseBody = {
|
|
|
- compile: { status: 'success' },
|
|
|
|
|
|
|
+ compile: {
|
|
|
|
|
+ status: 'success',
|
|
|
|
|
+ stats: {
|
|
|
|
|
+ isInitialCompile: 1,
|
|
|
|
|
+ restoredClsiCache: 1,
|
|
|
|
|
+ },
|
|
|
|
|
+ timings: { compileE2E: 1337 },
|
|
|
|
|
+ outputFiles: [
|
|
|
|
|
+ {
|
|
|
|
|
+ path: 'output.pdf',
|
|
|
|
|
+ size: 42,
|
|
|
|
|
+ url: 'http://localhost:3013/snip/output.pdf',
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
this.response = {
|
|
this.response = {
|
|
|
ok: true,
|
|
ok: true,
|
|
@@ -128,6 +142,7 @@ describe('ClsiManager', function () {
|
|
|
},
|
|
},
|
|
|
inc: sinon.stub(),
|
|
inc: sinon.stub(),
|
|
|
count: sinon.stub(),
|
|
count: sinon.stub(),
|
|
|
|
|
+ histogram: sinon.stub(),
|
|
|
}
|
|
}
|
|
|
this.Settings = {
|
|
this.Settings = {
|
|
|
apis: {
|
|
apis: {
|
|
@@ -139,8 +154,8 @@ describe('ClsiManager', function () {
|
|
|
url: `http://${CLSI_HOST}`,
|
|
url: `http://${CLSI_HOST}`,
|
|
|
submissionBackendClass: 'n2d',
|
|
submissionBackendClass: 'n2d',
|
|
|
},
|
|
},
|
|
|
- clsi_priority: {
|
|
|
|
|
- url: 'https://clsipremium.example.com',
|
|
|
|
|
|
|
+ clsi_new: {
|
|
|
|
|
+ sample: 100,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
enablePdfCaching: true,
|
|
enablePdfCaching: true,
|
|
@@ -157,10 +172,17 @@ describe('ClsiManager', function () {
|
|
|
return `${FILESTORE_URL}/history/project/${historyId}/hash/${hash}`
|
|
return `${FILESTORE_URL}/history/project/${historyId}/hash/${hash}`
|
|
|
}),
|
|
}),
|
|
|
}
|
|
}
|
|
|
|
|
+ this.SplitTestHandler = {
|
|
|
|
|
+ getPercentile: sinon.stub().returns(42),
|
|
|
|
|
+ }
|
|
|
|
|
+ this.AnalyticsManager = {
|
|
|
|
|
+ recordEventForUserInBackground: sinon.stub(),
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
this.ClsiManager = SandboxedModule.require(MODULE_PATH, {
|
|
this.ClsiManager = SandboxedModule.require(MODULE_PATH, {
|
|
|
requires: {
|
|
requires: {
|
|
|
'@overleaf/settings': this.Settings,
|
|
'@overleaf/settings': this.Settings,
|
|
|
|
|
+ '../SplitTests/SplitTestHandler': this.SplitTestHandler,
|
|
|
'../../models/Project': {
|
|
'../../models/Project': {
|
|
|
Project: this.Project,
|
|
Project: this.Project,
|
|
|
},
|
|
},
|
|
@@ -175,6 +197,7 @@ describe('ClsiManager', function () {
|
|
|
'./ClsiFormatChecker': this.ClsiFormatChecker,
|
|
'./ClsiFormatChecker': this.ClsiFormatChecker,
|
|
|
'@overleaf/metrics': this.Metrics,
|
|
'@overleaf/metrics': this.Metrics,
|
|
|
'../History/HistoryManager': this.HistoryManager,
|
|
'../History/HistoryManager': this.HistoryManager,
|
|
|
|
|
+ '../Analytics/AnalyticsManager': this.AnalyticsManager,
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -214,7 +237,7 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
{
|
|
{
|
|
|
- compileBackendClass: 'e2',
|
|
|
|
|
|
|
+ compileBackendClass: 'n2d',
|
|
|
compileGroup: 'standard',
|
|
compileGroup: 'standard',
|
|
|
timeout: this.timeout,
|
|
timeout: this.timeout,
|
|
|
}
|
|
}
|
|
@@ -228,7 +251,7 @@ describe('ClsiManager', function () {
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
url.searchParams.get('compileGroup') === 'standard'
|
|
url.searchParams.get('compileGroup') === 'standard'
|
|
|
),
|
|
),
|
|
|
{
|
|
{
|
|
@@ -308,7 +331,7 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
'standard',
|
|
'standard',
|
|
|
- 'e2',
|
|
|
|
|
|
|
+ 'n2d',
|
|
|
this.newClsiServerId
|
|
this.newClsiServerId
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -351,7 +374,7 @@ describe('ClsiManager', function () {
|
|
|
this.result = await this.ClsiManager.promises.sendRequest(
|
|
this.result = await this.ClsiManager.promises.sendRequest(
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
- { compileBackendClass: 'e2', compileGroup: 'standard' }
|
|
|
|
|
|
|
+ { compileBackendClass: 'n2d', compileGroup: 'standard' }
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -386,7 +409,7 @@ describe('ClsiManager', function () {
|
|
|
{
|
|
{
|
|
|
timeout: 100,
|
|
timeout: 100,
|
|
|
incrementalCompilesEnabled: true,
|
|
incrementalCompilesEnabled: true,
|
|
|
- compileBackendClass: 'e2',
|
|
|
|
|
|
|
+ compileBackendClass: 'n2d',
|
|
|
compileGroup: 'priority',
|
|
compileGroup: 'priority',
|
|
|
compileFromClsiCache: true,
|
|
compileFromClsiCache: true,
|
|
|
populateClsiCache: true,
|
|
populateClsiCache: true,
|
|
@@ -433,7 +456,7 @@ describe('ClsiManager', function () {
|
|
|
url.hostname === CLSI_HOST &&
|
|
url.hostname === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
url.searchParams.get('compileGroup') === 'priority'
|
|
url.searchParams.get('compileGroup') === 'priority'
|
|
|
),
|
|
),
|
|
|
{
|
|
{
|
|
@@ -790,8 +813,8 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
{
|
|
{
|
|
|
- compileBackendClass: 'e2',
|
|
|
|
|
- compileGroup: 'standard',
|
|
|
|
|
|
|
+ compileBackendClass: 'c2d',
|
|
|
|
|
+ compileGroup: 'priority',
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
// wait for the background task to finish
|
|
// wait for the background task to finish
|
|
@@ -806,18 +829,34 @@ describe('ClsiManager', function () {
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
`/project/${this.project._id}/user/${this.user_id}/compile` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
- url.searchParams.get('compileGroup') === 'standard'
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'c2d' &&
|
|
|
|
|
+ url.searchParams.get('compileGroup') === 'priority'
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
expect(this.FetchUtils.fetchStringWithResponse).to.have.been.calledWith(
|
|
expect(this.FetchUtils.fetchStringWithResponse).to.have.been.calledWith(
|
|
|
sinon.match(
|
|
sinon.match(
|
|
|
url =>
|
|
url =>
|
|
|
url.toString() ===
|
|
url.toString() ===
|
|
|
- `${this.Settings.apis.clsi_new.url}/project/${this.project._id}/user/${this.user_id}/compile?compileBackendClass=e2&compileGroup=standard`
|
|
|
|
|
|
|
+ `${this.Settings.apis.clsi_new.url}/project/${this.project._id}/user/${this.user_id}/compile?compileBackendClass=c4d&compileGroup=priority`
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
+ it('should record an event', function () {
|
|
|
|
|
+ expect(
|
|
|
|
|
+ this.AnalyticsManager.recordEventForUserInBackground
|
|
|
|
|
+ ).to.have.been.calledWith(this.user_id, 'double-compile-result', {
|
|
|
|
|
+ projectId: 'project-id',
|
|
|
|
|
+ compileBackendClass: 'c2d',
|
|
|
|
|
+ newCompileBackendClass: 'c4d',
|
|
|
|
|
+ status: 'success',
|
|
|
|
|
+ compileTime: 1337,
|
|
|
|
|
+ newCompileTime: 1337,
|
|
|
|
|
+ clsiServerId: 'newserver',
|
|
|
|
|
+ newClsiServerId: 'clsi-server-id',
|
|
|
|
|
+ pdfSize: 42,
|
|
|
|
|
+ newPdfSize: 42,
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -852,7 +891,7 @@ describe('ClsiManager', function () {
|
|
|
this.result = await this.ClsiManager.promises.sendExternalRequest(
|
|
this.result = await this.ClsiManager.promises.sendExternalRequest(
|
|
|
this.submissionId,
|
|
this.submissionId,
|
|
|
this.clsiRequest,
|
|
this.clsiRequest,
|
|
|
- { compileBackendClass: 'e2', compileGroup: 'standard' }
|
|
|
|
|
|
|
+ { compileBackendClass: 'n2d', compileGroup: 'standard' }
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -862,7 +901,7 @@ describe('ClsiManager', function () {
|
|
|
url =>
|
|
url =>
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname === `/project/${this.submissionId}/compile` &&
|
|
url.pathname === `/project/${this.submissionId}/compile` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
url.searchParams.get('compileGroup') === 'standard'
|
|
url.searchParams.get('compileGroup') === 'standard'
|
|
|
),
|
|
),
|
|
|
{
|
|
{
|
|
@@ -927,7 +966,7 @@ describe('ClsiManager', function () {
|
|
|
await this.ClsiManager.promises.deleteAuxFiles(
|
|
await this.ClsiManager.promises.deleteAuxFiles(
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
- { compileBackendClass: 'e2', compileGroup: 'standard' },
|
|
|
|
|
|
|
+ { compileBackendClass: 'n2d', compileGroup: 'standard' },
|
|
|
'node-1'
|
|
'node-1'
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -939,7 +978,7 @@ describe('ClsiManager', function () {
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
url.searchParams.get('compileGroup') === 'standard' &&
|
|
url.searchParams.get('compileGroup') === 'standard' &&
|
|
|
url.searchParams.get('clsiserverid') === 'node-1'
|
|
url.searchParams.get('clsiserverid') === 'node-1'
|
|
|
),
|
|
),
|
|
@@ -977,7 +1016,7 @@ describe('ClsiManager', function () {
|
|
|
await this.ClsiManager.promises.deleteAuxFiles(
|
|
await this.ClsiManager.promises.deleteAuxFiles(
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
- { compileBackendClass: 'n2d', compileGroup: 'standard' },
|
|
|
|
|
|
|
+ { compileBackendClass: 'c2d', compileGroup: 'priority' },
|
|
|
'node-1'
|
|
'node-1'
|
|
|
)
|
|
)
|
|
|
// wait for the background task to finish
|
|
// wait for the background task to finish
|
|
@@ -991,8 +1030,8 @@ describe('ClsiManager', function () {
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
|
|
- url.searchParams.get('compileGroup') === 'standard' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'c2d' &&
|
|
|
|
|
+ url.searchParams.get('compileGroup') === 'priority' &&
|
|
|
url.searchParams.get('clsiserverid') === 'node-1'
|
|
url.searchParams.get('clsiserverid') === 'node-1'
|
|
|
),
|
|
),
|
|
|
{ method: 'DELETE' }
|
|
{ method: 'DELETE' }
|
|
@@ -1003,8 +1042,8 @@ describe('ClsiManager', function () {
|
|
|
url.host === 'compiles.somewhere.test' &&
|
|
url.host === 'compiles.somewhere.test' &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
`/project/${this.project._id}/user/${this.user_id}` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
|
|
- url.searchParams.get('compileGroup') === 'standard' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'c4d' &&
|
|
|
|
|
+ url.searchParams.get('compileGroup') === 'priority' &&
|
|
|
!url.searchParams.has('clsiserverid')
|
|
!url.searchParams.has('clsiserverid')
|
|
|
),
|
|
),
|
|
|
sinon.match({ method: 'DELETE' })
|
|
sinon.match({ method: 'DELETE' })
|
|
@@ -1020,7 +1059,7 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
false,
|
|
false,
|
|
|
- { compileBackendClass: 'e2', compileGroup: 'standard' },
|
|
|
|
|
|
|
+ { compileBackendClass: 'n2d', compileGroup: 'standard' },
|
|
|
'node-1'
|
|
'node-1'
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -1030,7 +1069,7 @@ describe('ClsiManager', function () {
|
|
|
sinon.match(
|
|
sinon.match(
|
|
|
url =>
|
|
url =>
|
|
|
url.toString() ===
|
|
url.toString() ===
|
|
|
- `http://clsi.example.com/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=e2&compileGroup=standard&file=main.tex&image=mock-image-name&clsiserverid=node-1`
|
|
|
|
|
|
|
+ `http://clsi.example.com/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=n2d&compileGroup=standard&file=main.tex&image=mock-image-name&clsiserverid=node-1`
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -1047,7 +1086,7 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
'other.tex',
|
|
'other.tex',
|
|
|
- { compileBackendClass: 'e2', compileGroup: 'standard' },
|
|
|
|
|
|
|
+ { compileBackendClass: 'n2d', compileGroup: 'standard' },
|
|
|
'node-2'
|
|
'node-2'
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
@@ -1059,7 +1098,7 @@ describe('ClsiManager', function () {
|
|
|
url.host === CLSI_HOST &&
|
|
url.host === CLSI_HOST &&
|
|
|
url.pathname ===
|
|
url.pathname ===
|
|
|
`/project/${this.project._id}/user/${this.user_id}/wordcount` &&
|
|
`/project/${this.project._id}/user/${this.user_id}/wordcount` &&
|
|
|
- url.searchParams.get('compileBackendClass') === 'e2' &&
|
|
|
|
|
|
|
+ url.searchParams.get('compileBackendClass') === 'n2d' &&
|
|
|
url.searchParams.get('compileGroup') === 'standard' &&
|
|
url.searchParams.get('compileGroup') === 'standard' &&
|
|
|
url.searchParams.get('clsiserverid') === 'node-2' &&
|
|
url.searchParams.get('clsiserverid') === 'node-2' &&
|
|
|
url.searchParams.get('file') === 'other.tex' &&
|
|
url.searchParams.get('file') === 'other.tex' &&
|
|
@@ -1081,7 +1120,7 @@ describe('ClsiManager', function () {
|
|
|
this.project._id,
|
|
this.project._id,
|
|
|
this.user_id,
|
|
this.user_id,
|
|
|
false,
|
|
false,
|
|
|
- { compileBackendClass: 'n2d', compileGroup: 'standard' },
|
|
|
|
|
|
|
+ { compileBackendClass: 'c2d', compileGroup: 'priority' },
|
|
|
'node-1'
|
|
'node-1'
|
|
|
)
|
|
)
|
|
|
// wait for the background task to finish
|
|
// wait for the background task to finish
|
|
@@ -1093,14 +1132,14 @@ describe('ClsiManager', function () {
|
|
|
sinon.match(
|
|
sinon.match(
|
|
|
url =>
|
|
url =>
|
|
|
url.toString() ===
|
|
url.toString() ===
|
|
|
- `http://clsi.example.com/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=n2d&compileGroup=standard&file=main.tex&image=mock-image-name&clsiserverid=node-1`
|
|
|
|
|
|
|
+ `http://clsi.example.com/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=c2d&compileGroup=priority&file=main.tex&image=mock-image-name&clsiserverid=node-1`
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
expect(this.FetchUtils.fetchStringWithResponse).to.have.been.calledWith(
|
|
expect(this.FetchUtils.fetchStringWithResponse).to.have.been.calledWith(
|
|
|
sinon.match(
|
|
sinon.match(
|
|
|
url =>
|
|
url =>
|
|
|
url.toString() ===
|
|
url.toString() ===
|
|
|
- `${this.Settings.apis.clsi_new.url}/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=n2d&compileGroup=standard&file=main.tex&image=mock-image-name`
|
|
|
|
|
|
|
+ `${this.Settings.apis.clsi_new.url}/project/${this.project._id}/user/${this.user_id}/wordcount?compileBackendClass=c4d&compileGroup=priority&file=main.tex&image=mock-image-name`
|
|
|
)
|
|
)
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|