mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Explicitly wait for S3 in acceptance tests
This commit is contained in:
parent
237c4113cd
commit
56b38af678
2 changed files with 25 additions and 2 deletions
|
@ -2,6 +2,9 @@ app = require('../../../app')
|
|||
require("logger-sharelatex").logger.level("info")
|
||||
logger = require("logger-sharelatex")
|
||||
Settings = require("settings-sharelatex")
|
||||
request = require('request')
|
||||
|
||||
S3_TRIES = 30
|
||||
|
||||
module.exports =
|
||||
running: false
|
||||
|
@ -21,4 +24,22 @@ module.exports =
|
|||
logger.log("filestore running in dev mode")
|
||||
|
||||
for callback in @callbacks
|
||||
callback()
|
||||
callback()
|
||||
|
||||
waitForS3: (callback, tries) ->
|
||||
return callback() unless Settings.filestore.s3?.endpoint
|
||||
tries = 1 unless tries
|
||||
|
||||
request.get "#{Settings.filestore.s3.endpoint}/", (err, response) =>
|
||||
console.log(err, response?.statusCode, tries)
|
||||
if !err && [200, 404].includes(response?.statusCode)
|
||||
return callback()
|
||||
|
||||
if tries == S3_TRIES
|
||||
return callback('timed out waiting for S3')
|
||||
|
||||
setTimeout(
|
||||
() =>
|
||||
@waitForS3 callback, tries + 1
|
||||
1000
|
||||
)
|
||||
|
|
|
@ -29,8 +29,10 @@ describe "Filestore", ->
|
|||
"there are 3 lines in all"
|
||||
].join("\n")
|
||||
|
||||
fs.writeFile(@localFileReadPath, @constantFileContent, done)
|
||||
@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
|
||||
fs.writeFile @localFileReadPath, @constantFileContent, (err) ->
|
||||
return done(err) if err
|
||||
FilestoreApp.waitForS3(done)
|
||||
|
||||
beforeEach (done)->
|
||||
FilestoreApp.ensureRunning =>
|
||||
|
|
Loading…
Reference in a new issue