Merge pull request #96 from overleaf/em-upgrade-node-12

Upgrade to Node 12
This commit is contained in:
Eric Mc Sween 2021-03-17 09:12:43 -04:00 committed by GitHub
commit ccf1f502e2
17 changed files with 81 additions and 87 deletions

View file

@ -0,0 +1,3 @@
{
"require": "test/setup.js"
}

View file

@ -1 +1 @@
10.23.1
12.21.0

View file

@ -2,7 +2,7 @@
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
FROM node:10.23.1 as base
FROM node:12.21.0 as base
WORKDIR /app

View file

@ -21,8 +21,10 @@ DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
clean:
docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-$(DOCKER_COMPOSE_TEST_UNIT) down --rmi local
-$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --rmi local
format:
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format

View file

@ -3,6 +3,6 @@ docstore
--docker-repos=gcr.io/overleaf-ops
--env-add=
--env-pass-through=
--node-version=10.23.1
--node-version=12.21.0
--public-repo=True
--script-version=3.4.0
--script-version=3.7.0

View file

@ -6,7 +6,7 @@ version: "2.3"
services:
test_unit:
image: node:10.23.1
image: node:12.21.0
volumes:
- .:/app
working_dir: /app
@ -18,7 +18,7 @@ services:
user: node
test_acceptance:
image: node:10.23.1
image: node:12.21.0
volumes:
- .:/app
working_dir: /app

View file

@ -14,9 +14,7 @@
*/
process.env.BACKEND = 'gcs'
const Settings = require('settings-sharelatex')
const chai = require('chai')
const { expect } = chai
const should = chai.should()
const { expect } = require('chai')
const { db, ObjectId } = require('../../../app/js/mongodb')
const async = require('async')
const DocstoreApp = require('./helpers/DocstoreApp')
@ -96,8 +94,8 @@ describe('Archiving', function () {
((doc) => {
return (callback) => {
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
return callback()
})
@ -155,7 +153,7 @@ describe('Archiving', function () {
return db.docs.findOne({ _id: doc._id }, (error, doc) => {
doc.lines.should.deep.equal(this.docs[i].lines)
doc.ranges.should.deep.equal(this.docs[i].ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return callback()
})
}
@ -218,8 +216,8 @@ describe('Archiving', function () {
if (error != null) {
throw error
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
doc.deleted.should.equal(true)
return done()
@ -267,7 +265,7 @@ describe('Archiving', function () {
}
doc.lines.should.deep.equal(this.doc.lines)
doc.ranges.should.deep.equal(this.doc.ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
doc.deleted.should.equal(true)
return done()
})
@ -365,8 +363,8 @@ describe('Archiving', function () {
if (error) {
return done(error)
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
done()
})
@ -433,8 +431,8 @@ describe('Archiving', function () {
if (error != null) {
throw error
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
return done()
})
@ -476,7 +474,7 @@ describe('Archiving', function () {
}
doc.lines.should.deep.equal(this.doc.lines)
doc.ranges.should.deep.equal(this.doc.ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return done()
})
})
@ -907,8 +905,8 @@ describe('Archiving', function () {
if (error != null) {
throw error
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
return done()
})
@ -950,7 +948,7 @@ describe('Archiving', function () {
}
doc.lines.should.deep.equal(this.doc.lines)
doc.ranges.should.deep.equal(this.doc.ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return done()
})
})
@ -1026,8 +1024,8 @@ describe('Archiving', function () {
if (error != null) {
throw error
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
return done()
})
@ -1070,7 +1068,7 @@ describe('Archiving', function () {
}
doc.lines.should.deep.equal(this.doc.lines)
doc.ranges.should.deep.equal(this.doc.ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return done()
})
})
@ -1123,8 +1121,8 @@ describe('Archiving', function () {
if (error != null) {
throw error
}
should.not.exist(doc.lines)
should.not.exist(doc.ranges)
expect(doc.lines).not.to.exist
expect(doc.ranges).not.to.exist
doc.inS3.should.equal(true)
return done()
})
@ -1166,7 +1164,7 @@ describe('Archiving', function () {
}
doc.lines.should.deep.equal(this.doc.lines)
doc.ranges.should.deep.equal(this.doc.ranges)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return done()
})
})
@ -1220,7 +1218,7 @@ describe('Archiving', function () {
throw error
}
doc.lines.should.deep.equal(this.doc.lines)
should.not.exist(doc.inS3)
expect(doc.inS3).not.to.exist
return done()
})
})

View file

@ -11,10 +11,8 @@
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const chai = require('chai')
chai.should()
const { db, ObjectId } = require('../../../app/js/mongodb')
const { expect } = chai
const { expect } = require('chai')
const DocstoreApp = require('./helpers/DocstoreApp')
const Errors = require('../../../app/js/Errors')
const Settings = require('settings-sharelatex')

View file

@ -12,8 +12,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongodb')
const async = require('async')
const DocstoreApp = require('./helpers/DocstoreApp')

View file

@ -12,8 +12,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongodb')
const DocstoreApp = require('./helpers/DocstoreApp')

View file

@ -11,8 +11,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongodb')
const DocstoreApp = require('./helpers/DocstoreApp')

View file

@ -0,0 +1,40 @@
const chai = require('chai')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
const chaiAsPromised = require('chai-as-promised')
const SandboxedModule = require('sandboxed-module')
// Chai configuration
chai.should()
chai.use(sinonChai)
chai.use(chaiAsPromised)
// Global stubs
const sandbox = sinon.createSandbox()
const stubs = {
logger: {
log: sandbox.stub(),
warn: sandbox.stub(),
err: sandbox.stub(),
error: sandbox.stub(),
fatal: sandbox.stub()
}
}
// SandboxedModule configuration
SandboxedModule.configure({
requires: {
'logger-sharelatex': stubs.logger
},
globals: { Buffer, JSON, console, process }
})
exports.mochaHooks = {
beforeEach() {
this.logger = stubs.logger
},
afterEach() {
sandbox.reset()
}
}

View file

@ -1,21 +1,16 @@
const sinon = require('sinon')
const chai = require('chai')
const { expect } = chai
const { expect } = require('chai')
const modulePath = '../../../app/js/DocArchiveManager.js'
const SandboxedModule = require('sandboxed-module')
const { ObjectId } = require('mongodb')
const Errors = require('../../../app/js/Errors')
chai.use(require('chai-as-promised'))
chai.use(require('sinon-chai'))
describe('DocArchiveManager', function () {
let DocArchiveManager,
PersistorManager,
MongoManager,
RangeManager,
Settings,
Logger,
Crypto,
Streamifier,
HashDigest,
@ -39,10 +34,6 @@ describe('DocArchiveManager', function () {
bucket: 'wombat'
}
}
Logger = {
log: sinon.stub(),
err: sinon.stub()
}
HashDigest = sinon.stub().returns(md5Sum)
HashUpdate = sinon.stub().returns({ digest: HashDigest })
Crypto = {
@ -141,17 +132,12 @@ describe('DocArchiveManager', function () {
DocArchiveManager = SandboxedModule.require(modulePath, {
requires: {
'settings-sharelatex': Settings,
'logger-sharelatex': Logger,
crypto: Crypto,
streamifier: Streamifier,
'./MongoManager': MongoManager,
'./RangeManager': RangeManager,
'./PersistorManager': PersistorManager,
'./Errors': Errors
},
globals: {
console,
JSON
}
})
})

View file

@ -14,11 +14,7 @@
*/
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
const chai = require('chai')
chai.use(require('sinon-chai'))
const { assert } = require('chai')
chai.should()
const { expect } = chai
const { assert, expect } = require('chai')
const modulePath = require('path').join(__dirname, '../../../app/js/DocManager')
const { ObjectId } = require('mongodb')
const Errors = require('../../../app/js/Errors')
@ -36,11 +32,6 @@ describe('DocManager', function () {
shouldUpdateRanges: sinon.stub().returns(false)
}),
'settings-sharelatex': (this.settings = { docstore: {} }),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
warn() {},
err() {}
}),
'./Errors': Errors
}
})
@ -493,7 +484,6 @@ describe('DocManager', function () {
this.DocArchiveManager.archiveDocById = sinon
.stub()
.yields(this.err)
this.logger.warn = sinon.stub()
this.callback = sinon.stub().callsFake(done)
this.DocManager.deleteDoc(
this.project_id,
@ -630,7 +620,6 @@ describe('DocManager', function () {
beforeEach(function () {
this.settings.docstore.archiveOnSoftDelete = true
this.meta.deleted = true
this.logger.warn = sinon.stub()
})
describe('when the background flush succeeds', function () {

View file

@ -10,11 +10,8 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const SandboxedModule = require('sandboxed-module')
const { assert } = require('chai')
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { expect } = chai
const { assert, expect } = require('chai')
const modulePath = require('path').join(
__dirname,
'../../../app/js/HttpController'
@ -30,15 +27,9 @@ describe('HttpController', function () {
requires: {
'./DocManager': (this.DocManager = {}),
'./DocArchiveManager': (this.DocArchiveManager = {}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
fatal: sinon.stub()
}),
'settings-sharelatex': settings,
'./HealthChecker': {}
},
globals: { process }
}
})
this.res = {
send: sinon.stub(),

View file

@ -11,7 +11,6 @@
*/
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join(
__dirname,
'../../../app/js/MongoManager'
@ -28,11 +27,7 @@ describe('MongoManager', function () {
ObjectId
},
'@overleaf/metrics': { timeAsyncMethod: sinon.stub() },
'logger-sharelatex': { log() {} },
'settings-sharelatex': { max_deleted_docs: 42 }
},
globals: {
console
}
})
this.project_id = ObjectId().toString()

View file

@ -12,14 +12,12 @@
*/
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
require('chai').should()
const { expect } = require('chai')
const { assert, expect } = require('chai')
const modulePath = require('path').join(
__dirname,
'../../../app/js/RangeManager'
)
const { ObjectId } = require('mongodb')
const { assert } = require('chai')
const _ = require('underscore')
describe('RangeManager', function () {