mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
[clsi] gracefully handle fast exit of synctex/wordcount containers (#29505)
* [clsi] gracefully handle fast exit of synctex/wordcount containers * [clsi] do not change container options in-place for logging GitOrigin-RevId: 0b685310a3c72f8f46125fefaa30c1ddb19e7b07
This commit is contained in:
@@ -514,7 +514,7 @@ describe('DockerRunner', function () {
|
||||
sinon.spy(this.DockerRunner, 'startContainer')
|
||||
this.DockerRunner.waitForContainer = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, (this.exitCode = 42))
|
||||
.callsArgWith(3, null, (this.exitCode = 42))
|
||||
return this.DockerRunner._runAndWaitForContainer(
|
||||
this.options,
|
||||
this.volumes,
|
||||
@@ -675,6 +675,7 @@ describe('DockerRunner', function () {
|
||||
return this.DockerRunner.waitForContainer(
|
||||
this.containerId,
|
||||
this.timeout,
|
||||
{},
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
@@ -691,6 +692,49 @@ describe('DockerRunner', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the container is removed before waiting', function () {
|
||||
const err = new Error('not found')
|
||||
err.statusCode = 404
|
||||
beforeEach(function () {
|
||||
this.container.wait = sinon.stub().yields(err)
|
||||
})
|
||||
|
||||
describe('AutoRemove not set', function () {
|
||||
beforeEach(function () {
|
||||
this.DockerRunner.waitForContainer(
|
||||
this.containerId,
|
||||
this.timeout,
|
||||
{ HostConfig: {} },
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
it('should wait for the container', function () {
|
||||
this.getContainer.calledWith(this.containerId).should.equal(true)
|
||||
this.container.wait.called.should.equal(true)
|
||||
})
|
||||
it('should call the callback with the error', function () {
|
||||
this.callback.calledWith(err).should.equal(true)
|
||||
})
|
||||
})
|
||||
describe('AutoRemove=true', function () {
|
||||
beforeEach(function () {
|
||||
this.DockerRunner.waitForContainer(
|
||||
this.containerId,
|
||||
this.timeout,
|
||||
{ HostConfig: { AutoRemove: true } },
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
it('should wait for the container', function () {
|
||||
this.getContainer.calledWith(this.containerId).should.equal(true)
|
||||
this.container.wait.called.should.equal(true)
|
||||
})
|
||||
it('should call the callback with exit code 0', function () {
|
||||
this.callback.calledWith(null, 0).should.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return describe('when the container does not return before the timeout', function () {
|
||||
beforeEach(function (done) {
|
||||
this.container.wait = function (callback) {
|
||||
@@ -703,6 +747,7 @@ describe('DockerRunner', function () {
|
||||
return this.DockerRunner.waitForContainer(
|
||||
this.containerId,
|
||||
this.timeout,
|
||||
{},
|
||||
(...args) => {
|
||||
this.callback(...Array.from(args || []))
|
||||
return done()
|
||||
|
||||
Reference in New Issue
Block a user