Log out warning when using Mongo for version still

This commit is contained in:
James Allen 2014-05-14 14:16:27 +01:00
parent 0199f2e129
commit bdfe018cad
9 changed files with 21 additions and 12 deletions

View file

@ -3,6 +3,7 @@ Settings = require "settings-sharelatex"
Errors = require "./Errors" Errors = require "./Errors"
Metrics = require "./Metrics" Metrics = require "./Metrics"
{db, ObjectId} = require("./mongojs") {db, ObjectId} = require("./mongojs")
logger = require "logger-sharelatex"
module.exports = PersistenceManager = module.exports = PersistenceManager =
getDoc: (project_id, doc_id, callback = (error, lines, version) ->) -> getDoc: (project_id, doc_id, callback = (error, lines, version) ->) ->
@ -11,6 +12,7 @@ module.exports = PersistenceManager =
if version? if version?
callback null, lines, version callback null, lines, version
else else
logger.warn project_id: project_id, doc_id: doc_id, "loading doc version from mongo - deprecated"
PersistenceManager.getDocVersionInMongo doc_id, (error, version) -> PersistenceManager.getDocVersionInMongo doc_id, (error, version) ->
return callback(error) if error? return callback(error) if error?
if version? if version?

View file

@ -5,7 +5,7 @@ modulePath = path.join __dirname, '../../../app/js/RedisManager.js'
keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js')
project_id = 1234 project_id = 1234
doc_id = 5678 doc_id = 5678
loadModule = require('./module-loader').loadModule SandboxedModule = require('sandboxed-module')
describe 'putting a doc into memory', ()-> describe 'putting a doc into memory', ()->
lines = ["this is one line", "and another line"] lines = ["this is one line", "and another line"]
@ -44,7 +44,7 @@ describe 'putting a doc into memory', ()->
exec:(callback)-> exec:(callback)->
callback() callback()
redisManager = loadModule(modulePath, mocks).module.exports redisManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should put a all data into memory', (done)-> it 'should put a all data into memory', (done)->
redisManager.putDocInMemory project_id, doc_id, lines, version, ()-> redisManager.putDocInMemory project_id, doc_id, lines, version, ()->

View file

@ -3,6 +3,7 @@ chai = require('chai')
should = chai.should() should = chai.should()
modulePath = "../../../../app/js/DocOpsManager.js" modulePath = "../../../../app/js/DocOpsManager.js"
SandboxedModule = require('sandboxed-module') SandboxedModule = require('sandboxed-module')
{ObjectId} = require "mongojs"
describe "DocOpsManager", -> describe "DocOpsManager", ->
beforeEach -> beforeEach ->

View file

@ -3,7 +3,7 @@ should = require('chai').should()
path = require('path') path = require('path')
modulePath = path.join __dirname, '../../../app/js/RedisManager.js' modulePath = path.join __dirname, '../../../app/js/RedisManager.js'
_ = require('underscore') _ = require('underscore')
loadModule = require('./module-loader').loadModule SandboxedModule = require('sandboxed-module')
keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js')
describe 'getting entire list of pending updates', ()-> describe 'getting entire list of pending updates', ()->
@ -33,7 +33,7 @@ describe 'getting entire list of pending updates', ()->
exec: (callback)-> exec: (callback)->
callback(null, redisReturn) callback(null, redisReturn)
redisManager = loadModule(modulePath, mocks).module.exports redisManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should have 3 elements in array', (done)-> it 'should have 3 elements in array', (done)->
redisManager.getPendingUpdatesForDoc doc_id, (err, listOfUpdates)-> redisManager.getPendingUpdatesForDoc doc_id, (err, listOfUpdates)->

View file

@ -4,7 +4,7 @@ should = require('chai').should()
path = require('path') path = require('path')
modulePath = path.join __dirname, '../../../app/js/RedisManager.js' modulePath = path.join __dirname, '../../../app/js/RedisManager.js'
keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js')
loadModule = require('./module-loader').loadModule SandboxedModule = require('sandboxed-module')
describe 'getting cound of docs from memory', ()-> describe 'getting cound of docs from memory', ()->
@ -35,7 +35,7 @@ describe 'getting cound of docs from memory', ()->
exec:(callback)-> exec:(callback)->
callback() callback()
redisManager = loadModule(modulePath, mocks).module.exports redisManager = SandboxedModule.require(modulePath, requires: mocks)
redisManager.putDocInMemory project_id, doc_id1, 0, ["line"], -> redisManager.putDocInMemory project_id, doc_id1, 0, ["line"], ->
redisManager.putDocInMemory project_id, doc_id2, 0, ["ledf"], -> redisManager.putDocInMemory project_id, doc_id2, 0, ["ledf"], ->
redisManager.putDocInMemory project_id, doc_id3, 0, ["ledf"], -> redisManager.putDocInMemory project_id, doc_id3, 0, ["ledf"], ->

View file

@ -7,7 +7,7 @@ keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js')
project_id = 1234 project_id = 1234
doc_id = 5678 doc_id = 5678
blockingKey = "Blocking:#{doc_id}" blockingKey = "Blocking:#{doc_id}"
loadModule = require('../module-loader').loadModule SandboxedModule = require('sandboxed-module')
describe 'Lock Manager - checking the lock', ()-> describe 'Lock Manager - checking the lock', ()->
@ -27,7 +27,7 @@ describe 'Lock Manager - checking the lock', ()->
expire: exireStub expire: exireStub
set: setStub set: setStub
exec: execStub exec: execStub
LockManager = loadModule(modulePath, mocks).module.exports LockManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should check if lock exists but not set or expire', (done)-> it 'should check if lock exists but not set or expire', (done)->
execStub.callsArgWith(0, null, ["1"]) execStub.callsArgWith(0, null, ["1"])

View file

@ -6,7 +6,7 @@ modulePath = path.join __dirname, '../../../../app/js/LockManager.js'
keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js') keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js')
project_id = 1234 project_id = 1234
doc_id = 5678 doc_id = 5678
loadModule = require('../module-loader').loadModule SandboxedModule = require('sandboxed-module')
describe 'LockManager - releasing the lock', ()-> describe 'LockManager - releasing the lock', ()->
@ -19,7 +19,7 @@ describe 'LockManager - releasing the lock', ()->
auth:-> auth:->
del:deleteStub del:deleteStub
LockManager = loadModule(modulePath, mocks).module.exports LockManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should put a all data into memory', (done)-> it 'should put a all data into memory', (done)->
LockManager.releaseLock doc_id, -> LockManager.releaseLock doc_id, ->

View file

@ -13,6 +13,7 @@ describe "PersistenceManager.getDoc", ->
"./Metrics": @Metrics = "./Metrics": @Metrics =
Timer: class Timer Timer: class Timer
done: sinon.stub() done: sinon.stub()
"logger-sharelatex": @logger = {warn: sinon.stub()}
"./mongojs": "./mongojs":
db: @db = { docOps: {} } db: @db = { docOps: {} }
ObjectId: ObjectId ObjectId: ObjectId
@ -52,6 +53,11 @@ describe "PersistenceManager.getDoc", ->
.calledWith(@doc_id) .calledWith(@doc_id)
.should.equal true .should.equal true
it "shoud log a warning", ->
@logger.warn
.calledWith(project_id: @project_id, doc_id: @doc_id, "loading doc version from mongo - deprecated")
.should.equal true
it "should call the callback with the lines and version", -> it "should call the callback with the lines and version", ->
@callback.calledWith(null, @lines, @version).should.equal true @callback.calledWith(null, @lines, @version).should.equal true

View file

@ -5,7 +5,7 @@ sinon = require('sinon')
path = require('path') path = require('path')
modulePath = path.join __dirname, '../../../app/js/RedisManager.js' modulePath = path.join __dirname, '../../../app/js/RedisManager.js'
keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js')
loadModule = require('./module-loader').loadModule SandboxedModule = require('sandboxed-module')
describe 'removing single doc from memory', ()-> describe 'removing single doc from memory', ()->
@ -43,7 +43,7 @@ describe 'removing single doc from memory', ()->
exec:(callback)-> exec:(callback)->
callback(null, []) callback(null, [])
redisManager = loadModule(modulePath, mocks).module.exports redisManager = SandboxedModule.require(modulePath, requires: mocks)
redisManager.putDocInMemory project_id, doc_id1, 0, ["line"], -> redisManager.putDocInMemory project_id, doc_id1, 0, ["line"], ->
redisManager.putDocInMemory project_id, doc_id2, 0, ["ledf"], -> redisManager.putDocInMemory project_id, doc_id2, 0, ["ledf"], ->
redisManager.putDocInMemory project_id, doc_id3, 0, ["ledf"], -> redisManager.putDocInMemory project_id, doc_id3, 0, ["ledf"], ->