Merge pull request #3241 from overleaf/jpa-speedup-acceptance-tests

[misc] speedup the ConvertArchivedState test suite

GitOrigin-RevId: e7d6471955aabbc6af76e27fdf23d97e2fd87901
This commit is contained in:
Jessica Lawshe 2020-09-29 09:29:51 -05:00 committed by Copybot
parent 562fb35416
commit 2a3cb615ee
2 changed files with 12 additions and 8 deletions

View file

@ -33,7 +33,8 @@ async function batchedUpdate(collectionName, query, update, projection) {
// Some secondary connections are not ready as it returns, leading to
// failing cursor actions with a readPreference set to 'secondary'.
// TODO(das7pad): revisit/remove this delay after the mongo-driver update.
await Promise.all([getNativeDb(), promisify(setTimeout)(10 * 1000)])
const CONNECT_DELAY = parseInt(process.env.CONNECT_DELAY, 10) || 10000
await Promise.all([getNativeDb(), promisify(setTimeout)(CONNECT_DELAY)])
const db = await getNativeDb()
const collection = db.collection(collectionName)

View file

@ -67,14 +67,17 @@ describe('ConvertArchivedState', function() {
})
beforeEach(function(done) {
exec('node scripts/convert_archived_state.js', (error, stdout, stderr) => {
console.log(stdout)
console.error(stderr)
if (error) {
return done(error)
exec(
'CONNECT_DELAY=1 node scripts/convert_archived_state.js',
(error, stdout, stderr) => {
console.log(stdout)
console.error(stderr)
if (error) {
return done(error)
}
done()
}
done()
})
)
})
describe('main method', function() {