mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[document-updater] wrap doc locks in project lock (#35416)
* [document-updater] wrap doc locks in project lock * [document-updater] use BlockingProject as redis key prefix * [redis-wrapper] update comment GitOrigin-RevId: 0ce50e76386871e6c29481494febc8d6b37e7df5
This commit is contained in:
@@ -116,6 +116,38 @@ describe('index', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('extendLock', function () {
|
||||
beforeEach(function () {
|
||||
this.rclient = { eval: sinon.stub() }
|
||||
this.locker = new this.RedisLocker({
|
||||
rclient: this.rclient,
|
||||
getKey: id => `lock:${id}`,
|
||||
wrapTimeoutError: (err, id) => err,
|
||||
metricsPrefix: 'test',
|
||||
lockTTLSeconds: 30,
|
||||
})
|
||||
})
|
||||
|
||||
it('should extend the lock TTL when we still own it', function (done) {
|
||||
this.rclient.eval.yields(null, 1)
|
||||
this.locker.extendLock('id-1', 'lock-value', err => {
|
||||
expect(err).to.not.exist
|
||||
this.rclient.eval
|
||||
.calledWith(sinon.match.string, 1, 'lock:id-1', 'lock-value', 30)
|
||||
.should.equal(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should error when we no longer hold the lock', function (done) {
|
||||
this.rclient.eval.yields(null, 0)
|
||||
this.locker.extendLock('id-1', 'lock-value', err => {
|
||||
expect(err).to.exist
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('redis-sentinel', function () {
|
||||
it('should throw an error when creating a client', function () {
|
||||
const redisSentinelOptions = {
|
||||
|
||||
Reference in New Issue
Block a user