Просмотр исходного кода

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

[misc] speedup the ConvertArchivedState test suite

GitOrigin-RevId: e7d6471955aabbc6af76e27fdf23d97e2fd87901
Jessica Lawshe 6 лет назад
Родитель
Сommit
2a3cb615ee

+ 2 - 1
services/web/scripts/helpers/batchedUpdate.js

@@ -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)

+ 10 - 7
services/web/test/acceptance/src/ConvertArchivedState.js

@@ -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() {