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"
Metrics = require "./Metrics"
{db, ObjectId} = require("./mongojs")
logger = require "logger-sharelatex"
module.exports = PersistenceManager =
getDoc: (project_id, doc_id, callback = (error, lines, version) ->) ->
@ -11,6 +12,7 @@ module.exports = PersistenceManager =
if version?
callback null, lines, version
else
logger.warn project_id: project_id, doc_id: doc_id, "loading doc version from mongo - deprecated"
PersistenceManager.getDocVersionInMongo doc_id, (error, version) ->
return callback(error) if error?
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')
project_id = 1234
doc_id = 5678
loadModule = require('./module-loader').loadModule
SandboxedModule = require('sandboxed-module')
describe 'putting a doc into memory', ()->
lines = ["this is one line", "and another line"]
@ -44,7 +44,7 @@ describe 'putting a doc into memory', ()->
exec:(callback)->
callback()
redisManager = loadModule(modulePath, mocks).module.exports
redisManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should put a all data into memory', (done)->
redisManager.putDocInMemory project_id, doc_id, lines, version, ()->

View file

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

View file

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

View file

@ -4,7 +4,7 @@ should = require('chai').should()
path = require('path')
modulePath = path.join __dirname, '../../../app/js/RedisManager.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', ()->
@ -35,7 +35,7 @@ describe 'getting cound of docs from memory', ()->
exec:(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_id2, 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
doc_id = 5678
blockingKey = "Blocking:#{doc_id}"
loadModule = require('../module-loader').loadModule
SandboxedModule = require('sandboxed-module')
describe 'Lock Manager - checking the lock', ()->
@ -27,7 +27,7 @@ describe 'Lock Manager - checking the lock', ()->
expire: exireStub
set: setStub
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)->
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')
project_id = 1234
doc_id = 5678
loadModule = require('../module-loader').loadModule
SandboxedModule = require('sandboxed-module')
describe 'LockManager - releasing the lock', ()->
@ -19,7 +19,7 @@ describe 'LockManager - releasing the lock', ()->
auth:->
del:deleteStub
LockManager = loadModule(modulePath, mocks).module.exports
LockManager = SandboxedModule.require(modulePath, requires: mocks)
it 'should put a all data into memory', (done)->
LockManager.releaseLock doc_id, ->

View file

@ -13,6 +13,7 @@ describe "PersistenceManager.getDoc", ->
"./Metrics": @Metrics =
Timer: class Timer
done: sinon.stub()
"logger-sharelatex": @logger = {warn: sinon.stub()}
"./mongojs":
db: @db = { docOps: {} }
ObjectId: ObjectId
@ -52,6 +53,11 @@ describe "PersistenceManager.getDoc", ->
.calledWith(@doc_id)
.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", ->
@callback.calledWith(null, @lines, @version).should.equal true

View file

@ -5,7 +5,7 @@ sinon = require('sinon')
path = require('path')
modulePath = path.join __dirname, '../../../app/js/RedisManager.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', ()->
@ -43,7 +43,7 @@ describe 'removing single doc from memory', ()->
exec:(callback)->
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_id2, 0, ["ledf"], ->
redisManager.putDocInMemory project_id, doc_id3, 0, ["ledf"], ->