feat(thresholds): migration from previous threshold schema

This commit is contained in:
Torkel Ödegaard
2016-08-10 20:41:21 +02:00
parent 7c0675798e
commit bdb8d77562
3 changed files with 85 additions and 85 deletions

View File

@@ -45,6 +45,7 @@ describe('grafanaGraph', function() {
logBase: 1
}
],
thresholds: [],
xaxis: {},
seriesOverrides: [],
tooltip: {
@@ -113,101 +114,32 @@ describe('grafanaGraph', function() {
graphScenario('grid thresholds 100, 200', function(ctx) {
ctx.setup(function(ctrl) {
ctrl.panel.alert = {
warn: { op: ">", value: 100},
crit: { op: ">", value: 200}
};
ctrl.panel.thresholds = [
{op: ">", value: 300, fillColor: 'red', lineColor: 'blue', fill: true, line: true},
{op: ">", value: 200, fillColor: '#ed2e18', fill: true}
];
});
it('should add crit fill', function() {
it('should add fill for threshold with fill: true', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[0].yaxis.from).to.be(200);
expect(markings[0].yaxis.from).to.be(300);
expect(markings[0].yaxis.to).to.be(Infinity);
expect(markings[0].color).to.be('rgba(234, 112, 112, 0.10)');
expect(markings[0].color).to.be('red');
});
it('should add crit line', function() {
it('should add line', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[1].yaxis.from).to.be(200);
expect(markings[1].yaxis.to).to.be(200);
expect(markings[1].color).to.be('#ed2e18');
expect(markings[1].yaxis.from).to.be(300);
expect(markings[1].yaxis.to).to.be(300);
expect(markings[1].color).to.be('blue');
});
it('should add warn fill', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[2].yaxis.from).to.be(100);
expect(markings[2].yaxis.to).to.be(200);
expect(markings[2].color).to.be('rgba(216, 200, 27, 0.10)');
});
it('should add warn line', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[3].yaxis.from).to.be(100);
expect(markings[3].yaxis.to).to.be(100);
expect(markings[3].color).to.be('#F79520');
});
});
graphScenario('inverted grid thresholds 200, 100', function(ctx) {
ctx.setup(function(ctrl) {
ctrl.panel.alert = {
warn: { op: "<", value: 200},
crit: { op: "<", value: 100}
};
});
it('should add crit fill', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[0].yaxis.from).to.be(100);
expect(markings[0].yaxis.to).to.be(-Infinity);
expect(markings[0].color).to.be('rgba(234, 112, 112, 0.10)');
});
it('should add crit line', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[1].yaxis.from).to.be(100);
expect(markings[1].yaxis.to).to.be(100);
expect(markings[1].color).to.be('#ed2e18');
});
it('should add warn fill', function() {
it('should add fill for second thresholds to previous threshold', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[2].yaxis.from).to.be(200);
expect(markings[2].yaxis.to).to.be(100);
expect(markings[2].color).to.be('rgba(216, 200, 27, 0.10)');
});
it('should add warn line', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[3].yaxis.from).to.be(200);
expect(markings[3].yaxis.to).to.be(200);
expect(markings[3].color).to.be('#F79520');
});
});
graphScenario('grid warn thresholds from zero', function(ctx) {
ctx.setup(function(ctrl) {
ctrl.panel.alert = {
warn: { op: ">", value: 0},
crit: { op: ">", value: undefined}
};
});
it('should add warn fill', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[0].yaxis.from).to.be(0);
expect(markings[0].yaxis.to).to.be(Infinity);
expect(markings[0].color).to.be('rgba(216, 200, 27, 0.10)');
});
it('should add warn line', function() {
var markings = ctx.plotOptions.grid.markings;
expect(markings[1].yaxis.from).to.be(0);
expect(markings[1].yaxis.to).to.be(0);
expect(markings[1].color).to.be('#F79520');
expect(markings[2].yaxis.to).to.be(300);
});
});