Skip to content

Commit

Permalink
fix the test for nulls 😊 (#97)
Browse files Browse the repository at this point in the history
🐿 v2.9.0
  • Loading branch information
bjfletcher authored Jul 18, 2018
1 parent e828c73 commit 9adde27
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/checks/graphiteThreshold.check.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GraphiteThresholdCheck extends Check {
.then(results => {
const simplifiedResults = results.map(result => {
const isFailing = result.datapoints.some(value => {
if (typeof value[0] === null) {
if (value[0] === null) {
// metric data is unavailable, we don't fail this threshold check if metric data is unavailable
// if you want a failing check for when metric data is unavailable, use graphiteWorking
return false;
Expand Down
26 changes: 26 additions & 0 deletions test/graphiteThreshold.check.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,32 @@ describe('Graphite Threshold Check', function(){
});
});

it('should be healthy if any non-null datapoint is below lower threshold', done => {
mockGraphite([
{
target: "next.heroku.es-interface.pushUpdater_1_EU.push_event_received",
datapoints: [
[ 2, 1531921740 ],
[ 3, 1531921800 ],
[ 2, 1531921860 ],
[ null, 1531921920 ],
[ null, 1531921980 ]
]
}
]);
check = new Check(getCheckConfig({
threshold: 1,
direction: 'below',
samplePeriod: '5min'
}));
check.start();
setTimeout(() => {
expect(check.getStatus().ok).to.be.true;
expect(check.getStatus().checkOutput).to.equal('No threshold error detected in graphite data for next.metric.200.');
done();
});
});

});

it('Should be possible to configure sample period', function(done){
Expand Down

0 comments on commit 9adde27

Please sign in to comment.