Explicitly wait for S3 in acceptance tests

This commit is contained in:
Simon Detheridge 2019-12-10 17:43:34 +00:00
parent 237c4113cd
commit 56b38af678
2 changed files with 25 additions and 2 deletions

View file

@ -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
@ -22,3 +25,21 @@ module.exports =
for callback in @callbacks
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
)

View file

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