add initial compileGroup support

This commit is contained in:
Brian Gough
2020-06-11 16:01:44 +01:00
parent 9b92793b89
commit b33734bab6
9 changed files with 183 additions and 18 deletions

View File

@@ -160,7 +160,8 @@ describe('CompileManager', function() {
compiler: (this.compiler = 'pdflatex'),
timeout: (this.timeout = 42000),
imageName: (this.image = 'example.com/image'),
flags: (this.flags = ['-file-line-error'])
flags: (this.flags = ['-file-line-error']),
compileGroup: (this.compileGroup = 'compile-group')
}
this.env = {}
this.Settings.compileDir = 'compiles'
@@ -199,7 +200,8 @@ describe('CompileManager', function() {
timeout: this.timeout,
image: this.image,
flags: this.flags,
environment: this.env
environment: this.env,
compileGroup: this.compileGroup
})
.should.equal(true)
})
@@ -253,7 +255,8 @@ describe('CompileManager', function() {
CHKTEX_OPTIONS: '-nall -e9 -e10 -w15 -w16',
CHKTEX_EXIT_ON_ERROR: 1,
CHKTEX_ULIMIT_OPTIONS: '-t 5 -v 64000'
}
},
compileGroup: this.compileGroup
})
.should.equal(true)
})
@@ -275,7 +278,8 @@ describe('CompileManager', function() {
timeout: this.timeout,
image: this.image,
flags: this.flags,
environment: this.env
environment: this.env,
compileGroup: this.compileGroup
})
.should.equal(true)
})
@@ -384,7 +388,7 @@ describe('CompileManager', function() {
this.stdout = `NODE\t${this.page}\t${this.h}\t${this.v}\t${this.width}\t${this.height}\n`
this.CommandRunner.run = sinon
.stub()
.callsArgWith(6, null, { stdout: this.stdout })
.callsArgWith(7, null, { stdout: this.stdout })
return this.CompileManager.syncFromCode(
this.project_id,
this.user_id,
@@ -443,7 +447,7 @@ describe('CompileManager', function() {
this.stdout = `NODE\t${this.Settings.path.compilesDir}/${this.project_id}-${this.user_id}/${this.file_name}\t${this.line}\t${this.column}\n`
this.CommandRunner.run = sinon
.stub()
.callsArgWith(6, null, { stdout: this.stdout })
.callsArgWith(7, null, { stdout: this.stdout })
return this.CompileManager.syncFromPdf(
this.project_id,
this.user_id,
@@ -485,7 +489,7 @@ describe('CompileManager', function() {
return describe('wordcount', function() {
beforeEach(function() {
this.CommandRunner.run = sinon.stub().callsArg(6)
this.CommandRunner.run = sinon.stub().callsArg(7)
this.fs.readFile = sinon
.stub()
.callsArgWith(

View File

@@ -87,6 +87,7 @@ describe('DockerRunner', function() {
this.project_id = 'project-id-123'
this.volumes = { '/local/compile/directory': '/compile' }
this.Settings.clsi.docker.image = this.defaultImage = 'default-image'
this.compileGroup = 'compile-group'
return (this.Settings.clsi.docker.env = { PATH: 'mock-path' })
})
@@ -123,6 +124,7 @@ describe('DockerRunner', function() {
this.image,
this.timeout,
this.env,
this.compileGroup,
(err, output) => {
this.callback(err, output)
return done()
@@ -172,6 +174,7 @@ describe('DockerRunner', function() {
this.image,
this.timeout,
this.env,
this.compileGroup,
this.callback
)
})
@@ -220,6 +223,7 @@ describe('DockerRunner', function() {
this.image,
this.timeout,
this.env,
this.compileGroup,
this.callback
)
})
@@ -253,6 +257,7 @@ describe('DockerRunner', function() {
null,
this.timeout,
this.env,
this.compileGroup,
this.callback
)
})
@@ -282,6 +287,7 @@ describe('DockerRunner', function() {
this.image,
this.timeout,
this.env,
this.compileGroup,
this.callback
)
})
@@ -293,6 +299,64 @@ describe('DockerRunner', function() {
})
})
describe('run with _getOptions', function() {
beforeEach(function(done) {
// this.DockerRunner._getContainerOptions = sinon
// .stub()
// .returns((this.options = { mockoptions: 'foo' }))
this.DockerRunner._fingerprintContainer = sinon
.stub()
.returns((this.fingerprint = 'fingerprint'))
this.name = `project-${this.project_id}-${this.fingerprint}`
this.command = ['mock', 'command', '--outdir=$COMPILE_DIR']
this.command_with_dir = ['mock', 'command', '--outdir=/compile']
this.timeout = 42000
return done()
})
describe('when a compile group config is set', function() {
beforeEach(function() {
this.Settings.clsi.docker.compileGroupConfig = {
'compile-group': {
'HostConfig.newProperty': 'new-property'
},
'other-group': { otherProperty: 'other-property' }
}
this.DockerRunner._runAndWaitForContainer = sinon
.stub()
.callsArgWith(3, null, (this.output = 'mock-output'))
return this.DockerRunner.run(
this.project_id,
this.command,
this.directory,
this.image,
this.timeout,
this.env,
this.compileGroup,
this.callback
)
})
it('should set the docker options for the compile group', function() {
const options = this.DockerRunner._runAndWaitForContainer.lastCall
.args[0]
return expect(options.HostConfig).to.deep.include({
Binds: ['/local/compile/directory:/compile:rw'],
LogConfig: { Type: 'none', Config: {} },
CapDrop: 'ALL',
SecurityOpt: ['no-new-privileges'],
newProperty: 'new-property'
})
})
return it('should call the callback', function() {
return this.callback.calledWith(null, this.output).should.equal(true)
})
})
})
describe('_runAndWaitForContainer', function() {
beforeEach(function() {
this.options = { mockoptions: 'foo', name: (this.name = 'mock-name') }

View File

@@ -48,6 +48,7 @@ describe('LatexRunner', function() {
this.mainFile = 'main-file.tex'
this.compiler = 'pdflatex'
this.image = 'example.com/image'
this.compileGroup = 'compile-group'
this.callback = sinon.stub()
this.project_id = 'project-id-123'
return (this.env = { foo: '123' })
@@ -55,7 +56,7 @@ describe('LatexRunner', function() {
return describe('runLatex', function() {
beforeEach(function() {
return (this.CommandRunner.run = sinon.stub().callsArgWith(6, null, {
return (this.CommandRunner.run = sinon.stub().callsArgWith(7, null, {
stdout: 'this is stdout',
stderr: 'this is stderr'
}))
@@ -71,7 +72,8 @@ describe('LatexRunner', function() {
compiler: this.compiler,
timeout: (this.timeout = 42000),
image: this.image,
environment: this.env
environment: this.env,
compileGroup: this.compileGroup
},
this.callback
)
@@ -85,7 +87,8 @@ describe('LatexRunner', function() {
this.directory,
this.image,
this.timeout,
this.env
this.env,
this.compileGroup
)
.should.equal(true)
})