Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Report RabbitMQ Close Errors on Staging #1325

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/models/rabbitmq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ RabbitMQ.prototype.close = function (cb) {
}
this.hermesClient.close(function () {
log.trace('RabbitMQ.prototype.close complete')
if (process.env.NODE_ENV === 'staging') {
// Ignore errors on staging close (to avoid alerting)
return cb()
}
cb.apply(this, arguments)
})
}
Expand Down
41 changes: 40 additions & 1 deletion unit/models/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,46 @@ describe('RabbitMQ Model: ' + moduleName, function () {
it('should just callback if the rabbitmq is not started', function (done) {
ctx.rabbitMQ.close(done)
})
})

describe('on error', function () {
var closeError = new Error('error on close')

beforeEach(function (done) {
ctx.rabbitMQ.hermesClient = { close: noop }
sinon.stub(ctx.rabbitMQ.hermesClient, 'close').yieldsAsync(closeError)
done()
})

it('should pass errors to the callback', function (done) {
ctx.rabbitMQ.close(function (err) {
expect(err).to.equal(closeError)
done()
})
})

describe('in staging', function () {
var originalNodeEnv

beforeEach(function (done) {
originalNodeEnv = process.env.NODE_ENV
process.env.NODE_ENV = 'staging'
done()
})

afterEach(function (done) {
process.env.NODE_ENV = originalNodeEnv
done()
})

it('should not pass errors to the callback', function (done) {
ctx.rabbitMQ.close(function (err) {
expect(err).to.not.exist()
done()
})
})
}) // end 'in staging'
}) // end 'on error'
}) // end 'close'

describe('unloadWorkers', function () {
it('should just callback if the rabbitmq is not started', function (done) {
Expand Down