summaryrefslogtreecommitdiffstats
path: root/tests/sql/sla_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:39 +0000
commitfcfb5e62f95d625836328131cc5ca851182bcae4 (patch)
tree5309ef2284a82d61ece838d1dd1c97c09df152b8 /tests/sql/sla_test.go
parentAdding upstream version 1.1.1. (diff)
downloadicingadb-6ee3f6d80af8d7d56be5d07c1977df9f7da6f0ec.tar.xz
icingadb-6ee3f6d80af8d7d56be5d07c1977df9f7da6f0ec.zip
Adding upstream version 1.2.0.upstream/1.2.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/sql/sla_test.go')
-rw-r--r--tests/sql/sla_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/sql/sla_test.go b/tests/sql/sla_test.go
index 8a89850..de2bace 100644
--- a/tests/sql/sla_test.go
+++ b/tests/sql/sla_test.go
@@ -48,6 +48,42 @@ func TestSla(t *testing.T) {
End: 2000,
Expected: 60.0,
}, {
+ Name: "MultipleStateChangesDecimalsOddNumbers",
+ // Test flapping again, also that calculations are rounded correctly including decimal places.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -2.3%
+ &State{Time: 1023, State: 0, PreviousState: 2},
+ &State{Time: 1100, State: 2, PreviousState: 0}, // -14.2%
+ &State{Time: 1242, State: 0, PreviousState: 2},
+ &State{Time: 1300, State: 2, PreviousState: 0}, // -0.7%
+ &State{Time: 1307, State: 0, PreviousState: 2},
+ &State{Time: 1400, State: 2, PreviousState: 0}, // -26.6%
+ &State{Time: 1666, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 2000,
+ Expected: 56.2,
+ }, {
+ Name: "MultipleStateChangesDecimalsFractionOneThird",
+ // Test decimal representation of a fraction including precision and scale.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -33.3..%
+ &State{Time: 1100, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 1300,
+ Expected: 66.6667,
+ }, {
+ Name: "MultipleStateChangesDecimalsFractionSeventhPart",
+ // Test decimal representation of a fraction including precision and scale.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -85.7142..%
+ &State{Time: 1600, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 1700,
+ Expected: 14.2857,
+ }, {
Name: "OverlappingDowntimesAndProblems",
// SLA should be 90%:
// 1000..1100: OK, no downtime