[misc] test/acceptance: wait for the s3 container to start

This commit is contained in:
Jakob Ackermann 2020-01-24 19:13:29 +01:00
parent b0b96ee014
commit ca668ad657
2 changed files with 18 additions and 0 deletions

View file

@ -20,6 +20,9 @@ describe "Archiving updates", ->
message = new Error("s3 keys not setup, this test setup will fail")
return done(message)
TrackChangesClient.waitForS3 done
before (done) ->
@now = Date.now()
@to = @now
@user_id = ObjectId().toString()

View file

@ -100,6 +100,21 @@ module.exports = TrackChangesClient =
response.statusCode.should.equal 204
callback(error)
waitForS3: (done, retries=42) ->
if !Settings.trackchanges.s3.endpoint
return done()
request.get "#{Settings.trackchanges.s3.endpoint}/", (err, res) ->
if res && res.statusCode < 500
return done()
if retries == 0
return done(err or new Error("s3 returned #{res.statusCode}"))
setTimeout () ->
TrackChangesClient.waitForS3(done, --retries)
, 1000
getS3Doc: (project_id, doc_id, pack_id, callback = (error, body) ->) ->
params =
Bucket: S3_BUCKET