mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -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")
|
require("logger-sharelatex").logger.level("info")
|
||||||
logger = require("logger-sharelatex")
|
logger = require("logger-sharelatex")
|
||||||
Settings = require("settings-sharelatex")
|
Settings = require("settings-sharelatex")
|
||||||
|
request = require('request')
|
||||||
|
|
||||||
|
S3_TRIES = 30
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
running: false
|
running: false
|
||||||
|
@ -22,3 +25,21 @@ module.exports =
|
||||||
|
|
||||||
for callback in @callbacks
|
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"
|
"there are 3 lines in all"
|
||||||
].join("\n")
|
].join("\n")
|
||||||
|
|
||||||
fs.writeFile(@localFileReadPath, @constantFileContent, done)
|
|
||||||
@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
|
@filestoreUrl = "http://localhost:#{settings.internal.filestore.port}"
|
||||||
|
fs.writeFile @localFileReadPath, @constantFileContent, (err) ->
|
||||||
|
return done(err) if err
|
||||||
|
FilestoreApp.waitForS3(done)
|
||||||
|
|
||||||
beforeEach (done)->
|
beforeEach (done)->
|
||||||
FilestoreApp.ensureRunning =>
|
FilestoreApp.ensureRunning =>
|
||||||
|
|
Loading…
Reference in a new issue