Skip to content

Commit

Permalink
fix(container-registry-v5): Increase number of retries when fetching …
Browse files Browse the repository at this point in the history
…container logs (#1947)

* fix(container-registry-v5): fake setTimeout in tests

This shaves 15 seconds off of these tests.

* fix(container-registry-v5): increase number of log stream retries

https://heroku.support/1081019
  • Loading branch information
tevanoff committed Feb 28, 2022
1 parent 5291c48 commit 04e2dd0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/container-registry-v5/lib/streamer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const http = require('http-call').HTTP
const maxRetries = 10
const maxRetries = 30

async function call (url, out, retries) {
try {
Expand Down
1 change: 1 addition & 0 deletions packages/container-registry-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.2",
"depcheck": "^0.7.2",
"lolex": "^3.1.0",
"mocha": "^5.0.4",
"mockdate": "^2.0.2",
"nock": "^9.2.3",
Expand Down
18 changes: 15 additions & 3 deletions packages/container-registry-v5/test/streamer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { expect } = require('chai')
const nock = require('nock')
const stream = require('stream')
let lolex = require('lolex')

const streamer = require('../lib/streamer')

Expand All @@ -19,6 +20,17 @@ MockOut.prototype._write = function (d) {
}

describe('streaming', () => {
let clock;

beforeEach(function () {
clock = lolex.install()
clock.setTimeout = function (fn, timeout) { fn() }
})

afterEach(function () {
clock.uninstall()
})

it('streams data', () => {
const ws = new MockOut()
const api = nock('https://streamer.test:443')
Expand Down Expand Up @@ -49,18 +61,18 @@ describe('streaming', () => {
return streamer('https://streamer.test/streams/data.log', ws)
.then(() => expect(ws.data.join('')).to.equal('My retried data'))
.then(() => api.done())
}).timeout(5 * 1000 * 1.2)
})

it('errors on too many retries', async () => {
const ws = new MockOut()
const api = nock('https://streamer.test:443')
.get('/streams/data.log')
.times(10)
.times(30)
.reply(404, '')

await expect(streamer('https://streamer.test/streams/data.log', ws)).to.be.rejected
await api.done()
}).timeout(10 * 1000 * 1.2)
})

it('does not retry on non-404 errors', async () => {
const ws = new MockOut()
Expand Down

0 comments on commit 04e2dd0

Please sign in to comment.